diff --git a/.hermes/shared-memory/decision-log.md b/.hermes/shared-memory/decision-log.md
index c4a20efe..070fd6ca 100644
--- a/.hermes/shared-memory/decision-log.md
+++ b/.hermes/shared-memory/decision-log.md
@@ -16,6 +16,22 @@
---
+## 2026-05-26 平台跨流程错误统一用可复制来源弹窗展示
+
+- 背景:拼图等生成链路可能同时存在多个草稿或游玩实例,页面内裸错误 banner 容易让用户误以为当前正在看的拼图失败,也不方便复制完整错误给开发排查。
+- 决策:平台入口、生成页、结果页、作品详情、作品架和运行态的跨流程错误统一收口到 `PlatformErrorDialog`;弹窗必须带错误来源,例如某个草稿、生成会话、作品详情或游玩实例,并提供复制按钮复制来源与错误内容。页面内旧的裸错误 banner、创作入口 modal 错误、生成页错误徽标等不再重复展示;表单校验和发布确认弹窗里的局部业务错误仍可保留在原弹窗内。
+- 影响范围:`src/components/platform-entry/PlatformEntryFlowShellImpl.tsx`、`src/components/platform-entry/PlatformErrorDialog.tsx`、`src/components/CustomWorldGenerationView.tsx`、`src/components/custom-world-home/CustomWorldCreationHub.tsx`、`src/components/custom-world-home/CustomWorldCreationStartCard.tsx`、`src/components/platform-entry/PlatformWorkDetailView.tsx`、`src/components/platform-entry/PlatformEntryCreationTypeModal.tsx`、`src/components/puzzle-result/PuzzleResultView.tsx`。
+- 验证方式:`npm run test -- src/components/platform-entry/PlatformErrorDialog.test.tsx src/components/platform-entry/PlatformEntryCreationTypeModal.test.tsx`、`npm run typecheck`、`npm run check:encoding` 通过;手测时异步失败应弹出包含“错误来源”和“错误内容”的弹窗,复制按钮应复制完整诊断文本。
+- 关联文档:`docs/【玩法创作】平台入口与玩法链路-2026-05-15.md`。
+
+## 2026-05-26 “我的”页任务卡读后端任务摘要并移除常驻填邀请码入口
+
+- 背景:移动端“我的”页每日任务卡曾硬编码 `0 / 1`,任务领取完成后只刷新弹窗内任务中心,卡片本身不更新;页面底部还保留旧的“填邀请码”次级按钮,和当前五项常用功能宫格口径重复。
+- 决策:`RpgEntryHomeView` 的每日任务卡以 `/api/profile/tasks` 返回的任务中心为事实源,展示当前可操作任务的奖励、进度和状态;领取成功后同步使用 claim 响应里的 `center` 刷新卡片。移动端“我的”页不再渲染常驻“填邀请码”次级入口,邀请码填写仅保留邀请链接 query 自动打开弹窗和其它明确引导。
+- 影响范围:`src/components/rpg-entry/RpgEntryHomeView.tsx`、`src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx`、`docs/【项目基线】当前产品与工程约束-2026-05-15.md`。
+- 验证方式:`npm run test -- src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx` 应断言任务卡显示 `1 / 1`、领取后显示已完成,且新用户账号也没有 `次级入口` / `填邀请码` 常驻按钮;`npm run typecheck`、`npm run check:encoding` 通过。
+- 关联文档:`docs/【项目基线】当前产品与工程约束-2026-05-15.md`。
+
## 2026-05-25 平台首页推荐按桌面与移动断点分流
- 背景:平台首页的推荐页在桌面与移动端之间原先共用同一套推荐运行态逻辑,容易让桌面和移动两套内容同时启动,也让首页的推荐卡与桌面发现壳互相抢状态。
diff --git a/.hermes/shared-memory/pitfalls.md b/.hermes/shared-memory/pitfalls.md
index c9f1c0d1..f086ebc2 100644
--- a/.hermes/shared-memory/pitfalls.md
+++ b/.hermes/shared-memory/pitfalls.md
@@ -15,6 +15,30 @@
- 关联:相关文件、文档、提交或 Issue
```
+## 平台异步错误必须带来源弹窗,不要只显示裸错误
+
+- 现象:用户先后触发多个拼图或草稿生成时,旧请求失败后会在当前页面显示“图片生成失败”等裸错误,容易误判为当前正在看的拼图失败;错误文本也不便复制给开发排查。
+- 原因:不同入口、生成页、结果页、作品详情和运行态各自渲染局部错误,没有统一携带草稿、生成会话、作品或游玩来源。
+- 处理:跨流程错误统一由 `PlatformEntryFlowShellImpl` 汇总为 `PlatformErrorDialog`,来源使用玩法、草稿 / session / work / run 标识组成;弹窗提供复制按钮。关闭弹窗时只清理可安全清理的错误状态;恢复类错误用 dismiss key 防止反复弹出但不擅自改底层状态。
+- 验证:触发任一平台级异步失败时,页面应出现包含“错误来源”和“错误内容”的弹窗;复制内容应包含来源和错误正文;旧页面内错误 banner 不再重复出现。
+- 关联:`src/components/platform-entry/PlatformEntryFlowShellImpl.tsx`、`src/components/platform-entry/PlatformErrorDialog.tsx`、`docs/【玩法创作】平台入口与玩法链路-2026-05-15.md`。
+
+## “我的”页每日任务卡不要硬编码进度
+
+- 现象:用户完成或领取每日任务后,任务中心弹窗里的任务状态已经变化,但“我的”页卡片仍显示 `0 / 1` 和“去完成”。
+- 原因:卡片首版只写了静态展示文案,没有读取 `/api/profile/tasks` 返回的 `ProfileTaskCenterResponse`,领取接口返回的新 `center` 也只用于弹窗。
+- 处理:进入“我的”页时读取任务中心,卡片用当前可操作任务或已领取任务派生奖励、进度条和操作状态;`claimRpgProfileTaskReward(...)` 成功后用响应里的 `center` 覆盖本地任务中心。
+- 验证:`npm run test -- src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx` 应覆盖卡片从后端任务摘要显示 `1 / 1`,领取后显示已完成。
+- 关联:`src/components/rpg-entry/RpgEntryHomeView.tsx`、`src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx`、`docs/【项目基线】当前产品与工程约束-2026-05-15.md`。
+
+## “我的”页不要恢复旧的填邀请码次级按钮
+
+- 现象:移动端“我的”页在五项常用功能和设置入口下方又出现一个“填邀请码”按钮,看起来像旧入口残留。
+- 原因:邀请码流程迁移后仍按新用户窗口保留 `canShowReferralRedeemShortcut` 次级入口;但当前页面口径已经固定为五项常用功能宫格,邀请码填写应由邀请链接 query 或明确引导打开弹窗。
+- 处理:移除常驻 `次级入口` / `填邀请码` 渲染,不删除 `ProfileReferralModal` 的 `redeem` 面板,也不破坏 `?inviteCode=` / `?invite_code=` 自动打开填写弹窗。
+- 验证:新用户账号打开“我的”页时没有 `次级入口` 和 `填邀请码` 按钮;带 `?inviteCode=spring-2026` 的登录用户仍自动打开邀请码弹窗并预填 `SPRING2026`。
+- 关联:`src/components/rpg-entry/RpgEntryHomeView.tsx`、`.hermes/skills/genarrative-profile-invite-flow/SKILL.md`。
+
## 创作卡片点击要直达已有入口表单,别再保留空白入口页
- 现象:创作 Tab 模板卡点击后如果仍然停留在创作大厅,或者先进入“X 创作入口”这种空白页,就会让用户多走一层,还可能被错误的 stage 白名单拉回平台。
diff --git a/docs/【玩法创作】平台入口与玩法链路-2026-05-15.md b/docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
index 0e593209..600e0327 100644
--- a/docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
+++ b/docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
@@ -12,6 +12,8 @@
创作表单提交前的泥点余额前置校验只允许用独立弹窗提示失败原因,不得把用户退回创作入口或玩法模板列表,也不得清空当前表单状态。当前适用拼图、抓大鹅和汪汪声浪等会在前端提交前校验泥点的生成入口;余额不足、余额读取失败都应停留在当前工作台,由用户关闭提示后继续编辑或自行补足泥点。
+平台入口、生成页、结果页、作品详情、作品架和运行态的跨流程错误统一收口到 `PlatformErrorDialog`。弹窗必须带明确错误来源,例如某个草稿、某次生成、作品详情或某个游玩实例,并提供复制按钮复制“错误来源 + 错误内容”。页面内不再重复渲染裸错误 banner;表单校验、发布确认弹窗里的局部业务错误可以保留在原弹窗内。
+
`PlatformEntryFlowShellImpl.tsx` 仍是平台入口编排壳,后续维护时应优先把独立 UI 片段、公开作品映射、草稿生成 notice 和运行态状态 helper 拆到 `src/components/platform-entry/PlatformEntryFlowShellImpl/` 或同目录紧邻 helper 文件。拆分只允许改变文件组织,不改变入口配置事实源、默认导出、props、页面阶段、UI 文案或现有交互;其中拼图首访 onboarding 已拆为 `PlatformEntryFlowShellImpl/PuzzleOnboardingView.tsx`。
`platformEntryCreationTypes.ts` 只做前端展示派生,分组时必须把后端 `creationTypes` 里的 `categoryId` / `categoryLabel` 当作可缺失字段处理,空值统一回退到 `recent` / `最近创作`,避免旧数据、局部 mock 或异常返回把创作入口初始化直接打崩。
@@ -44,7 +46,7 @@
6. 点击 `generationStatus=generating` 的草稿卡必须恢复对应玩法的生成进度页,不能进入空白结果页或普通工作区;恢复生成页的 `startedAtMs` 使用进入生成页的当前时间,作品摘要 `updatedAt` 只用于排序和摘要展示,不参与假进度起算。
7. 私有 generated 图片必须通过 `ResolvedAssetImage` / `/api/assets/read-url` 换签读取。
-发现 Tab、创作 Tab 与草稿 Tab 的页面根内容区不再套 `platform-page-stage` 外层全局卡片壳,让列表、筛选和玩法卡获得更宽的横向空间;推荐页和我的页仍按各自页面设计保留原有全局卡片口径。移动端“我的”页仍按顶部头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口、次级入口带和法律信息组织,但字号必须维持平台普通 UI 档位,不能因为窄屏把卡片标题、功能 label 或法律信息撑成展示级字号;最后一屏内容必须能在底部 dock 上方完整滚动露出,不得被固定底部导航遮挡。
+发现 Tab、创作 Tab 与草稿 Tab 的页面根内容区不再套 `platform-page-stage` 外层全局卡片壳,让列表、筛选和玩法卡获得更宽的横向空间;推荐页和我的页仍按各自页面设计保留原有全局卡片口径。移动端“我的”页仍按顶部头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口和法律信息组织,不保留旧的底部“填邀请码”次级入口;每日任务卡必须读取 `/api/profile/tasks` 的当前任务摘要并在领取后同步刷新卡片进度。字号必须维持平台普通 UI 档位,不能因为窄屏把卡片标题、功能 label 或法律信息撑成展示级字号;最后一屏内容必须能在底部 dock 上方完整滚动露出,不得被固定底部导航遮挡。
## RPG / 自定义世界
@@ -72,7 +74,7 @@ RPG 从作品架、广场详情或作品号搜索点击“启动”前,入口
RPG 运行态的战斗终局、继续冒险、继续探索和切场景都属于服务端 runtime 快照真相:`module-runtime-story` 必须在终局战斗 action 后调用 post-battle finalization,持久写入 `story_continue_adventure`、`deferredOptions`、`deferredRuntimeState.storyEngineMemory.currentSceneActState` 和清理后的战斗状态;`idle_travel_next_scene` / `camp_travel_home_scene` 必须由后端写入新的 `currentScenePreset`、`currentSceneActState`、`currentEncounter` 和 `runtimeStats.scenesTraveled`。前端只播放退场、进场和继续按钮表现,不能用默认 `观察/试探/调息` fallback 或本地动画假装推进剧情。旧 bootstrap 快照可能只有 `connectedSceneIds` / `forwardSceneId` 而没有 `connections`,后端生成战后旅行选项时必须兼容这些字段。
-RPG / 拼图等运行态存档仍以 `/api/profile/save-archives` 的后端列表为真相,恢复动作继续走对应恢复接口,但移动端“我的”页已经不再提供独立的 `次级入口 > 存档` 和设置入口存档按钮;“玩过”弹窗可以继续合并展示可继续存档,个人中心只保留设置、扫码、常用功能和条件性次级入口。移动端“我的”页的五项常用功能宫格只放泥点充值、邀请好友、兑换码、玩家社区、反馈与建议,避免把存档挤入主宫格破坏参考图布局。前端只展示 `/api/profile/save-archives` 返回的列表并在用户选择后调用对应恢复接口,不能本地拼装或筛选正式存档真相。
+RPG / 拼图等运行态存档仍以 `/api/profile/save-archives` 的后端列表为真相,恢复动作继续走对应恢复接口,但移动端“我的”页已经不再提供独立的 `次级入口 > 存档` 和设置入口存档按钮;“玩过”弹窗可以继续合并展示可继续存档,个人中心只保留设置、扫码和五项常用功能。移动端“我的”页的五项常用功能宫格只放泥点充值、邀请好友、兑换码、玩家社区、反馈与建议,避免把存档或填邀请码挤入主宫格破坏参考图布局。前端只展示 `/api/profile/save-archives` 返回的列表并在用户选择后调用对应恢复接口,不能本地拼装或筛选正式存档真相。
## 拼图
diff --git a/docs/【项目基线】当前产品与工程约束-2026-05-15.md b/docs/【项目基线】当前产品与工程约束-2026-05-15.md
index 0007216b..2544e47d 100644
--- a/docs/【项目基线】当前产品与工程约束-2026-05-15.md
+++ b/docs/【项目基线】当前产品与工程约束-2026-05-15.md
@@ -93,11 +93,12 @@ server-rs + Axum + SpacetimeDB
7. 主站入口已锁定移动端页面级缩放;单个游戏页面不要再重复实现整页缩放锁定。
8. 图像输入通用 UI 统一走 `src/components/common/CreativeImageInputPanel.tsx`。外层页面持有业务状态,组件只承担上传卡、预览、参考图缩略图、AI 重绘开关、错误展示和提交按钮。
9. 发现页 `分类` 子频道的筛选必须打开独立 dialog / drawer / modal,至少支持玩法类型过滤与排序切换;筛选结果为空时显示空状态,不把筛选内容展开在当前列表下方。
-10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口、可选次级入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;页面不再提供独立存档按钮入口,填邀请码仅在新用户可填写窗口内展示为次级入口。
-11. “我的”页泥点、游戏时长、已玩游戏数量三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、会员卡、每日任务、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
-12. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、每日任务、五项常用功能、可选次级入口和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
-13. RPG 等运行态的战斗飘字、血量变化和即时反馈必须在暗色、噪声高的场景背景上保持可读:使用高亮文字、深色描边、强阴影或小面积半透明底,不只依赖红/绿文字本身表达伤害或治疗。
-14. 平台亮色 UI 配色以陶泥儿主视觉为准:暖白 / 米杏底、陶土橙主按钮、深棕正文与浅杏边框;新增界面优先复用 `src/index.css` 的 `--platform-*` 主题变量和 `apps/admin-web/src/styles/admin.css` 的同系色值,不再引入粉红、蓝绿等独立主色方案。
+10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;页面不再提供独立存档按钮入口,也不在底部保留旧的填邀请码次级入口。填邀请码只由邀请链接 query 或其它明确引导打开独立弹窗,不作为“我的”页常驻按钮。
+11. “我的”页每日任务卡必须展示后端 `/api/profile/tasks` 返回的当前任务摘要,包括奖励泥点数、进度和领取 / 去完成 / 已完成状态;任务领取成功后,卡片摘要必须跟随返回的任务中心数据同步刷新,不能继续硬编码 `0 / 1` 或只更新弹窗内任务列表。
+12. “我的”页泥点、游戏时长、已玩游戏数量三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、会员卡、每日任务、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
+13. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、每日任务、五项常用功能和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
+14. RPG 等运行态的战斗飘字、血量变化和即时反馈必须在暗色、噪声高的场景背景上保持可读:使用高亮文字、深色描边、强阴影或小面积半透明底,不只依赖红/绿文字本身表达伤害或治疗。
+15. 平台亮色 UI 配色以陶泥儿主视觉为准:暖白 / 米杏底、陶土橙主按钮、深棕正文与浅杏边框;新增界面优先复用 `src/index.css` 的 `--platform-*` 主题变量和 `apps/admin-web/src/styles/admin.css` 的同系色值,不再引入粉红、蓝绿等独立主色方案。
## 文案与编码
diff --git a/src/components/CustomWorldGenerationView.tsx b/src/components/CustomWorldGenerationView.tsx
index 9a00c842..55efe604 100644
--- a/src/components/CustomWorldGenerationView.tsx
+++ b/src/components/CustomWorldGenerationView.tsx
@@ -13,7 +13,7 @@ interface CustomWorldGenerationViewProps {
anchorEntries?: CustomWorldStructuredAnchorEntry[];
progress: CustomWorldGenerationProgress | null;
isGenerating: boolean;
- error: string | null;
+ error?: string | null;
onBack: () => void;
onEditSetting: () => void;
onRetry: () => void;
@@ -110,7 +110,6 @@ export function CustomWorldGenerationView({
anchorEntries = [],
progress,
isGenerating,
- error,
onBack,
onEditSetting,
onRetry,
@@ -123,7 +122,6 @@ export function CustomWorldGenerationView({
settingDescription = '这段文本会直接驱动本轮世界框架、角色与场景生成。',
progressTitle = '生成进度',
activeBadgeLabel = '世界建设中',
- pausedBadgeLabel = '生成已暂停',
idleBadgeLabel = '等待操作',
structuredEmptyText = '正在整理当前设定结构,请稍后。',
hideBatchModule = false,
@@ -169,11 +167,7 @@ export function CustomWorldGenerationView({
{backLabel}
- {isGenerating
- ? activeBadgeLabel
- : error
- ? pausedBadgeLabel
- : idleBadgeLabel}
+ {isGenerating ? activeBadgeLabel : idleBadgeLabel}
@@ -195,12 +189,6 @@ export function CustomWorldGenerationView({
/>
- {error ? (
-
- {error}
-
- ) : null}
-
{!isGenerating ? (
<>
diff --git a/src/components/custom-world-home/CustomWorldCreationHub.tsx b/src/components/custom-world-home/CustomWorldCreationHub.tsx
index ccd20cd5..12520cf8 100644
--- a/src/components/custom-world-home/CustomWorldCreationHub.tsx
+++ b/src/components/custom-world-home/CustomWorldCreationHub.tsx
@@ -1,12 +1,12 @@
import { useEffect, useMemo, useState } from 'react';
-import type { BigFishWorkSummary } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
import type { BarkBattleWorkSummary } from '../../../packages/shared/src/contracts/barkBattle';
+import type { BigFishWorkSummary } from '../../../packages/shared/src/contracts/bigFishWorkSummary';
import type { CustomWorldWorkSummary } from '../../../packages/shared/src/contracts/customWorldAgent';
import type { BabyObjectMatchDraft } from '../../../packages/shared/src/contracts/edutainmentBabyObject';
+import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
import type { Match3DWorkSummary } from '../../../packages/shared/src/contracts/match3dWorks';
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
-import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
import type { CustomWorldLibraryEntry } from '../../../packages/shared/src/contracts/runtime';
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
import type { VisualNovelWorkSummary } from '../../../packages/shared/src/contracts/visualNovel';
@@ -43,7 +43,6 @@ type CustomWorldCreationHubProps = {
loading: boolean;
error: string | null;
onRetry: () => void;
- createError?: string | null;
createBusy?: boolean;
entryConfig: CreationEntryConfig;
creationTypes: readonly PlatformCreationTypeCard[];
@@ -154,7 +153,6 @@ export function CustomWorldCreationHub({
loading,
error,
onRetry,
- createError = null,
createBusy = false,
entryConfig,
creationTypes,
@@ -360,7 +358,6 @@ export function CustomWorldCreationHub({
{showStartCard ? (
- {error}
+
diff --git a/src/components/custom-world-home/CustomWorldCreationStartCard.tsx b/src/components/custom-world-home/CustomWorldCreationStartCard.tsx
index c5021674..6647e42c 100644
--- a/src/components/custom-world-home/CustomWorldCreationStartCard.tsx
+++ b/src/components/custom-world-home/CustomWorldCreationStartCard.tsx
@@ -1,5 +1,5 @@
import { Coins, Trophy } from 'lucide-react';
-import { useMemo, useState, type UIEvent } from 'react';
+import { type UIEvent,useMemo, useState } from 'react';
import type { CreationEntryConfig } from '../../services/creationEntryConfigService';
import {
@@ -10,7 +10,6 @@ import {
type CustomWorldCreationStartCardProps = {
busy?: boolean;
- error?: string | null;
entryConfig: CreationEntryConfig;
creationTypes: readonly PlatformCreationTypeCard[];
onCreateType: (type: PlatformCreationTypeId) => void;
@@ -25,7 +24,6 @@ function shouldShowCreationBadge(badge: string) {
export function CustomWorldCreationStartCard({
busy = false,
- error = null,
entryConfig,
creationTypes,
onCreateType,
@@ -233,11 +231,6 @@ export function CustomWorldCreationStartCard({
})}
- {error ? (
-
- {error}
-
- ) : null}
);
diff --git a/src/components/platform-entry/PlatformEntryCreationTypeModal.test.tsx b/src/components/platform-entry/PlatformEntryCreationTypeModal.test.tsx
index 583c19ad..fdfe2575 100644
--- a/src/components/platform-entry/PlatformEntryCreationTypeModal.test.tsx
+++ b/src/components/platform-entry/PlatformEntryCreationTypeModal.test.tsx
@@ -51,7 +51,6 @@ test('dispatches wooden fish creation type selection', () => {
{}}
diff --git a/src/components/platform-entry/PlatformEntryCreationTypeModal.tsx b/src/components/platform-entry/PlatformEntryCreationTypeModal.tsx
index 8d6698aa..21b297b9 100644
--- a/src/components/platform-entry/PlatformEntryCreationTypeModal.tsx
+++ b/src/components/platform-entry/PlatformEntryCreationTypeModal.tsx
@@ -10,7 +10,6 @@ import {
export interface PlatformEntryCreationTypeModalProps {
isOpen: boolean;
isBusy: boolean;
- error: string | null;
entryConfig: CreationEntryConfig;
creationTypes: readonly PlatformCreationTypeCard[];
onClose: () => void;
@@ -94,7 +93,6 @@ function CreationTypeCard(props: {
export function PlatformEntryCreationTypeModal({
isOpen,
isBusy,
- error,
entryConfig,
creationTypes,
onClose,
@@ -172,11 +170,6 @@ export function PlatformEntryCreationTypeModal({
))}
- {error ? (
-
- {error}
-
- ) : null}
);
}
diff --git a/src/components/platform-entry/PlatformEntryFlowShellImpl.tsx b/src/components/platform-entry/PlatformEntryFlowShellImpl.tsx
index c6359f6b..a74239f8 100644
--- a/src/components/platform-entry/PlatformEntryFlowShellImpl.tsx
+++ b/src/components/platform-entry/PlatformEntryFlowShellImpl.tsx
@@ -38,6 +38,7 @@ import type {
BabyObjectMatchDraft,
CreateBabyObjectMatchDraftRequest,
} from '../../../packages/shared/src/contracts/edutainmentBabyObject';
+import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
import type {
CreateMatch3DSessionRequest,
ExecuteMatch3DActionRequest,
@@ -154,13 +155,6 @@ import {
type CreationEntryConfig,
fetchCreationEntryConfig,
} from '../../services/creationEntryConfigService';
-import {
- cancelCreativeAgentSession,
- confirmCreativePuzzleTemplate,
- createCreativeAgentSession,
- streamCreativeAgentMessage,
- streamCreativeDraftEdit,
-} from '../../services/creative-agent';
import {
clearCreationUrlState,
type CreationUrlState,
@@ -169,11 +163,12 @@ import {
writeCreationUrlState,
} from '../../services/creationUrlState';
import {
- clearPuzzleRuntimeUrlState,
- readPuzzleRuntimeUrlState,
- writePuzzleRuntimeUrlState,
- type PuzzleRuntimeUrlState,
-} from '../../services/puzzleRuntimeUrlState';
+ cancelCreativeAgentSession,
+ confirmCreativePuzzleTemplate,
+ createCreativeAgentSession,
+ streamCreativeAgentMessage,
+ streamCreativeDraftEdit,
+} from '../../services/creative-agent';
import {
readCustomWorldAgentUiState,
shouldRestoreCustomWorldAgentUiState,
@@ -196,7 +191,6 @@ import {
JumpHopWorkProfileResponse,
JumpHopWorkspaceCreateRequest,
} from '../../services/jump-hop/jumpHopClient';
-import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
import { match3dCreationClient } from '../../services/match3d-creation';
import { createServerMatch3DRuntimeAdapter } from '../../services/match3d-runtime';
import {
@@ -287,6 +281,12 @@ import {
listPuzzleWorks,
updatePuzzleWork,
} from '../../services/puzzle-works';
+import {
+ clearPuzzleRuntimeUrlState,
+ type PuzzleRuntimeUrlState,
+ readPuzzleRuntimeUrlState,
+ writePuzzleRuntimeUrlState,
+} from '../../services/puzzleRuntimeUrlState';
import { deleteRpgCreationAgentSession } from '../../services/rpg-creation';
import { rpgCreationPreviewAdapter } from '../../services/rpg-creation/rpgCreationPreviewAdapter';
import {
@@ -375,6 +375,7 @@ import {
mapVisualNovelWorkToPlatformGalleryCard,
mapWoodenFishWorkToPlatformGalleryCard,
type PlatformPublicGalleryCard,
+ resolvePlatformPublicWorkCode,
} from '../rpg-entry/rpgEntryWorldPresentation';
import { useRpgCreationAgentOperationPolling } from '../rpg-entry/useRpgCreationAgentOperationPolling';
import { useRpgCreationEnterWorld } from '../rpg-entry/useRpgCreationEnterWorld';
@@ -414,6 +415,7 @@ import {
PlatformEntryHomeView,
type PlatformHomeTab,
} from './PlatformEntryHomeView';
+import { usePlatformDesktopLayout } from './platformEntryResponsive';
import {
buildCreationHubFallbackItems,
resolveRpgCreationErrorMessage,
@@ -423,11 +425,14 @@ import type {
SelectionStage,
} from './platformEntryTypes';
import { PlatformEntryWorldDetailView } from './PlatformEntryWorldDetailView';
+import {
+ PlatformErrorDialog,
+ type PlatformErrorDialogPayload,
+} from './PlatformErrorDialog';
import { PlatformFeedbackView } from './PlatformFeedbackView';
import { PlatformWorkDetailView } from './PlatformWorkDetailView';
import { usePlatformCreationAgentFlowController } from './usePlatformCreationAgentFlowController';
import { usePlatformEntryBootstrap } from './usePlatformEntryBootstrap';
-import { usePlatformDesktopLayout } from './platformEntryResponsive';
import { usePlatformEntryLibraryDetail } from './usePlatformEntryLibraryDetail';
import { usePlatformEntryNavigation } from './usePlatformEntryNavigation';
@@ -2012,6 +2017,22 @@ function createPendingDraftShelfState(
};
}
+function normalizePlatformErrorMessage(message: string | null | undefined) {
+ const normalized = message?.trim();
+ return normalized ? normalized : null;
+}
+
+function formatPlatformErrorSource(label: string, id?: string | null) {
+ const normalizedId = id?.trim();
+ return normalizedId ? `${label} ${normalizedId}` : label;
+}
+
+function buildPlatformErrorDialogDismissKey(
+ error: (PlatformErrorDialogPayload & { key: string }) | null,
+) {
+ return error ? `${error.key}:${error.source}:${error.message}` : null;
+}
+
function createMiniGameDraftGenerationStateForRestoredDraft(
kind: MiniGameDraftGenerationKind,
metadata?: MiniGameDraftGenerationState['metadata'],
@@ -5767,6 +5788,336 @@ export function PlatformEntryFlowShellImpl({
isMiniGameDraftGenerating(
activePuzzleBackgroundCompileTask?.generationState ?? null,
);
+ const [dismissedPlatformErrorDialogKey, setDismissedPlatformErrorDialogKey] =
+ useState(null);
+ const currentPlatformErrorDialog = useMemo<
+ (PlatformErrorDialogPayload & { key: string }) | null
+ >(() => {
+ const candidates: Array<{
+ key: string;
+ source: string;
+ message: string | null | undefined;
+ }> = [
+ {
+ key: 'creation-entry-config',
+ source: '创作入口配置',
+ message: creationEntryConfigError,
+ },
+ {
+ key: 'platform-bootstrap',
+ source: '平台首页',
+ message: platformBootstrap.platformError,
+ },
+ {
+ key: 'rpg-creation-type',
+ source: '创作入口',
+ message: sessionController.creationTypeError,
+ },
+ {
+ key: 'rpg-restore',
+ source: '创作作品架',
+ message: sessionController.agentWorkspaceRestoreError,
+ },
+ {
+ key: 'rpg-result',
+ source: formatPlatformErrorSource(
+ 'RPG 草稿',
+ sessionController.agentSession?.sessionId ??
+ sessionController.generatedCustomWorldProfile?.id,
+ ),
+ message: resultViewError,
+ },
+ {
+ key: 'public-work-detail',
+ source: formatPlatformErrorSource(
+ '作品详情',
+ selectedPublicWorkDetail
+ ? resolvePlatformPublicWorkCode(selectedPublicWorkDetail)
+ : selectedDetailEntry?.profileId,
+ ),
+ message: publicWorkDetailError ?? detailNavigation.detailError,
+ },
+ {
+ key: 'big-fish',
+ source: formatPlatformErrorSource(
+ selectionStage === 'big-fish-runtime' ? '大鱼吃小鱼游玩' : '大鱼草稿',
+ bigFishRun?.runId ?? bigFishSession?.sessionId,
+ ),
+ message: bigFishError,
+ },
+ {
+ key: 'match3d',
+ source: formatPlatformErrorSource(
+ selectionStage === 'match3d-runtime' ? '抓大鹅游玩' : '抓大鹅草稿',
+ match3dRun?.runId ??
+ match3dGenerationViewSession?.sessionId ??
+ match3dSession?.sessionId,
+ ),
+ message: match3dGenerationViewError ?? match3dError,
+ },
+ {
+ key: 'square-hole',
+ source: formatPlatformErrorSource(
+ selectionStage === 'square-hole-runtime'
+ ? '方洞挑战游玩'
+ : '方洞挑战草稿',
+ squareHoleRun?.runId ?? squareHoleSession?.sessionId,
+ ),
+ message: squareHoleError,
+ },
+ {
+ key: 'jump-hop',
+ source: formatPlatformErrorSource(
+ selectionStage === 'jump-hop-runtime' ? '跳一跳游玩' : '跳一跳草稿',
+ jumpHopRun?.runId ?? jumpHopSession?.sessionId,
+ ),
+ message: jumpHopError,
+ },
+ {
+ key: 'wooden-fish',
+ source: formatPlatformErrorSource(
+ selectionStage === 'wooden-fish-runtime'
+ ? '敲木鱼游玩'
+ : '敲木鱼草稿',
+ woodenFishRun?.runId ?? woodenFishSession?.sessionId,
+ ),
+ message: woodenFishError,
+ },
+ {
+ key: 'puzzle',
+ source: formatPlatformErrorSource(
+ selectionStage === 'puzzle-runtime' ? '拼图游玩' : '拼图草稿',
+ puzzleRun?.runId ??
+ puzzleGenerationViewSession?.sessionId ??
+ puzzleSession?.sessionId,
+ ),
+ message: puzzleGenerationViewError ?? puzzleCreationError ?? puzzleError,
+ },
+ {
+ key: 'puzzle-onboarding',
+ source: '拼图首次创作',
+ message: puzzleOnboardingError,
+ },
+ {
+ key: 'puzzle-shelf',
+ source: '拼图作品架',
+ message: puzzleShelfError,
+ },
+ {
+ key: 'visual-novel',
+ source: formatPlatformErrorSource(
+ selectionStage === 'visual-novel-runtime'
+ ? '视觉小说游玩'
+ : '视觉小说草稿',
+ visualNovelRun?.runId ?? visualNovelSession?.sessionId,
+ ),
+ message: visualNovelError,
+ },
+ {
+ key: 'baby-object-match',
+ source: formatPlatformErrorSource(
+ selectionStage === 'baby-object-match-runtime'
+ ? '宝贝识物游玩'
+ : '宝贝识物草稿',
+ babyObjectMatchDraft?.profileId,
+ ),
+ message: babyObjectMatchError,
+ },
+ {
+ key: 'bark-battle',
+ source: formatPlatformErrorSource(
+ selectionStage === 'bark-battle-runtime'
+ ? '汪汪声浪游玩'
+ : '汪汪声浪草稿',
+ barkBattlePublishedConfig?.workId ?? barkBattleDraftConfig?.workId,
+ ),
+ message: barkBattleError,
+ },
+ {
+ key: 'creative-agent',
+ source: formatPlatformErrorSource(
+ '智能创作 Agent',
+ creativeAgentSession?.sessionId,
+ ),
+ message: creativeAgentError,
+ },
+ {
+ key: 'rpg-generation',
+ source: formatPlatformErrorSource(
+ 'RPG 草稿生成',
+ sessionController.agentSession?.sessionId,
+ ),
+ message: sessionController.activeGenerationError,
+ },
+ ];
+
+ for (const candidate of candidates) {
+ const message = normalizePlatformErrorMessage(candidate.message);
+ if (message) {
+ return {
+ key: candidate.key,
+ source: candidate.source,
+ message,
+ };
+ }
+ }
+
+ return null;
+ }, [
+ babyObjectMatchDraft?.profileId,
+ babyObjectMatchError,
+ barkBattleDraftConfig?.workId,
+ barkBattleError,
+ barkBattlePublishedConfig?.workId,
+ bigFishError,
+ bigFishRun?.runId,
+ bigFishSession?.sessionId,
+ creationEntryConfigError,
+ creativeAgentError,
+ creativeAgentSession?.sessionId,
+ detailNavigation.detailError,
+ jumpHopError,
+ jumpHopRun?.runId,
+ jumpHopSession?.sessionId,
+ match3dError,
+ match3dGenerationViewError,
+ match3dGenerationViewSession?.sessionId,
+ match3dRun?.runId,
+ match3dSession?.sessionId,
+ platformBootstrap.platformError,
+ publicWorkDetailError,
+ puzzleCreationError,
+ puzzleError,
+ puzzleGenerationViewError,
+ puzzleGenerationViewSession?.sessionId,
+ puzzleOnboardingError,
+ puzzleRun?.runId,
+ puzzleSession?.sessionId,
+ puzzleShelfError,
+ resultViewError,
+ selectedDetailEntry?.profileId,
+ selectedPublicWorkDetail,
+ selectionStage,
+ sessionController.activeGenerationError,
+ sessionController.agentSession?.sessionId,
+ sessionController.agentWorkspaceRestoreError,
+ sessionController.creationTypeError,
+ sessionController.generatedCustomWorldProfile?.id,
+ squareHoleError,
+ squareHoleRun?.runId,
+ squareHoleSession?.sessionId,
+ visualNovelError,
+ visualNovelRun?.runId,
+ visualNovelSession?.sessionId,
+ woodenFishError,
+ woodenFishRun?.runId,
+ woodenFishSession?.sessionId,
+ ]);
+ const activePlatformErrorDialogDismissKey =
+ buildPlatformErrorDialogDismissKey(currentPlatformErrorDialog);
+ const activePlatformErrorDialog =
+ activePlatformErrorDialogDismissKey &&
+ activePlatformErrorDialogDismissKey === dismissedPlatformErrorDialogKey
+ ? null
+ : currentPlatformErrorDialog;
+ const closePlatformErrorDialog = useCallback(() => {
+ if (!currentPlatformErrorDialog) {
+ return;
+ }
+
+ const dismissKey = buildPlatformErrorDialogDismissKey(
+ currentPlatformErrorDialog,
+ );
+ if (dismissKey) {
+ setDismissedPlatformErrorDialogKey(dismissKey);
+ }
+
+ if (currentPlatformErrorDialog.key === 'creation-entry-config') {
+ setCreationEntryConfigError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'platform-bootstrap') {
+ platformBootstrap.setPlatformError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'rpg-creation-type') {
+ sessionController.setCreationTypeError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'rpg-restore') {
+ return;
+ }
+ if (
+ currentPlatformErrorDialog.key === 'rpg-result' ||
+ currentPlatformErrorDialog.key === 'rpg-generation'
+ ) {
+ autosaveCoordinator.setCustomWorldAutoSaveError(null);
+ sessionController.setCustomWorldError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'public-work-detail') {
+ setPublicWorkDetailError(null);
+ detailNavigation.setDetailError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'big-fish') {
+ setBigFishError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'match3d') {
+ setMatch3DError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'square-hole') {
+ setSquareHoleError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'jump-hop') {
+ setJumpHopError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'wooden-fish') {
+ setWoodenFishError(null);
+ return;
+ }
+ if (
+ currentPlatformErrorDialog.key === 'puzzle' ||
+ currentPlatformErrorDialog.key === 'puzzle-onboarding' ||
+ currentPlatformErrorDialog.key === 'puzzle-shelf'
+ ) {
+ setPuzzleCreationError(null);
+ setPuzzleOnboardingError(null);
+ setPuzzleShelfError(null);
+ setPuzzleError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'visual-novel') {
+ setVisualNovelError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'baby-object-match') {
+ setBabyObjectMatchError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'bark-battle') {
+ setBarkBattleError(null);
+ return;
+ }
+ if (currentPlatformErrorDialog.key === 'creative-agent') {
+ setCreativeAgentError(null);
+ }
+ }, [
+ autosaveCoordinator,
+ currentPlatformErrorDialog,
+ detailNavigation,
+ platformBootstrap,
+ sessionController,
+ setBigFishError,
+ setMatch3DError,
+ setPuzzleError,
+ setSquareHoleError,
+ setVisualNovelError,
+ ]);
const shouldPollPuzzleGenerationSession =
selectionStage === 'puzzle-generating' &&
activePuzzleGenerationSessionId != null &&
@@ -14098,19 +14449,6 @@ export function PlatformEntryFlowShellImpl({
void refreshBabyObjectMatchShelf();
void refreshBarkBattleShelf();
}}
- createError={
- creationEntryConfigError ??
- sessionController.creationTypeError ??
- bigFishError ??
- match3dError ??
- (isSquareHoleCreationVisible ? squareHoleError : null) ??
- woodenFishError ??
- puzzleCreationError ??
- puzzleError ??
- (isVisualNovelCreationOpen ? visualNovelError : null) ??
- babyObjectMatchError ??
- barkBattleError
- }
createBusy={
!creationEntryConfig ||
sessionController.isCreatingAgentSession ||
@@ -15762,7 +16100,6 @@ export function PlatformEntryFlowShellImpl({
settingDescription={null}
progressTitle="拼图草稿生成进度"
activeBadgeLabel="草稿生成中"
- pausedBadgeLabel="草稿生成已暂停"
idleBadgeLabel="等待返回工作区"
hideBatchModule
/>
@@ -16420,7 +16757,7 @@ export function PlatformEntryFlowShellImpl({
{creationEntryConfig ? (
- {
@@ -16542,6 +16865,12 @@ export function PlatformEntryFlowShellImpl({
payload={publishSharePayload}
onClose={() => setPublishSharePayload(null)}
/>
+
({
+ copyTextToClipboard: vi.fn(),
+}));
+
+afterEach(() => {
+ vi.clearAllMocks();
+});
+
+describe('PlatformErrorDialog', () => {
+ test('shows source, message, and copies the full error report', async () => {
+ vi.mocked(clipboardService.copyTextToClipboard).mockResolvedValue(true);
+
+ render(
+ {}}
+ />,
+ );
+
+ const dialog = screen.getByRole('dialog', { name: '发生错误' });
+ expect(within(dialog).getByText('拼图草稿 puzzle-session-123')).toBeTruthy();
+ expect(within(dialog).getByText('图片生成失败,请稍后再试。')).toBeTruthy();
+
+ fireEvent.click(within(dialog).getByRole('button', { name: '复制报错' }));
+
+ expect(clipboardService.copyTextToClipboard).toHaveBeenCalledWith(
+ ['来源:拼图草稿 puzzle-session-123', '错误:图片生成失败,请稍后再试。'].join(
+ '\n',
+ ),
+ );
+ await waitFor(() => {
+ expect(
+ within(dialog).getByRole('button', { name: '已复制' }),
+ ).toBeTruthy();
+ });
+ });
+
+ test('does not render when there is no active error', () => {
+ render( {}} />);
+
+ expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
+ });
+});
diff --git a/src/components/platform-entry/PlatformErrorDialog.tsx b/src/components/platform-entry/PlatformErrorDialog.tsx
new file mode 100644
index 00000000..794a6a5c
--- /dev/null
+++ b/src/components/platform-entry/PlatformErrorDialog.tsx
@@ -0,0 +1,120 @@
+import { Check, Copy } from 'lucide-react';
+import { useEffect, useMemo, useRef, useState } from 'react';
+
+import { copyTextToClipboard } from '../../services/clipboard';
+import { UnifiedModal } from '../common/UnifiedModal';
+
+export type PlatformErrorDialogPayload = {
+ source: string;
+ message: string;
+};
+
+type PlatformErrorDialogProps = {
+ error: PlatformErrorDialogPayload | null;
+ onClose: () => void;
+ overlayClassName?: string;
+ panelClassName?: string;
+};
+
+function buildPlatformErrorReport(error: PlatformErrorDialogPayload) {
+ return [`来源:${error.source}`, `错误:${error.message}`].join('\n');
+}
+
+export function PlatformErrorDialog({
+ error,
+ onClose,
+ overlayClassName = 'platform-theme platform-theme--light !items-center',
+ panelClassName = 'platform-remap-surface rounded-[1.5rem]',
+}: PlatformErrorDialogProps) {
+ const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>(
+ 'idle',
+ );
+ const resetTimerRef = useRef(null);
+ const reportText = useMemo(
+ () => (error ? buildPlatformErrorReport(error) : ''),
+ [error],
+ );
+
+ useEffect(
+ () => () => {
+ if (resetTimerRef.current !== null) {
+ window.clearTimeout(resetTimerRef.current);
+ }
+ },
+ [],
+ );
+
+ useEffect(() => {
+ setCopyState('idle');
+ }, [error?.source, error?.message]);
+
+ const copyError = () => {
+ if (!reportText) {
+ return;
+ }
+
+ void copyTextToClipboard(reportText).then((copied) => {
+ setCopyState(copied ? 'copied' : 'failed');
+ if (resetTimerRef.current !== null) {
+ window.clearTimeout(resetTimerRef.current);
+ }
+ resetTimerRef.current = window.setTimeout(() => {
+ resetTimerRef.current = null;
+ setCopyState('idle');
+ }, 1400);
+ });
+ };
+
+ return (
+
+ {copyState === 'copied' ? (
+
+ ) : (
+
+ )}
+ {copyState === 'copied'
+ ? '已复制'
+ : copyState === 'failed'
+ ? '复制失败'
+ : '复制报错'}
+
+ }
+ >
+ {error ? (
+ <>
+
+
+ 来源
+
+
+ {error.source}
+
+
+
+
+ 错误
+
+
+ {error.message}
+
+
+ >
+ ) : null}
+
+ );
+}
diff --git a/src/components/platform-entry/PlatformWorkDetailView.tsx b/src/components/platform-entry/PlatformWorkDetailView.tsx
index 7477d978..65d3c404 100644
--- a/src/components/platform-entry/PlatformWorkDetailView.tsx
+++ b/src/components/platform-entry/PlatformWorkDetailView.tsx
@@ -24,7 +24,6 @@ import {
formatPlatformWorldTime,
isBarkBattleGalleryEntry,
isEdutainmentGalleryEntry,
- isJumpHopGalleryEntry,
type PlatformPublicGalleryCard,
resolvePlatformPublicWorkCode,
resolvePlatformWorldCoverSlides,
@@ -36,7 +35,7 @@ export interface PlatformWorkDetailViewProps {
authorAvatarUrl?: string | null;
authorDisplayName?: string | null;
isBusy: boolean;
- error: string | null;
+ error?: string | null;
visibleCoverCount?: number;
onBack: () => void;
onLike: () => void;
@@ -89,7 +88,6 @@ export function PlatformWorkDetailView({
authorAvatarUrl,
authorDisplayName,
isBusy,
- error,
visibleCoverCount = 1,
onBack,
onLike,
@@ -432,9 +430,6 @@ export function PlatformWorkDetailView({
{shareState === 'copied' ? '分享内容已复制' : '分享失败'}
) : null}
- {error ? (
- {error}
- ) : null}
diff --git a/src/components/puzzle-result/PuzzleResultView.tsx b/src/components/puzzle-result/PuzzleResultView.tsx
index 4b280ad5..093b529a 100644
--- a/src/components/puzzle-result/PuzzleResultView.tsx
+++ b/src/components/puzzle-result/PuzzleResultView.tsx
@@ -1819,12 +1819,7 @@ export function PuzzleResultView({
) : null}
- {error ? (
-
- {error}
-
- ) : null}
- {!error && autoSaveError ? (
+ {autoSaveError ? (
{autoSaveError}
diff --git a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx
index f27b62c7..f336c6d6 100644
--- a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx
+++ b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx
@@ -1826,11 +1826,18 @@ test('non-wechat profile opens reward code from recharge-shaped entry', async ()
expect(mockGetRpgProfileRechargeCenter).not.toHaveBeenCalled();
});
-test('profile daily task shortcut opens task center and claims reward', async () => {
+test('profile daily task shortcut reflects task progress and claim updates', async () => {
const user = userEvent.setup();
const onRechargeSuccess = vi.fn();
renderProfileView(onRechargeSuccess);
+
+ const dailyTask = screen.getByRole('button', { name: /每日任务/u });
+ await waitFor(() => {
+ expect(within(dailyTask).getByText('1 / 1')).toBeTruthy();
+ });
+ expect(within(dailyTask).getByText('领取')).toBeTruthy();
+
await user.click(screen.getByRole('button', { name: /每日任务/u }));
expect(await screen.findByText('每日登录')).toBeTruthy();
@@ -1847,6 +1854,7 @@ test('profile daily task shortcut opens task center and claims reward', async ()
expect(await screen.findByText('已领取 10 泥点')).toBeTruthy();
expect(screen.queryByRole('button', { name: '已领取' })).toBeNull();
expect(screen.getByText('暂无任务')).toBeTruthy();
+ expect(within(dailyTask).getByText('已完成')).toBeTruthy();
});
test('profile task center keeps only the highest priority actionable task', async () => {
@@ -1909,7 +1917,7 @@ test('profile task center keeps only the highest priority actionable task', asyn
expect(screen.queryByText('低优先级已完成')).toBeNull();
});
-test('profile total play time card always uses hours', () => {
+test('profile total play time card always uses hours', async () => {
renderProfileView(vi.fn(), {
totalPlayTimeMs: 90 * 60 * 1000,
});
@@ -1920,9 +1928,10 @@ test('profile total play time card always uses hours', () => {
expect(within(playTimeCard).getByText('1.5小时')).toBeTruthy();
expect(within(playTimeCard).queryByText('90分')).toBeNull();
+ await screen.findByText('1 / 1');
});
-test('profile played works card shows count unit', () => {
+test('profile played works card shows count unit', async () => {
renderProfileView(vi.fn(), {
playedWorldCount: 1,
});
@@ -1932,9 +1941,10 @@ test('profile played works card shows count unit', () => {
});
expect(within(playedCard).getByText('1个')).toBeTruthy();
+ await screen.findByText('1 / 1');
});
-test('profile stats cards are centered without update timestamp', () => {
+test('profile stats cards are centered without update timestamp', async () => {
renderProfileView(vi.fn(), {
updatedAt: '2026-05-03T08:01:00Z',
});
@@ -1950,6 +1960,7 @@ test('profile stats cards are centered without update timestamp', () => {
expect(card.className).toContain('text-center');
}
expect(screen.queryByText(/更新于/u)).toBeNull();
+ await screen.findByText('1 / 1');
});
test('mobile profile page matches the reference layout sections', async () => {
@@ -2007,7 +2018,7 @@ test('mobile profile page matches the reference layout sections', async () => {
expect(dailyTask.querySelector('.platform-profile-daily-task-card__desc')).toBeTruthy();
expect(dailyTask.querySelector('.platform-profile-daily-task-card__progress')).toBeTruthy();
expect(dailyTask.textContent).toContain('完成任务可领取 10 泥点');
- expect(within(dailyTask).getByText('0 / 1')).toBeTruthy();
+ expect(await within(dailyTask).findByText('1 / 1')).toBeTruthy();
const shortcutRegion = screen.getByRole('region', { name: '常用功能' });
expect(
@@ -2101,7 +2112,7 @@ test('profile scan action opens camera scanner instead of recharge panel', async
expect(mockGetRpgProfileRechargeCenter).not.toHaveBeenCalled();
});
-test('desktop account entry uses saved avatar image when available', () => {
+test('desktop account entry uses saved avatar image when available', async () => {
mockDesktopLayout();
const avatarUrl = 'data:image/png;base64,AAAA';
@@ -2111,6 +2122,7 @@ test('desktop account entry uses saved avatar image when available', () => {
const avatarImage = accountEntry.querySelector('img');
expect(avatarImage?.getAttribute('src')).toBe(avatarUrl);
expect(within(accountEntry).queryByText('测')).toBeNull();
+ await screen.findByText('1 / 1');
});
test('profile avatar upload uses the shared square crop tool', async () => {
@@ -2184,7 +2196,7 @@ test('profile invite shortcut shows reward subtitle and invited users', async ()
expect(screen.queryByText('今日')).toBeNull();
});
-test('profile redeem invite shortcut sits between invite and community for fresh accounts', async () => {
+test('profile page hides legacy redeem invite secondary shortcut for fresh accounts', async () => {
renderProfileView(
vi.fn(),
{},
@@ -2192,20 +2204,16 @@ test('profile redeem invite shortcut sits between invite and community for fresh
);
const inviteButton = screen.getByRole('button', { name: /邀请好友/u });
- const redeemButton = await screen.findByRole('button', {
- name: /填邀请码/u,
- });
const communityButton = screen.getByRole('button', { name: /玩家社区/u });
- const secondaryShortcuts = screen.getByRole('region', {
- name: '次级入口',
+
+ await waitFor(() => {
+ expect(mockGetRpgProfileReferralInviteCenter).toHaveBeenCalledTimes(1);
});
expect(inviteButton).toBeTruthy();
expect(communityButton).toBeTruthy();
- expect(
- within(secondaryShortcuts).getByRole('button', { name: /填邀请码/u }),
- ).toBeTruthy();
- expect(within(redeemButton).getByText('新用户奖励')).toBeTruthy();
+ expect(screen.queryByRole('region', { name: '次级入口' })).toBeNull();
+ expect(screen.queryByRole('button', { name: /填邀请码/u })).toBeNull();
});
test('profile redeem invite shortcut hides after redeemed or one day old', async () => {
@@ -2226,6 +2234,7 @@ test('profile redeem invite shortcut hides after redeemed or one day old', async
expect(
within(firstShortcutRegion).queryByRole('button', { name: /填邀请码/u }),
).toBeNull();
+ await screen.findByText('1 / 1');
unmount();
renderProfileView(vi.fn(), {}, { createdAt: '2026-04-01T00:00:00.000Z' });
@@ -2237,6 +2246,7 @@ test('profile redeem invite shortcut hides after redeemed or one day old', async
name: /填邀请码/u,
}),
).toBeNull();
+ await screen.findByText('1 / 1');
});
test('invite query opens login modal for logged out users', async () => {
@@ -2269,9 +2279,10 @@ test('profile redeem invite modal reads query invite code after login', async ()
expect((input as HTMLInputElement).value).toBe('SPRING2026');
});
-test('profile redeem invite modal submits code and hides shortcut after success', async () => {
+test('profile redeem invite query modal submits code after login', async () => {
const user = userEvent.setup();
const onRechargeSuccess = vi.fn();
+ window.history.replaceState(null, '', '/?inviteCode=spring-2026');
renderProfileView(
onRechargeSuccess,
@@ -2279,9 +2290,7 @@ test('profile redeem invite modal submits code and hides shortcut after success'
{ createdAt: buildFreshProfileCreatedAt() },
);
- await user.click(await screen.findByRole('button', { name: /填邀请码/u }));
- const input = await screen.findByLabelText('邀请码');
- await user.type(input, 'spring-2026');
+ expect(await screen.findByLabelText('邀请码')).toBeTruthy();
await user.click(screen.getByRole('button', { name: '提交' }));
await waitFor(() => {
@@ -2291,12 +2300,7 @@ test('profile redeem invite modal submits code and hides shortcut after success'
});
expect(onRechargeSuccess).toHaveBeenCalledTimes(1);
expect(await screen.findByText('已填写')).toBeTruthy();
- const shortcutRegion = screen.getByRole('region', { name: '常用功能' });
- expect(
- within(shortcutRegion).queryByRole('button', {
- name: /填邀请码/u,
- }),
- ).toBeNull();
+ expect(screen.queryByRole('region', { name: '次级入口' })).toBeNull();
});
test('opens reward code modal from profile action on mobile', async () => {
diff --git a/src/components/rpg-entry/RpgEntryHomeView.tsx b/src/components/rpg-entry/RpgEntryHomeView.tsx
index 506b9c01..ab961e97 100644
--- a/src/components/rpg-entry/RpgEntryHomeView.tsx
+++ b/src/components/rpg-entry/RpgEntryHomeView.tsx
@@ -255,18 +255,25 @@ const RECOMMEND_ENTRY_DRAG_LIMIT_PX = 160;
const WECHAT_JS_SDK_URL = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js';
const WECHAT_PAY_CONFIRM_RETRY_DELAYS_MS = [800, 1600, 3000] as const;
const WECHAT_NATIVE_PAY_QR_IMAGE_SIZE = 180;
-const PROFILE_TASK_STATUS_PRIORITY_RANK: Record = {
+const PROFILE_TASK_STATUS_PRIORITY_RANK: Record<
+ ProfileTaskItem['status'],
+ number
+> = {
claimable: 2,
incomplete: 1,
disabled: 0,
claimed: -1,
};
+const PROFILE_TASK_CARD_FALLBACK_REWARD_POINTS = 10;
const PROFILE_QR_SCAN_INTERVAL_MS = 360;
function selectProfileTaskCenterTasks(tasks: ProfileTaskItem[]) {
return tasks
.map((task, index) => ({ task, index }))
- .filter(({ task }) => task.status === 'claimable' || task.status === 'incomplete')
+ .filter(
+ ({ task }) =>
+ task.status === 'claimable' || task.status === 'incomplete',
+ )
.sort(
(left, right) =>
PROFILE_TASK_STATUS_PRIORITY_RANK[right.task.status] -
@@ -277,6 +284,37 @@ function selectProfileTaskCenterTasks(tasks: ProfileTaskItem[]) {
.map(({ task }) => task);
}
+function selectProfileTaskCardTask(tasks: ProfileTaskItem[]) {
+ return (
+ selectProfileTaskCenterTasks(tasks)[0] ??
+ tasks.find((task) => task.status === 'claimed') ??
+ tasks.find((task) => task.status !== 'disabled') ??
+ null
+ );
+}
+
+function buildProfileTaskCardSummary(center: ProfileTaskCenterResponse | null) {
+ const task = selectProfileTaskCardTask(center?.tasks ?? []);
+ const threshold = Math.max(1, task?.threshold ?? 1);
+ const progressCount = Math.min(task?.progressCount ?? 0, threshold);
+ const rewardPoints =
+ task?.rewardPoints ?? PROFILE_TASK_CARD_FALLBACK_REWARD_POINTS;
+ const actionLabel =
+ task?.status === 'claimable'
+ ? '领取'
+ : task?.status === 'claimed'
+ ? '已完成'
+ : '去完成';
+
+ return {
+ actionLabel,
+ progressCount,
+ progressPercent: Math.round((progressCount / threshold) * 100),
+ rewardPoints,
+ threshold,
+ };
+}
+
type ProfileReferralPanel = 'invite' | 'redeem' | 'community';
type ProfilePopupPanel = ProfileReferralPanel | 'saveArchives';
type BarcodeDetectorLike = {
@@ -2449,42 +2487,6 @@ function ProfileSettingsRow({
);
}
-function ProfileSecondaryShortcutButton({
- label,
- subLabel,
- icon,
- onClick,
-}: {
- label: string;
- subLabel?: string;
- icon: ComponentType<{ className?: string }>;
- onClick: () => void;
-}) {
- const Icon = icon;
-
- return (
-
- );
-}
-
function ProfileLegalSection({
onOpenDocument,
}: {
@@ -4218,12 +4220,10 @@ export function RpgEntryHomeView({
profileDashboard?.totalPlayTimeMs ?? 0,
);
const playedWorkCount = profileDashboard?.playedWorldCount ?? 0;
- const canShowReferralRedeemShortcut =
- isAuthenticated &&
- isWithinProfileInviteRedeemWindow(authUi?.user?.createdAt) &&
- isReferralCenterInitialized &&
- Boolean(referralCenter) &&
- referralCenter?.hasRedeemedCode !== true;
+ const profileTaskCardSummary = useMemo(
+ () => buildProfileTaskCardSummary(taskCenter),
+ [taskCenter],
+ );
const tabIcons: Record<
PlatformHomeTab,
ComponentType<{ className?: string }>
@@ -4776,7 +4776,7 @@ export function RpgEntryHomeView({
document.removeEventListener('visibilitychange', handleResume);
};
}, [handleWechatPayResult]);
- const loadTaskCenter = () => {
+ const loadTaskCenter = useCallback(() => {
setTaskCenterError(null);
setIsLoadingTaskCenter(true);
void getRpgProfileTasks()
@@ -4788,11 +4788,24 @@ export function RpgEntryHomeView({
);
})
.finally(() => setIsLoadingTaskCenter(false));
- };
+ }, []);
+
+ useEffect(() => {
+ if (activeTab !== 'profile' || !isAuthenticated) {
+ setTaskCenter(null);
+ setTaskCenterError(null);
+ return;
+ }
+
+ loadTaskCenter();
+ }, [activeTab, isAuthenticated, loadTaskCenter]);
+
const openTaskCenterPanel = () => {
setIsTaskCenterOpen(true);
setTaskClaimSuccess(null);
- loadTaskCenter();
+ if (!taskCenter) {
+ loadTaskCenter();
+ }
};
const openQrScannerPanel = () => {
if (!authUi?.user) {
@@ -6185,14 +6198,24 @@ export function RpgEntryHomeView({
每日任务
- 完成任务可领取 10 泥点
+ 完成任务可领取{' '}
+
+ {profileTaskCardSummary.rewardPoints}
+ {' '}
+ 泥点
- 0 / 1
+ {profileTaskCardSummary.progressCount} /{' '}
+ {profileTaskCardSummary.threshold}
-
+
@@ -6202,7 +6225,7 @@ export function RpgEntryHomeView({
className="platform-profile-daily-task-card__mascot"
/>
- 去完成
+ {profileTaskCardSummary.actionLabel}
@@ -6267,20 +6290,6 @@ export function RpgEntryHomeView({
/>
- {canShowReferralRedeemShortcut ? (
-
- openProfilePopupPanel('redeem')}
- />
-
- ) : null}
-
>
) : (