新增:发布页真实化——媒体九宫格编辑态 + 建草稿/迁移发布两步 + 发布漏斗与媒体三段埋点,create 页 demo 发布流退役(T3-17)
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:
2026-09-10 14:42:13 +08:00
parent f873acf9a3
commit 9892b65a19
23 changed files with 2760 additions and 99 deletions
+46 -6
View File
@@ -169,6 +169,21 @@ CursorPage<PostComment> commentPage(
bool hasMore = false,
}) => CursorPage(items: items, nextCursor: nextCursor, hasMore: hasMore);
/// 草稿样本(T3-17 发布页草稿恢复用;media 可清空为纯文字草稿)。
Post sampleDraft({
String id = 'draft-1',
int version = 3,
String content = '草稿正文',
bool withMedia = true,
}) => Post.fromJson({
...samplePostJson(id: id, status: 'draft', version: version),
'content': content,
if (!withMedia) 'media': const <Map<String, dynamic>>[],
});
CursorPage<Post> postPage(List<Post> items) =>
CursorPage(items: items, nextCursor: null, hasMore: false);
/// 假仓库:controller 测试注入行为并记录调用(Completer 控时序)。
/// 未注入 handler 的方法一律 UnimplementedError(误触发即测试失败)。
class FakeCommunityRepository implements CommunityRepository {
@@ -189,6 +204,14 @@ class FakeCommunityRepository implements CommunityRepository {
Future<MediaUploadCredentials> Function(CreateMediaUploadRequest request)?
onCreateMediaUpload;
Future<MediaAsset> Function(String assetId)? onCompleteMediaUpload;
Future<Post> Function(CreatePostRequest request, String? idempotencyKey)?
onCreatePost;
Future<Post> Function(String postId, UpdatePostRequest request)? onUpdatePost;
Future<void> Function(String postId)? onDeletePost;
Future<CursorPage<Post>> Function(PostStatus? status)? onListMyPosts;
/// createPost 收到的幂等键顺序(同键重放断言用)。
final List<String?> idempotencyKeys = [];
@override
Future<CursorPage<FeedCard>> getFeed({int? limit, String? cursor}) {
@@ -241,22 +264,39 @@ class FakeCommunityRepository implements CommunityRepository {
}
@override
Future<Post> createPost(CreatePostRequest request) =>
throw UnimplementedError();
Future<Post> createPost(CreatePostRequest request, {String? idempotencyKey}) {
calls.add('createPost:${request.status?.name}:${request.content}');
idempotencyKeys.add(idempotencyKey);
return onCreatePost!(request, idempotencyKey);
}
@override
Future<Post> updatePost(String postId, UpdatePostRequest request) =>
throw UnimplementedError();
Future<Post> updatePost(String postId, UpdatePostRequest request) {
calls.add(
'updatePost:$postId:v${request.version}:publish=${request.publish}',
);
return onUpdatePost!(postId, request);
}
@override
Future<void> deletePost(String postId) => throw UnimplementedError();
Future<void> deletePost(String postId) {
calls.add('deletePost:$postId');
return onDeletePost!(postId);
}
@override
Future<CursorPage<Post>> listMyPosts({
int? limit,
String? cursor,
PostStatus? status,
}) => throw UnimplementedError();
}) {
calls.add('listMyPosts:${status?.name}');
return onListMyPosts == null
? Future.value(
const CursorPage(items: [], nextCursor: null, hasMore: false),
)
: onListMyPosts!(status);
}
@override
Future<CursorPage<PostComment>> listComments(