新增:资料页真实化 + 编辑页——/me 读写、PATCH 三态、获赞与作品统计(T3.5-08)
资料页头部三项(展示名 / 头像 / 数字)自此全部来自服务端,176 行硬编码 demo(「萌宠新手(豆豆家长)」/ 24 / 1.8k / 2)退役。 - `PatchField<T>` 承载契约 v1.4.0 的 PATCH 三态(absent 不落键 / clear 落 显式 null / value 落值)。三态必须由类型承载而非 `T?` 加约定:把「不改」 也编码成 null,用户只改昵称就会连头像一起被服务端清掉。 - `UserProfile` 补 nickname / avatarUrl,展示回退 `nickname ?? username` **做在客户端展示层**——服务端 /me 刻意返回 DB 原值,编辑页因此只用原值 预填,避免把展示约定固化成真实昵称。 - `ProfileController`:`/me` 主链路四态 + 两块统计独立三态(统计失败只降级 这一块,不为两个数字丢掉整页);登出 reset 防跨账号泄漏。 - 编辑页维护三态意图而非「当前值整体提交」:昵称 / 头像各有显式清除入口, 未改字段的键根本不进 JSON;空 patch 直接短路(服务端对空 patch 答 400)。 - 昵称校验按**码点**计 1~32 且先 btrim,与 `ck_users_nickname` 对齐; 纯空白是校验失败而非隐式清空。 - `MediaUploader` 的 purpose 参数化 + 复用其六态编排的 `AvatarUploadSheet` (单图、预览确认后才交付 ready assetId,孤儿防护不变)。 - 修复 `/api/v1/me` 端口线路:该端点由 user 服务(:8082)提供,`ApiAuthRepository` 此前只挂 auth(:8081)会得到 404。此前无人消费 me(),故这条错线一直没被 触发;本单是第一个真实消费者,桌面实测即暴露。 测试 526 → 588(+62)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:patbond_flutter/analytics/analytics_page_name.dart';
|
||||
import 'package:patbond_flutter/analytics/page_view_tracker.dart';
|
||||
import 'package:patbond_flutter/core/theme/app_theme.dart';
|
||||
import 'package:patbond_flutter/core/widgets/avatar_upload_sheet.dart';
|
||||
import 'package:patbond_flutter/features/community/community_controller.dart';
|
||||
import 'package:patbond_flutter/features/community/community_interaction_analytics.dart';
|
||||
import 'package:patbond_flutter/features/community/feed_analytics.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:patbond_flutter/features/pets/pet_analytics.dart';
|
||||
import 'package:patbond_flutter/features/pets/pets_controller.dart';
|
||||
import 'package:patbond_flutter/features/pets/pets_page.dart';
|
||||
import 'package:patbond_flutter/features/post/post_detail_page.dart';
|
||||
import 'package:patbond_flutter/features/profile/profile_controller.dart';
|
||||
import 'package:patbond_flutter/features/profile/profile_page.dart';
|
||||
import 'package:patbond_flutter/features/services/services_page.dart';
|
||||
import 'package:patbond_flutter/state/app_state.dart';
|
||||
@@ -27,6 +29,7 @@ class MainShellPage extends StatefulWidget {
|
||||
required this.appState,
|
||||
required this.petsController,
|
||||
required this.communityController,
|
||||
required this.profileController,
|
||||
super.key,
|
||||
this.currentUserId,
|
||||
this.petAnalytics,
|
||||
@@ -35,6 +38,7 @@ class MainShellPage extends StatefulWidget {
|
||||
this.interactionAnalytics,
|
||||
this.postAnalytics,
|
||||
this.mediaUploaderFactory,
|
||||
this.avatarUploaderBuilder,
|
||||
this.pageViewTracker,
|
||||
this.onLogout,
|
||||
});
|
||||
@@ -47,6 +51,9 @@ class MainShellPage extends StatefulWidget {
|
||||
/// 社区状态(T3-12 数据层;首页 Feed segment 数据源,T3-14 接线)。
|
||||
final CommunityController communityController;
|
||||
|
||||
/// 本人资料与社区数字(T3.5-08);资料 Tab 与首页问候语共用。
|
||||
final ProfileController profileController;
|
||||
|
||||
/// 当前登录用户 id(详情页评论删除入口 / 关注钮自见性的 UI 判定)。
|
||||
final String? currentUserId;
|
||||
|
||||
@@ -68,6 +75,9 @@ class MainShellPage extends StatefulWidget {
|
||||
/// 发布页 [MediaUploader] 构造口(桌面实测 / 测试替换选图与压缩层)。
|
||||
final MediaUploaderFactory? mediaUploaderFactory;
|
||||
|
||||
/// 头像上传构造口(T3.5-08/09:资料编辑页与宠物详情页)。
|
||||
final AvatarUploaderBuilder? avatarUploaderBuilder;
|
||||
|
||||
/// Tab 曝光补点(IndexedStack 切换不产生路由事件,03 号评估 §3.2)。
|
||||
final PageViewTracker? pageViewTracker;
|
||||
|
||||
@@ -167,6 +177,7 @@ class _MainShellPageState extends State<MainShellPage> {
|
||||
HomePage(
|
||||
appState: widget.appState,
|
||||
communityController: widget.communityController,
|
||||
profileController: widget.profileController,
|
||||
feedAnalytics: widget.feedAnalytics,
|
||||
isActive: currentIndex == 0,
|
||||
onOpenServices: openServices,
|
||||
@@ -182,12 +193,18 @@ class _MainShellPageState extends State<MainShellPage> {
|
||||
controller: widget.petsController,
|
||||
analytics: widget.petAnalytics,
|
||||
healthAnalytics: widget.healthRecordAnalytics,
|
||||
avatarUploaderBuilder: widget.avatarUploaderBuilder,
|
||||
),
|
||||
ServicesPage(
|
||||
showPersonal: showPersonalServices,
|
||||
locationWeather: widget.appState.locationWeather,
|
||||
),
|
||||
ProfilePage(appState: widget.appState, onLogout: widget.onLogout),
|
||||
ProfilePage(
|
||||
appState: widget.appState,
|
||||
controller: widget.profileController,
|
||||
avatarUploaderBuilder: widget.avatarUploaderBuilder,
|
||||
onLogout: widget.onLogout,
|
||||
),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
|
||||
Reference in New Issue
Block a user