新增:发布页真实化——媒体九宫格编辑态 + 建草稿/迁移发布两步 + 发布漏斗与媒体三段埋点,create 页 demo 发布流退役(T3-17)
CI / flutter-gates (push) Successful in 3m9s
CI / flutter-gates (push) Successful in 3m9s
- 新增 PostComposePage(P3 发布页,push 路由 post_form):正文/类目 (general·help)/九宫格选图(组装 MediaUploader + UploadProgressOverlay, 删格按列表序重发 position)/发布 gating(正文非空 + 在场媒体全 ready) - 发布走「createPost(draft) → PATCH status=published」两步:迁移失败时草稿 已在服务端,UI 明确提示「草稿已保存」;40905 重置幂等键、42203 提示等图、 网络失败同键重放不重复建帖;40902 自动取新 version 重提一次 - 草稿:「存草稿」(manual) 与「取消 → 保留」(on_exit) 两路径 + 进页恢复最新 一条草稿(提示条/清空);「不保留」软删服务端草稿(post_deleted 触点) - 埋点:新增 post_analytics.dart(发布漏斗五事件 + 媒体三段,键集对齐字典 v3);MediaUploader 挂接 started/succeeded/failed(含 cancelled) 与 attemptSeq; pageName 枚举补 post_form - PostMediaEditGrid(同文件编辑态):3 列九宫格 + 虚线「+」格 + 删除角标 + 进度覆盖层 + 失败整格重试;页级上传汇总条 - create 页只余 AI 生成模拟(M4 原样保留),demo 发布流与 AppState.posts / publishPost / updatePost 及其持久化一并退役;首页 story「发布」与 Feed 空态 CTA 改为 push 真实发布页 - 测试 458 → 502(+44):发布页 widget 22、发布埋点 11、媒体三段 7、编辑态 九宫格 4、主壳发布闭环 1;另加桌面真链路 integration_test(env 门控) - flutter analyze 0 问题、dart format 无 diff;compose 六容器真链路实测通过 (选图上传 → 发布 → Feed 置顶 → 第二客户端可见) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,13 +7,16 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppState extends ChangeNotifier {
|
||||
static const _petKey = 'patbond_pet';
|
||||
static const _postsKey = 'patbond_posts';
|
||||
static const _locationWeatherKey = 'patbond_location_weather';
|
||||
|
||||
/// 首页问候卡 / 创作页 / 主壳头像仍消费的 demo 宠物(T2-12 起档案
|
||||
/// Tab 已切独立 pets feature 真实数据;此 demo 随后续工单收敛)。
|
||||
///
|
||||
/// **demo 帖子列表已于 T3-17 退役**:Feed / 详情页自 T3-14/15 起消费
|
||||
/// community 真实数据,发布页自 T3-17 起走真实两步上传 + 建草稿/迁移
|
||||
/// 发布,`posts` / `publishPost` / `updatePost` 与其
|
||||
/// shared_preferences 持久化一并删除(03 号评估 §1.1 判定)。
|
||||
PetProfile pet = initialPet;
|
||||
List<PostModel> posts = List<PostModel>.from(initialPosts);
|
||||
LocationWeather locationWeather = initialLocationWeather;
|
||||
bool isReady = false;
|
||||
|
||||
@@ -21,17 +24,11 @@ class AppState extends ChangeNotifier {
|
||||
try {
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
final savedPet = preferences.getString(_petKey);
|
||||
final savedPosts = preferences.getString(_postsKey);
|
||||
final savedLocationWeather = preferences.getString(_locationWeatherKey);
|
||||
|
||||
if (savedPet != null) {
|
||||
pet = PetProfile.fromJson(jsonDecode(savedPet) as Map<String, dynamic>);
|
||||
}
|
||||
if (savedPosts != null) {
|
||||
posts = (jsonDecode(savedPosts) as List)
|
||||
.map((item) => PostModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
if (savedLocationWeather != null) {
|
||||
locationWeather = LocationWeather.fromJson(
|
||||
jsonDecode(savedLocationWeather) as Map<String, dynamic>,
|
||||
@@ -40,7 +37,6 @@ class AppState extends ChangeNotifier {
|
||||
} catch (error, stackTrace) {
|
||||
debugPrint('读取本地数据失败,已使用默认数据:$error\n$stackTrace');
|
||||
pet = initialPet;
|
||||
posts = List<PostModel>.from(initialPosts);
|
||||
locationWeather = initialLocationWeather;
|
||||
} finally {
|
||||
isReady = true;
|
||||
@@ -48,21 +44,6 @@ class AppState extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updatePost(PostModel value) async {
|
||||
final index = posts.indexWhere((post) => post.id == value.id);
|
||||
if (index == -1) return;
|
||||
posts[index] = value;
|
||||
posts = List<PostModel>.from(posts);
|
||||
notifyListeners();
|
||||
await _savePosts();
|
||||
}
|
||||
|
||||
Future<void> publishPost(PostModel value) async {
|
||||
posts = [value, ...posts];
|
||||
notifyListeners();
|
||||
await _savePosts();
|
||||
}
|
||||
|
||||
Future<void> updateLocationWeather(LocationWeather value) async {
|
||||
locationWeather = value;
|
||||
notifyListeners();
|
||||
@@ -71,21 +52,15 @@ class AppState extends ChangeNotifier {
|
||||
|
||||
Future<void> resetDemoData() async {
|
||||
pet = initialPet;
|
||||
posts = List<PostModel>.from(initialPosts);
|
||||
locationWeather = initialLocationWeather;
|
||||
notifyListeners();
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
await Future.wait([
|
||||
preferences.remove(_petKey),
|
||||
preferences.remove(_postsKey),
|
||||
preferences.remove(_locationWeatherKey),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> _savePosts() {
|
||||
return _save(_postsKey, posts.map((post) => post.toJson()).toList());
|
||||
}
|
||||
|
||||
Future<void> _save(String key, Object value) async {
|
||||
try {
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
|
||||
Reference in New Issue
Block a user