feat: surface platform errors in copyable dialogs
This commit is contained in:
@@ -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 平台首页推荐按桌面与移动断点分流
|
## 2026-05-25 平台首页推荐按桌面与移动断点分流
|
||||||
|
|
||||||
- 背景:平台首页的推荐页在桌面与移动端之间原先共用同一套推荐运行态逻辑,容易让桌面和移动两套内容同时启动,也让首页的推荐卡与桌面发现壳互相抢状态。
|
- 背景:平台首页的推荐页在桌面与移动端之间原先共用同一套推荐运行态逻辑,容易让桌面和移动两套内容同时启动,也让首页的推荐卡与桌面发现壳互相抢状态。
|
||||||
|
|||||||
@@ -15,6 +15,30 @@
|
|||||||
- 关联:相关文件、文档、提交或 Issue
|
- 关联:相关文件、文档、提交或 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 白名单拉回平台。
|
- 现象:创作 Tab 模板卡点击后如果仍然停留在创作大厅,或者先进入“X 创作入口”这种空白页,就会让用户多走一层,还可能被错误的 stage 白名单拉回平台。
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
创作表单提交前的泥点余额前置校验只允许用独立弹窗提示失败原因,不得把用户退回创作入口或玩法模板列表,也不得清空当前表单状态。当前适用拼图、抓大鹅和汪汪声浪等会在前端提交前校验泥点的生成入口;余额不足、余额读取失败都应停留在当前工作台,由用户关闭提示后继续编辑或自行补足泥点。
|
创作表单提交前的泥点余额前置校验只允许用独立弹窗提示失败原因,不得把用户退回创作入口或玩法模板列表,也不得清空当前表单状态。当前适用拼图、抓大鹅和汪汪声浪等会在前端提交前校验泥点的生成入口;余额不足、余额读取失败都应停留在当前工作台,由用户关闭提示后继续编辑或自行补足泥点。
|
||||||
|
|
||||||
|
平台入口、生成页、结果页、作品详情、作品架和运行态的跨流程错误统一收口到 `PlatformErrorDialog`。弹窗必须带明确错误来源,例如某个草稿、某次生成、作品详情或某个游玩实例,并提供复制按钮复制“错误来源 + 错误内容”。页面内不再重复渲染裸错误 banner;表单校验、发布确认弹窗里的局部业务错误可以保留在原弹窗内。
|
||||||
|
|
||||||
`PlatformEntryFlowShellImpl.tsx` 仍是平台入口编排壳,后续维护时应优先把独立 UI 片段、公开作品映射、草稿生成 notice 和运行态状态 helper 拆到 `src/components/platform-entry/PlatformEntryFlowShellImpl/` 或同目录紧邻 helper 文件。拆分只允许改变文件组织,不改变入口配置事实源、默认导出、props、页面阶段、UI 文案或现有交互;其中拼图首访 onboarding 已拆为 `PlatformEntryFlowShellImpl/PuzzleOnboardingView.tsx`。
|
`PlatformEntryFlowShellImpl.tsx` 仍是平台入口编排壳,后续维护时应优先把独立 UI 片段、公开作品映射、草稿生成 notice 和运行态状态 helper 拆到 `src/components/platform-entry/PlatformEntryFlowShellImpl/` 或同目录紧邻 helper 文件。拆分只允许改变文件组织,不改变入口配置事实源、默认导出、props、页面阶段、UI 文案或现有交互;其中拼图首访 onboarding 已拆为 `PlatformEntryFlowShellImpl/PuzzleOnboardingView.tsx`。
|
||||||
|
|
||||||
`platformEntryCreationTypes.ts` 只做前端展示派生,分组时必须把后端 `creationTypes` 里的 `categoryId` / `categoryLabel` 当作可缺失字段处理,空值统一回退到 `recent` / `最近创作`,避免旧数据、局部 mock 或异常返回把创作入口初始化直接打崩。
|
`platformEntryCreationTypes.ts` 只做前端展示派生,分组时必须把后端 `creationTypes` 里的 `categoryId` / `categoryLabel` 当作可缺失字段处理,空值统一回退到 `recent` / `最近创作`,避免旧数据、局部 mock 或异常返回把创作入口初始化直接打崩。
|
||||||
@@ -44,7 +46,7 @@
|
|||||||
6. 点击 `generationStatus=generating` 的草稿卡必须恢复对应玩法的生成进度页,不能进入空白结果页或普通工作区;恢复生成页的 `startedAtMs` 使用进入生成页的当前时间,作品摘要 `updatedAt` 只用于排序和摘要展示,不参与假进度起算。
|
6. 点击 `generationStatus=generating` 的草稿卡必须恢复对应玩法的生成进度页,不能进入空白结果页或普通工作区;恢复生成页的 `startedAtMs` 使用进入生成页的当前时间,作品摘要 `updatedAt` 只用于排序和摘要展示,不参与假进度起算。
|
||||||
7. 私有 generated 图片必须通过 `ResolvedAssetImage` / `/api/assets/read-url` 换签读取。
|
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 / 自定义世界
|
## 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 运行态的战斗终局、继续冒险、继续探索和切场景都属于服务端 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` 返回的列表并在用户选择后调用对应恢复接口,不能本地拼装或筛选正式存档真相。
|
||||||
|
|
||||||
## 拼图
|
## 拼图
|
||||||
|
|
||||||
|
|||||||
@@ -93,11 +93,12 @@ server-rs + Axum + SpacetimeDB
|
|||||||
7. 主站入口已锁定移动端页面级缩放;单个游戏页面不要再重复实现整页缩放锁定。
|
7. 主站入口已锁定移动端页面级缩放;单个游戏页面不要再重复实现整页缩放锁定。
|
||||||
8. 图像输入通用 UI 统一走 `src/components/common/CreativeImageInputPanel.tsx`。外层页面持有业务状态,组件只承担上传卡、预览、参考图缩略图、AI 重绘开关、错误展示和提交按钮。
|
8. 图像输入通用 UI 统一走 `src/components/common/CreativeImageInputPanel.tsx`。外层页面持有业务状态,组件只承担上传卡、预览、参考图缩略图、AI 重绘开关、错误展示和提交按钮。
|
||||||
9. 发现页 `分类` 子频道的筛选必须打开独立 dialog / drawer / modal,至少支持玩法类型过滤与排序切换;筛选结果为空时显示空状态,不把筛选内容展开在当前列表下方。
|
9. 发现页 `分类` 子频道的筛选必须打开独立 dialog / drawer / modal,至少支持玩法类型过滤与排序切换;筛选结果为空时显示空状态,不把筛选内容展开在当前列表下方。
|
||||||
10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口、可选次级入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;页面不再提供独立存档按钮入口,填邀请码仅在新用户可填写窗口内展示为次级入口。
|
10. 移动端“我的”页顶部品牌行承载扫码和设置入口,正文按参考图顺序组织为头像 / 昵称 / 陶泥号、会员横幅、三张统计卡、每日任务、五项常用功能宫格、设置入口和法律信息;`media/profile/` 中的陶泥素材作为该页图形资产。常用功能宫格固定承载泥点充值、邀请好友、兑换码、玩家社区、反馈与建议;页面不再提供独立存档按钮入口,也不在底部保留旧的填邀请码次级入口。填邀请码只由邀请链接 query 或其它明确引导打开独立弹窗,不作为“我的”页常驻按钮。
|
||||||
11. “我的”页泥点、游戏时长、已玩游戏数量三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、会员卡、每日任务、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
|
11. “我的”页每日任务卡必须展示后端 `/api/profile/tasks` 返回的当前任务摘要,包括奖励泥点数、进度和领取 / 去完成 / 已完成状态;任务领取成功后,卡片摘要必须跟随返回的任务中心数据同步刷新,不能继续硬编码 `0 / 1` 或只更新弹窗内任务列表。
|
||||||
12. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、每日任务、五项常用功能、可选次级入口和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
|
12. “我的”页泥点、游戏时长、已玩游戏数量三张统计卡只展示各自标签和值,三个统计 icon 使用小尺寸普通 UI 档位,内容不换行,不在统计区底部展示“更新于”时间;移动端昵称、会员卡、每日任务、常用功能和法律信息也应保持 `10px` 到 `14px` 的普通 UI 字号区间,避免展示级字号挤压内容。
|
||||||
13. RPG 等运行态的战斗飘字、血量变化和即时反馈必须在暗色、噪声高的场景背景上保持可读:使用高亮文字、深色描边、强阴影或小面积半透明底,不只依赖红/绿文字本身表达伤害或治疗。
|
13. 移动端“我的”页需要兼容窄屏:头像 / 昵称 / 陶泥号、三张统计卡、每日任务、五项常用功能和法律信息都必须能在底部固定 TabBar 上方完整滚动露出,不得与底部 dock、刘海 safe-area 或相邻 UI 元素遮挡重叠。
|
||||||
14. 平台亮色 UI 配色以陶泥儿主视觉为准:暖白 / 米杏底、陶土橙主按钮、深棕正文与浅杏边框;新增界面优先复用 `src/index.css` 的 `--platform-*` 主题变量和 `apps/admin-web/src/styles/admin.css` 的同系色值,不再引入粉红、蓝绿等独立主色方案。
|
14. RPG 等运行态的战斗飘字、血量变化和即时反馈必须在暗色、噪声高的场景背景上保持可读:使用高亮文字、深色描边、强阴影或小面积半透明底,不只依赖红/绿文字本身表达伤害或治疗。
|
||||||
|
15. 平台亮色 UI 配色以陶泥儿主视觉为准:暖白 / 米杏底、陶土橙主按钮、深棕正文与浅杏边框;新增界面优先复用 `src/index.css` 的 `--platform-*` 主题变量和 `apps/admin-web/src/styles/admin.css` 的同系色值,不再引入粉红、蓝绿等独立主色方案。
|
||||||
|
|
||||||
## 文案与编码
|
## 文案与编码
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ interface CustomWorldGenerationViewProps {
|
|||||||
anchorEntries?: CustomWorldStructuredAnchorEntry[];
|
anchorEntries?: CustomWorldStructuredAnchorEntry[];
|
||||||
progress: CustomWorldGenerationProgress | null;
|
progress: CustomWorldGenerationProgress | null;
|
||||||
isGenerating: boolean;
|
isGenerating: boolean;
|
||||||
error: string | null;
|
error?: string | null;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onEditSetting: () => void;
|
onEditSetting: () => void;
|
||||||
onRetry: () => void;
|
onRetry: () => void;
|
||||||
@@ -110,7 +110,6 @@ export function CustomWorldGenerationView({
|
|||||||
anchorEntries = [],
|
anchorEntries = [],
|
||||||
progress,
|
progress,
|
||||||
isGenerating,
|
isGenerating,
|
||||||
error,
|
|
||||||
onBack,
|
onBack,
|
||||||
onEditSetting,
|
onEditSetting,
|
||||||
onRetry,
|
onRetry,
|
||||||
@@ -123,7 +122,6 @@ export function CustomWorldGenerationView({
|
|||||||
settingDescription = '这段文本会直接驱动本轮世界框架、角色与场景生成。',
|
settingDescription = '这段文本会直接驱动本轮世界框架、角色与场景生成。',
|
||||||
progressTitle = '生成进度',
|
progressTitle = '生成进度',
|
||||||
activeBadgeLabel = '世界建设中',
|
activeBadgeLabel = '世界建设中',
|
||||||
pausedBadgeLabel = '生成已暂停',
|
|
||||||
idleBadgeLabel = '等待操作',
|
idleBadgeLabel = '等待操作',
|
||||||
structuredEmptyText = '正在整理当前设定结构,请稍后。',
|
structuredEmptyText = '正在整理当前设定结构,请稍后。',
|
||||||
hideBatchModule = false,
|
hideBatchModule = false,
|
||||||
@@ -169,11 +167,7 @@ export function CustomWorldGenerationView({
|
|||||||
<span className="break-keep">{backLabel}</span>
|
<span className="break-keep">{backLabel}</span>
|
||||||
</button>
|
</button>
|
||||||
<div className="rounded-full border border-[#f05816] bg-white/72 px-3 py-1.5 text-[11px] font-black tracking-[0.08em] text-[#df6118] shadow-[0_12px_30px_rgba(214,77,31,0.08)] backdrop-blur-md sm:px-4 sm:text-xs">
|
<div className="rounded-full border border-[#f05816] bg-white/72 px-3 py-1.5 text-[11px] font-black tracking-[0.08em] text-[#df6118] shadow-[0_12px_30px_rgba(214,77,31,0.08)] backdrop-blur-md sm:px-4 sm:text-xs">
|
||||||
{isGenerating
|
{isGenerating ? activeBadgeLabel : idleBadgeLabel}
|
||||||
? activeBadgeLabel
|
|
||||||
: error
|
|
||||||
? pausedBadgeLabel
|
|
||||||
: idleBadgeLabel}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -195,12 +189,6 @@ export function CustomWorldGenerationView({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? (
|
|
||||||
<div className="mt-4 rounded-[1.4rem] border border-[#d88969]/35 bg-white/76 px-4 py-3 text-sm leading-6 text-[#a6402f] backdrop-blur-md">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:justify-end">
|
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:justify-end">
|
||||||
{!isGenerating ? (
|
{!isGenerating ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
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 { 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 { CustomWorldWorkSummary } from '../../../packages/shared/src/contracts/customWorldAgent';
|
||||||
import type { BabyObjectMatchDraft } from '../../../packages/shared/src/contracts/edutainmentBabyObject';
|
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 { Match3DWorkSummary } from '../../../packages/shared/src/contracts/match3dWorks';
|
||||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
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 { CustomWorldLibraryEntry } from '../../../packages/shared/src/contracts/runtime';
|
||||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||||
import type { VisualNovelWorkSummary } from '../../../packages/shared/src/contracts/visualNovel';
|
import type { VisualNovelWorkSummary } from '../../../packages/shared/src/contracts/visualNovel';
|
||||||
@@ -43,7 +43,6 @@ type CustomWorldCreationHubProps = {
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: string | null;
|
error: string | null;
|
||||||
onRetry: () => void;
|
onRetry: () => void;
|
||||||
createError?: string | null;
|
|
||||||
createBusy?: boolean;
|
createBusy?: boolean;
|
||||||
entryConfig: CreationEntryConfig;
|
entryConfig: CreationEntryConfig;
|
||||||
creationTypes: readonly PlatformCreationTypeCard[];
|
creationTypes: readonly PlatformCreationTypeCard[];
|
||||||
@@ -154,7 +153,6 @@ export function CustomWorldCreationHub({
|
|||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
onRetry,
|
onRetry,
|
||||||
createError = null,
|
|
||||||
createBusy = false,
|
createBusy = false,
|
||||||
entryConfig,
|
entryConfig,
|
||||||
creationTypes,
|
creationTypes,
|
||||||
@@ -360,7 +358,6 @@ export function CustomWorldCreationHub({
|
|||||||
{showStartCard ? (
|
{showStartCard ? (
|
||||||
<CustomWorldCreationStartCard
|
<CustomWorldCreationStartCard
|
||||||
busy={createBusy}
|
busy={createBusy}
|
||||||
error={createError}
|
|
||||||
entryConfig={entryConfig}
|
entryConfig={entryConfig}
|
||||||
creationTypes={creationTypes}
|
creationTypes={creationTypes}
|
||||||
onCreateType={onCreateType}
|
onCreateType={onCreateType}
|
||||||
@@ -377,12 +374,11 @@ export function CustomWorldCreationHub({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showWorkShelf && error ? (
|
{showWorkShelf && error ? (
|
||||||
<div className="platform-banner platform-banner--danger rounded-[1.4rem] px-4 py-4 text-sm leading-7">
|
<div className="flex justify-end">
|
||||||
<div>{error}</div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onRetry}
|
onClick={onRetry}
|
||||||
className="platform-button platform-button--ghost mt-3 min-h-0 rounded-full px-4 py-2 text-sm"
|
className="platform-button platform-button--ghost min-h-0 rounded-full px-4 py-2 text-sm"
|
||||||
>
|
>
|
||||||
重试
|
重试
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Coins, Trophy } from 'lucide-react';
|
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 type { CreationEntryConfig } from '../../services/creationEntryConfigService';
|
||||||
import {
|
import {
|
||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
|
|
||||||
type CustomWorldCreationStartCardProps = {
|
type CustomWorldCreationStartCardProps = {
|
||||||
busy?: boolean;
|
busy?: boolean;
|
||||||
error?: string | null;
|
|
||||||
entryConfig: CreationEntryConfig;
|
entryConfig: CreationEntryConfig;
|
||||||
creationTypes: readonly PlatformCreationTypeCard[];
|
creationTypes: readonly PlatformCreationTypeCard[];
|
||||||
onCreateType: (type: PlatformCreationTypeId) => void;
|
onCreateType: (type: PlatformCreationTypeId) => void;
|
||||||
@@ -25,7 +24,6 @@ function shouldShowCreationBadge(badge: string) {
|
|||||||
|
|
||||||
export function CustomWorldCreationStartCard({
|
export function CustomWorldCreationStartCard({
|
||||||
busy = false,
|
busy = false,
|
||||||
error = null,
|
|
||||||
entryConfig,
|
entryConfig,
|
||||||
creationTypes,
|
creationTypes,
|
||||||
onCreateType,
|
onCreateType,
|
||||||
@@ -233,11 +231,6 @@ export function CustomWorldCreationStartCard({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? (
|
|
||||||
<div className="platform-banner platform-banner--danger mt-4 rounded-[1rem] px-3 py-2 text-sm leading-5 sm:rounded-[1.25rem] sm:leading-6">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ test('dispatches wooden fish creation type selection', () => {
|
|||||||
<PlatformEntryCreationTypeModal
|
<PlatformEntryCreationTypeModal
|
||||||
isOpen
|
isOpen
|
||||||
isBusy={false}
|
isBusy={false}
|
||||||
error={null}
|
|
||||||
entryConfig={entryConfig}
|
entryConfig={entryConfig}
|
||||||
creationTypes={derivePlatformCreationTypes(entryConfig.creationTypes)}
|
creationTypes={derivePlatformCreationTypes(entryConfig.creationTypes)}
|
||||||
onClose={() => {}}
|
onClose={() => {}}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
export interface PlatformEntryCreationTypeModalProps {
|
export interface PlatformEntryCreationTypeModalProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
isBusy: boolean;
|
isBusy: boolean;
|
||||||
error: string | null;
|
|
||||||
entryConfig: CreationEntryConfig;
|
entryConfig: CreationEntryConfig;
|
||||||
creationTypes: readonly PlatformCreationTypeCard[];
|
creationTypes: readonly PlatformCreationTypeCard[];
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@@ -94,7 +93,6 @@ function CreationTypeCard(props: {
|
|||||||
export function PlatformEntryCreationTypeModal({
|
export function PlatformEntryCreationTypeModal({
|
||||||
isOpen,
|
isOpen,
|
||||||
isBusy,
|
isBusy,
|
||||||
error,
|
|
||||||
entryConfig,
|
entryConfig,
|
||||||
creationTypes,
|
creationTypes,
|
||||||
onClose,
|
onClose,
|
||||||
@@ -172,11 +170,6 @@ export function PlatformEntryCreationTypeModal({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? (
|
|
||||||
<div className="platform-banner platform-banner--danger mt-4 rounded-[1.25rem] text-sm leading-6">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</UnifiedModal>
|
</UnifiedModal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import type {
|
|||||||
BabyObjectMatchDraft,
|
BabyObjectMatchDraft,
|
||||||
CreateBabyObjectMatchDraftRequest,
|
CreateBabyObjectMatchDraftRequest,
|
||||||
} from '../../../packages/shared/src/contracts/edutainmentBabyObject';
|
} from '../../../packages/shared/src/contracts/edutainmentBabyObject';
|
||||||
|
import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
|
||||||
import type {
|
import type {
|
||||||
CreateMatch3DSessionRequest,
|
CreateMatch3DSessionRequest,
|
||||||
ExecuteMatch3DActionRequest,
|
ExecuteMatch3DActionRequest,
|
||||||
@@ -154,13 +155,6 @@ import {
|
|||||||
type CreationEntryConfig,
|
type CreationEntryConfig,
|
||||||
fetchCreationEntryConfig,
|
fetchCreationEntryConfig,
|
||||||
} from '../../services/creationEntryConfigService';
|
} from '../../services/creationEntryConfigService';
|
||||||
import {
|
|
||||||
cancelCreativeAgentSession,
|
|
||||||
confirmCreativePuzzleTemplate,
|
|
||||||
createCreativeAgentSession,
|
|
||||||
streamCreativeAgentMessage,
|
|
||||||
streamCreativeDraftEdit,
|
|
||||||
} from '../../services/creative-agent';
|
|
||||||
import {
|
import {
|
||||||
clearCreationUrlState,
|
clearCreationUrlState,
|
||||||
type CreationUrlState,
|
type CreationUrlState,
|
||||||
@@ -169,11 +163,12 @@ import {
|
|||||||
writeCreationUrlState,
|
writeCreationUrlState,
|
||||||
} from '../../services/creationUrlState';
|
} from '../../services/creationUrlState';
|
||||||
import {
|
import {
|
||||||
clearPuzzleRuntimeUrlState,
|
cancelCreativeAgentSession,
|
||||||
readPuzzleRuntimeUrlState,
|
confirmCreativePuzzleTemplate,
|
||||||
writePuzzleRuntimeUrlState,
|
createCreativeAgentSession,
|
||||||
type PuzzleRuntimeUrlState,
|
streamCreativeAgentMessage,
|
||||||
} from '../../services/puzzleRuntimeUrlState';
|
streamCreativeDraftEdit,
|
||||||
|
} from '../../services/creative-agent';
|
||||||
import {
|
import {
|
||||||
readCustomWorldAgentUiState,
|
readCustomWorldAgentUiState,
|
||||||
shouldRestoreCustomWorldAgentUiState,
|
shouldRestoreCustomWorldAgentUiState,
|
||||||
@@ -196,7 +191,6 @@ import {
|
|||||||
JumpHopWorkProfileResponse,
|
JumpHopWorkProfileResponse,
|
||||||
JumpHopWorkspaceCreateRequest,
|
JumpHopWorkspaceCreateRequest,
|
||||||
} from '../../services/jump-hop/jumpHopClient';
|
} from '../../services/jump-hop/jumpHopClient';
|
||||||
import type { JumpHopWorkSummaryResponse } from '../../../packages/shared/src/contracts/jumpHop';
|
|
||||||
import { match3dCreationClient } from '../../services/match3d-creation';
|
import { match3dCreationClient } from '../../services/match3d-creation';
|
||||||
import { createServerMatch3DRuntimeAdapter } from '../../services/match3d-runtime';
|
import { createServerMatch3DRuntimeAdapter } from '../../services/match3d-runtime';
|
||||||
import {
|
import {
|
||||||
@@ -287,6 +281,12 @@ import {
|
|||||||
listPuzzleWorks,
|
listPuzzleWorks,
|
||||||
updatePuzzleWork,
|
updatePuzzleWork,
|
||||||
} from '../../services/puzzle-works';
|
} from '../../services/puzzle-works';
|
||||||
|
import {
|
||||||
|
clearPuzzleRuntimeUrlState,
|
||||||
|
type PuzzleRuntimeUrlState,
|
||||||
|
readPuzzleRuntimeUrlState,
|
||||||
|
writePuzzleRuntimeUrlState,
|
||||||
|
} from '../../services/puzzleRuntimeUrlState';
|
||||||
import { deleteRpgCreationAgentSession } from '../../services/rpg-creation';
|
import { deleteRpgCreationAgentSession } from '../../services/rpg-creation';
|
||||||
import { rpgCreationPreviewAdapter } from '../../services/rpg-creation/rpgCreationPreviewAdapter';
|
import { rpgCreationPreviewAdapter } from '../../services/rpg-creation/rpgCreationPreviewAdapter';
|
||||||
import {
|
import {
|
||||||
@@ -375,6 +375,7 @@ import {
|
|||||||
mapVisualNovelWorkToPlatformGalleryCard,
|
mapVisualNovelWorkToPlatformGalleryCard,
|
||||||
mapWoodenFishWorkToPlatformGalleryCard,
|
mapWoodenFishWorkToPlatformGalleryCard,
|
||||||
type PlatformPublicGalleryCard,
|
type PlatformPublicGalleryCard,
|
||||||
|
resolvePlatformPublicWorkCode,
|
||||||
} from '../rpg-entry/rpgEntryWorldPresentation';
|
} from '../rpg-entry/rpgEntryWorldPresentation';
|
||||||
import { useRpgCreationAgentOperationPolling } from '../rpg-entry/useRpgCreationAgentOperationPolling';
|
import { useRpgCreationAgentOperationPolling } from '../rpg-entry/useRpgCreationAgentOperationPolling';
|
||||||
import { useRpgCreationEnterWorld } from '../rpg-entry/useRpgCreationEnterWorld';
|
import { useRpgCreationEnterWorld } from '../rpg-entry/useRpgCreationEnterWorld';
|
||||||
@@ -414,6 +415,7 @@ import {
|
|||||||
PlatformEntryHomeView,
|
PlatformEntryHomeView,
|
||||||
type PlatformHomeTab,
|
type PlatformHomeTab,
|
||||||
} from './PlatformEntryHomeView';
|
} from './PlatformEntryHomeView';
|
||||||
|
import { usePlatformDesktopLayout } from './platformEntryResponsive';
|
||||||
import {
|
import {
|
||||||
buildCreationHubFallbackItems,
|
buildCreationHubFallbackItems,
|
||||||
resolveRpgCreationErrorMessage,
|
resolveRpgCreationErrorMessage,
|
||||||
@@ -423,11 +425,14 @@ import type {
|
|||||||
SelectionStage,
|
SelectionStage,
|
||||||
} from './platformEntryTypes';
|
} from './platformEntryTypes';
|
||||||
import { PlatformEntryWorldDetailView } from './PlatformEntryWorldDetailView';
|
import { PlatformEntryWorldDetailView } from './PlatformEntryWorldDetailView';
|
||||||
|
import {
|
||||||
|
PlatformErrorDialog,
|
||||||
|
type PlatformErrorDialogPayload,
|
||||||
|
} from './PlatformErrorDialog';
|
||||||
import { PlatformFeedbackView } from './PlatformFeedbackView';
|
import { PlatformFeedbackView } from './PlatformFeedbackView';
|
||||||
import { PlatformWorkDetailView } from './PlatformWorkDetailView';
|
import { PlatformWorkDetailView } from './PlatformWorkDetailView';
|
||||||
import { usePlatformCreationAgentFlowController } from './usePlatformCreationAgentFlowController';
|
import { usePlatformCreationAgentFlowController } from './usePlatformCreationAgentFlowController';
|
||||||
import { usePlatformEntryBootstrap } from './usePlatformEntryBootstrap';
|
import { usePlatformEntryBootstrap } from './usePlatformEntryBootstrap';
|
||||||
import { usePlatformDesktopLayout } from './platformEntryResponsive';
|
|
||||||
import { usePlatformEntryLibraryDetail } from './usePlatformEntryLibraryDetail';
|
import { usePlatformEntryLibraryDetail } from './usePlatformEntryLibraryDetail';
|
||||||
import { usePlatformEntryNavigation } from './usePlatformEntryNavigation';
|
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(
|
function createMiniGameDraftGenerationStateForRestoredDraft(
|
||||||
kind: MiniGameDraftGenerationKind,
|
kind: MiniGameDraftGenerationKind,
|
||||||
metadata?: MiniGameDraftGenerationState['metadata'],
|
metadata?: MiniGameDraftGenerationState['metadata'],
|
||||||
@@ -5767,6 +5788,336 @@ export function PlatformEntryFlowShellImpl({
|
|||||||
isMiniGameDraftGenerating(
|
isMiniGameDraftGenerating(
|
||||||
activePuzzleBackgroundCompileTask?.generationState ?? null,
|
activePuzzleBackgroundCompileTask?.generationState ?? null,
|
||||||
);
|
);
|
||||||
|
const [dismissedPlatformErrorDialogKey, setDismissedPlatformErrorDialogKey] =
|
||||||
|
useState<string | null>(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 =
|
const shouldPollPuzzleGenerationSession =
|
||||||
selectionStage === 'puzzle-generating' &&
|
selectionStage === 'puzzle-generating' &&
|
||||||
activePuzzleGenerationSessionId != null &&
|
activePuzzleGenerationSessionId != null &&
|
||||||
@@ -14098,19 +14449,6 @@ export function PlatformEntryFlowShellImpl({
|
|||||||
void refreshBabyObjectMatchShelf();
|
void refreshBabyObjectMatchShelf();
|
||||||
void refreshBarkBattleShelf();
|
void refreshBarkBattleShelf();
|
||||||
}}
|
}}
|
||||||
createError={
|
|
||||||
creationEntryConfigError ??
|
|
||||||
sessionController.creationTypeError ??
|
|
||||||
bigFishError ??
|
|
||||||
match3dError ??
|
|
||||||
(isSquareHoleCreationVisible ? squareHoleError : null) ??
|
|
||||||
woodenFishError ??
|
|
||||||
puzzleCreationError ??
|
|
||||||
puzzleError ??
|
|
||||||
(isVisualNovelCreationOpen ? visualNovelError : null) ??
|
|
||||||
babyObjectMatchError ??
|
|
||||||
barkBattleError
|
|
||||||
}
|
|
||||||
createBusy={
|
createBusy={
|
||||||
!creationEntryConfig ||
|
!creationEntryConfig ||
|
||||||
sessionController.isCreatingAgentSession ||
|
sessionController.isCreatingAgentSession ||
|
||||||
@@ -15762,7 +16100,6 @@ export function PlatformEntryFlowShellImpl({
|
|||||||
settingDescription={null}
|
settingDescription={null}
|
||||||
progressTitle="拼图草稿生成进度"
|
progressTitle="拼图草稿生成进度"
|
||||||
activeBadgeLabel="草稿生成中"
|
activeBadgeLabel="草稿生成中"
|
||||||
pausedBadgeLabel="草稿生成已暂停"
|
|
||||||
idleBadgeLabel="等待返回工作区"
|
idleBadgeLabel="等待返回工作区"
|
||||||
hideBatchModule
|
hideBatchModule
|
||||||
/>
|
/>
|
||||||
@@ -16436,20 +16773,6 @@ export function PlatformEntryFlowShellImpl({
|
|||||||
(isVisualNovelCreationOpen && isVisualNovelStreamingReply) ||
|
(isVisualNovelCreationOpen && isVisualNovelStreamingReply) ||
|
||||||
isBabyObjectMatchBusy
|
isBabyObjectMatchBusy
|
||||||
}
|
}
|
||||||
error={
|
|
||||||
creationEntryConfigError ??
|
|
||||||
bigFishError ??
|
|
||||||
creativeAgentError ??
|
|
||||||
match3dError ??
|
|
||||||
squareHoleError ??
|
|
||||||
jumpHopError ??
|
|
||||||
woodenFishError ??
|
|
||||||
puzzleCreationError ??
|
|
||||||
(isVisualNovelCreationOpen ? visualNovelError : null) ??
|
|
||||||
babyObjectMatchError ??
|
|
||||||
puzzleError ??
|
|
||||||
sessionController.creationTypeError
|
|
||||||
}
|
|
||||||
entryConfig={creationEntryConfig}
|
entryConfig={creationEntryConfig}
|
||||||
creationTypes={creationEntryTypes}
|
creationTypes={creationEntryTypes}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
@@ -16542,6 +16865,12 @@ export function PlatformEntryFlowShellImpl({
|
|||||||
payload={publishSharePayload}
|
payload={publishSharePayload}
|
||||||
onClose={() => setPublishSharePayload(null)}
|
onClose={() => setPublishSharePayload(null)}
|
||||||
/>
|
/>
|
||||||
|
<PlatformErrorDialog
|
||||||
|
error={activePlatformErrorDialog}
|
||||||
|
onClose={closePlatformErrorDialog}
|
||||||
|
overlayClassName={`platform-theme ${platformThemeClass} !items-center`}
|
||||||
|
panelClassName="platform-remap-surface rounded-[1.5rem]"
|
||||||
|
/>
|
||||||
<UnifiedModal
|
<UnifiedModal
|
||||||
open={Boolean(pendingDeleteCreationWork)}
|
open={Boolean(pendingDeleteCreationWork)}
|
||||||
title="删除作品"
|
title="删除作品"
|
||||||
|
|||||||
60
src/components/platform-entry/PlatformErrorDialog.test.tsx
Normal file
60
src/components/platform-entry/PlatformErrorDialog.test.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/* @vitest-environment jsdom */
|
||||||
|
|
||||||
|
import {
|
||||||
|
fireEvent,
|
||||||
|
render,
|
||||||
|
screen,
|
||||||
|
waitFor,
|
||||||
|
within,
|
||||||
|
} from '@testing-library/react';
|
||||||
|
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
|
import * as clipboardService from '../../services/clipboard';
|
||||||
|
import { PlatformErrorDialog } from './PlatformErrorDialog';
|
||||||
|
|
||||||
|
vi.mock('../../services/clipboard', () => ({
|
||||||
|
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(
|
||||||
|
<PlatformErrorDialog
|
||||||
|
error={{
|
||||||
|
source: '拼图草稿 puzzle-session-123',
|
||||||
|
message: '图片生成失败,请稍后再试。',
|
||||||
|
}}
|
||||||
|
onClose={() => {}}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
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(<PlatformErrorDialog error={null} onClose={() => {}} />);
|
||||||
|
|
||||||
|
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
120
src/components/platform-entry/PlatformErrorDialog.tsx
Normal file
120
src/components/platform-entry/PlatformErrorDialog.tsx
Normal file
@@ -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<number | null>(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 (
|
||||||
|
<UnifiedModal
|
||||||
|
open={Boolean(error)}
|
||||||
|
title="发生错误"
|
||||||
|
onClose={onClose}
|
||||||
|
size="sm"
|
||||||
|
overlayClassName={overlayClassName}
|
||||||
|
panelClassName={panelClassName}
|
||||||
|
bodyClassName="space-y-3 px-4 py-4 sm:px-5 sm:py-5"
|
||||||
|
footerClassName="justify-end px-4 py-4 sm:px-5"
|
||||||
|
footer={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={copyError}
|
||||||
|
disabled={!reportText}
|
||||||
|
className="platform-button platform-button--primary w-full justify-center gap-2 sm:w-auto"
|
||||||
|
>
|
||||||
|
{copyState === 'copied' ? (
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<Copy className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
{copyState === 'copied'
|
||||||
|
? '已复制'
|
||||||
|
: copyState === 'failed'
|
||||||
|
? '复制失败'
|
||||||
|
: '复制报错'}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{error ? (
|
||||||
|
<>
|
||||||
|
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
|
||||||
|
<div className="text-xs font-bold text-[var(--platform-text-soft)]">
|
||||||
|
来源
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 break-words text-sm font-semibold leading-5 text-[var(--platform-text-strong)]">
|
||||||
|
{error.source}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
|
||||||
|
<div className="text-xs font-bold text-[var(--platform-text-soft)]">
|
||||||
|
错误
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 whitespace-pre-wrap break-words text-sm leading-6 text-[var(--platform-text-strong)]">
|
||||||
|
{error.message}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</UnifiedModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
formatPlatformWorldTime,
|
formatPlatformWorldTime,
|
||||||
isBarkBattleGalleryEntry,
|
isBarkBattleGalleryEntry,
|
||||||
isEdutainmentGalleryEntry,
|
isEdutainmentGalleryEntry,
|
||||||
isJumpHopGalleryEntry,
|
|
||||||
type PlatformPublicGalleryCard,
|
type PlatformPublicGalleryCard,
|
||||||
resolvePlatformPublicWorkCode,
|
resolvePlatformPublicWorkCode,
|
||||||
resolvePlatformWorldCoverSlides,
|
resolvePlatformWorldCoverSlides,
|
||||||
@@ -36,7 +35,7 @@ export interface PlatformWorkDetailViewProps {
|
|||||||
authorAvatarUrl?: string | null;
|
authorAvatarUrl?: string | null;
|
||||||
authorDisplayName?: string | null;
|
authorDisplayName?: string | null;
|
||||||
isBusy: boolean;
|
isBusy: boolean;
|
||||||
error: string | null;
|
error?: string | null;
|
||||||
visibleCoverCount?: number;
|
visibleCoverCount?: number;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onLike: () => void;
|
onLike: () => void;
|
||||||
@@ -89,7 +88,6 @@ export function PlatformWorkDetailView({
|
|||||||
authorAvatarUrl,
|
authorAvatarUrl,
|
||||||
authorDisplayName,
|
authorDisplayName,
|
||||||
isBusy,
|
isBusy,
|
||||||
error,
|
|
||||||
visibleCoverCount = 1,
|
visibleCoverCount = 1,
|
||||||
onBack,
|
onBack,
|
||||||
onLike,
|
onLike,
|
||||||
@@ -432,9 +430,6 @@ export function PlatformWorkDetailView({
|
|||||||
{shareState === 'copied' ? '分享内容已复制' : '分享失败'}
|
{shareState === 'copied' ? '分享内容已复制' : '分享失败'}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{error ? (
|
|
||||||
<div className="platform-work-detail__error">{error}</div>
|
|
||||||
) : null}
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1819,12 +1819,7 @@ export function PuzzleResultView({
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? (
|
{autoSaveError ? (
|
||||||
<div className="platform-banner platform-banner--danger mt-3 rounded-2xl text-sm leading-6">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
{!error && autoSaveError ? (
|
|
||||||
<div className="platform-banner platform-banner--danger mt-3 rounded-2xl text-sm leading-6">
|
<div className="platform-banner platform-banner--danger mt-3 rounded-2xl text-sm leading-6">
|
||||||
{autoSaveError}
|
{autoSaveError}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1826,11 +1826,18 @@ test('non-wechat profile opens reward code from recharge-shaped entry', async ()
|
|||||||
expect(mockGetRpgProfileRechargeCenter).not.toHaveBeenCalled();
|
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 user = userEvent.setup();
|
||||||
const onRechargeSuccess = vi.fn();
|
const onRechargeSuccess = vi.fn();
|
||||||
|
|
||||||
renderProfileView(onRechargeSuccess);
|
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 }));
|
await user.click(screen.getByRole('button', { name: /每日任务/u }));
|
||||||
|
|
||||||
expect(await screen.findByText('每日登录')).toBeTruthy();
|
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(await screen.findByText('已领取 10 泥点')).toBeTruthy();
|
||||||
expect(screen.queryByRole('button', { name: '已领取' })).toBeNull();
|
expect(screen.queryByRole('button', { name: '已领取' })).toBeNull();
|
||||||
expect(screen.getByText('暂无任务')).toBeTruthy();
|
expect(screen.getByText('暂无任务')).toBeTruthy();
|
||||||
|
expect(within(dailyTask).getByText('已完成')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('profile task center keeps only the highest priority actionable task', async () => {
|
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();
|
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(), {
|
renderProfileView(vi.fn(), {
|
||||||
totalPlayTimeMs: 90 * 60 * 1000,
|
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).getByText('1.5小时')).toBeTruthy();
|
||||||
expect(within(playTimeCard).queryByText('90分')).toBeNull();
|
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(), {
|
renderProfileView(vi.fn(), {
|
||||||
playedWorldCount: 1,
|
playedWorldCount: 1,
|
||||||
});
|
});
|
||||||
@@ -1932,9 +1941,10 @@ test('profile played works card shows count unit', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(within(playedCard).getByText('1个')).toBeTruthy();
|
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(), {
|
renderProfileView(vi.fn(), {
|
||||||
updatedAt: '2026-05-03T08:01:00Z',
|
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(card.className).toContain('text-center');
|
||||||
}
|
}
|
||||||
expect(screen.queryByText(/更新于/u)).toBeNull();
|
expect(screen.queryByText(/更新于/u)).toBeNull();
|
||||||
|
await screen.findByText('1 / 1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('mobile profile page matches the reference layout sections', async () => {
|
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__desc')).toBeTruthy();
|
||||||
expect(dailyTask.querySelector('.platform-profile-daily-task-card__progress')).toBeTruthy();
|
expect(dailyTask.querySelector('.platform-profile-daily-task-card__progress')).toBeTruthy();
|
||||||
expect(dailyTask.textContent).toContain('完成任务可领取 10 泥点');
|
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: '常用功能' });
|
const shortcutRegion = screen.getByRole('region', { name: '常用功能' });
|
||||||
expect(
|
expect(
|
||||||
@@ -2101,7 +2112,7 @@ test('profile scan action opens camera scanner instead of recharge panel', async
|
|||||||
expect(mockGetRpgProfileRechargeCenter).not.toHaveBeenCalled();
|
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();
|
mockDesktopLayout();
|
||||||
const avatarUrl = 'data:image/png;base64,AAAA';
|
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');
|
const avatarImage = accountEntry.querySelector('img');
|
||||||
expect(avatarImage?.getAttribute('src')).toBe(avatarUrl);
|
expect(avatarImage?.getAttribute('src')).toBe(avatarUrl);
|
||||||
expect(within(accountEntry).queryByText('测')).toBeNull();
|
expect(within(accountEntry).queryByText('测')).toBeNull();
|
||||||
|
await screen.findByText('1 / 1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('profile avatar upload uses the shared square crop tool', async () => {
|
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();
|
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(
|
renderProfileView(
|
||||||
vi.fn(),
|
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 inviteButton = screen.getByRole('button', { name: /邀请好友/u });
|
||||||
const redeemButton = await screen.findByRole('button', {
|
|
||||||
name: /填邀请码/u,
|
|
||||||
});
|
|
||||||
const communityButton = screen.getByRole('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(inviteButton).toBeTruthy();
|
||||||
expect(communityButton).toBeTruthy();
|
expect(communityButton).toBeTruthy();
|
||||||
expect(
|
expect(screen.queryByRole('region', { name: '次级入口' })).toBeNull();
|
||||||
within(secondaryShortcuts).getByRole('button', { name: /填邀请码/u }),
|
expect(screen.queryByRole('button', { name: /填邀请码/u })).toBeNull();
|
||||||
).toBeTruthy();
|
|
||||||
expect(within(redeemButton).getByText('新用户奖励')).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('profile redeem invite shortcut hides after redeemed or one day old', async () => {
|
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(
|
expect(
|
||||||
within(firstShortcutRegion).queryByRole('button', { name: /填邀请码/u }),
|
within(firstShortcutRegion).queryByRole('button', { name: /填邀请码/u }),
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
|
await screen.findByText('1 / 1');
|
||||||
unmount();
|
unmount();
|
||||||
|
|
||||||
renderProfileView(vi.fn(), {}, { createdAt: '2026-04-01T00:00:00.000Z' });
|
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,
|
name: /填邀请码/u,
|
||||||
}),
|
}),
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
|
await screen.findByText('1 / 1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('invite query opens login modal for logged out users', async () => {
|
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');
|
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 user = userEvent.setup();
|
||||||
const onRechargeSuccess = vi.fn();
|
const onRechargeSuccess = vi.fn();
|
||||||
|
window.history.replaceState(null, '', '/?inviteCode=spring-2026');
|
||||||
|
|
||||||
renderProfileView(
|
renderProfileView(
|
||||||
onRechargeSuccess,
|
onRechargeSuccess,
|
||||||
@@ -2279,9 +2290,7 @@ test('profile redeem invite modal submits code and hides shortcut after success'
|
|||||||
{ createdAt: buildFreshProfileCreatedAt() },
|
{ createdAt: buildFreshProfileCreatedAt() },
|
||||||
);
|
);
|
||||||
|
|
||||||
await user.click(await screen.findByRole('button', { name: /填邀请码/u }));
|
expect(await screen.findByLabelText('邀请码')).toBeTruthy();
|
||||||
const input = await screen.findByLabelText('邀请码');
|
|
||||||
await user.type(input, 'spring-2026');
|
|
||||||
await user.click(screen.getByRole('button', { name: '提交' }));
|
await user.click(screen.getByRole('button', { name: '提交' }));
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
@@ -2291,12 +2300,7 @@ test('profile redeem invite modal submits code and hides shortcut after success'
|
|||||||
});
|
});
|
||||||
expect(onRechargeSuccess).toHaveBeenCalledTimes(1);
|
expect(onRechargeSuccess).toHaveBeenCalledTimes(1);
|
||||||
expect(await screen.findByText('已填写')).toBeTruthy();
|
expect(await screen.findByText('已填写')).toBeTruthy();
|
||||||
const shortcutRegion = screen.getByRole('region', { name: '常用功能' });
|
expect(screen.queryByRole('region', { name: '次级入口' })).toBeNull();
|
||||||
expect(
|
|
||||||
within(shortcutRegion).queryByRole('button', {
|
|
||||||
name: /填邀请码/u,
|
|
||||||
}),
|
|
||||||
).toBeNull();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('opens reward code modal from profile action on mobile', async () => {
|
test('opens reward code modal from profile action on mobile', async () => {
|
||||||
|
|||||||
@@ -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_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_PAY_CONFIRM_RETRY_DELAYS_MS = [800, 1600, 3000] as const;
|
||||||
const WECHAT_NATIVE_PAY_QR_IMAGE_SIZE = 180;
|
const WECHAT_NATIVE_PAY_QR_IMAGE_SIZE = 180;
|
||||||
const PROFILE_TASK_STATUS_PRIORITY_RANK: Record<ProfileTaskItem['status'], number> = {
|
const PROFILE_TASK_STATUS_PRIORITY_RANK: Record<
|
||||||
|
ProfileTaskItem['status'],
|
||||||
|
number
|
||||||
|
> = {
|
||||||
claimable: 2,
|
claimable: 2,
|
||||||
incomplete: 1,
|
incomplete: 1,
|
||||||
disabled: 0,
|
disabled: 0,
|
||||||
claimed: -1,
|
claimed: -1,
|
||||||
};
|
};
|
||||||
|
const PROFILE_TASK_CARD_FALLBACK_REWARD_POINTS = 10;
|
||||||
const PROFILE_QR_SCAN_INTERVAL_MS = 360;
|
const PROFILE_QR_SCAN_INTERVAL_MS = 360;
|
||||||
|
|
||||||
function selectProfileTaskCenterTasks(tasks: ProfileTaskItem[]) {
|
function selectProfileTaskCenterTasks(tasks: ProfileTaskItem[]) {
|
||||||
return tasks
|
return tasks
|
||||||
.map((task, index) => ({ task, index }))
|
.map((task, index) => ({ task, index }))
|
||||||
.filter(({ task }) => task.status === 'claimable' || task.status === 'incomplete')
|
.filter(
|
||||||
|
({ task }) =>
|
||||||
|
task.status === 'claimable' || task.status === 'incomplete',
|
||||||
|
)
|
||||||
.sort(
|
.sort(
|
||||||
(left, right) =>
|
(left, right) =>
|
||||||
PROFILE_TASK_STATUS_PRIORITY_RANK[right.task.status] -
|
PROFILE_TASK_STATUS_PRIORITY_RANK[right.task.status] -
|
||||||
@@ -277,6 +284,37 @@ function selectProfileTaskCenterTasks(tasks: ProfileTaskItem[]) {
|
|||||||
.map(({ task }) => task);
|
.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 ProfileReferralPanel = 'invite' | 'redeem' | 'community';
|
||||||
type ProfilePopupPanel = ProfileReferralPanel | 'saveArchives';
|
type ProfilePopupPanel = ProfileReferralPanel | 'saveArchives';
|
||||||
type BarcodeDetectorLike = {
|
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 (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={onClick}
|
|
||||||
className="platform-profile-secondary-shortcut inline-flex items-center gap-2 rounded-full px-3 py-2 text-left"
|
|
||||||
>
|
|
||||||
<span className="platform-profile-secondary-shortcut__icon">
|
|
||||||
<Icon className="h-4 w-4" />
|
|
||||||
</span>
|
|
||||||
<span className="min-w-0">
|
|
||||||
<span className="block truncate text-[13px] font-semibold text-[var(--platform-text-strong)]">
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
{subLabel ? (
|
|
||||||
<span className="mt-0.5 block truncate text-[11px] font-medium text-[var(--platform-text-soft)]">
|
|
||||||
{subLabel}
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ProfileLegalSection({
|
function ProfileLegalSection({
|
||||||
onOpenDocument,
|
onOpenDocument,
|
||||||
}: {
|
}: {
|
||||||
@@ -4218,12 +4220,10 @@ export function RpgEntryHomeView({
|
|||||||
profileDashboard?.totalPlayTimeMs ?? 0,
|
profileDashboard?.totalPlayTimeMs ?? 0,
|
||||||
);
|
);
|
||||||
const playedWorkCount = profileDashboard?.playedWorldCount ?? 0;
|
const playedWorkCount = profileDashboard?.playedWorldCount ?? 0;
|
||||||
const canShowReferralRedeemShortcut =
|
const profileTaskCardSummary = useMemo(
|
||||||
isAuthenticated &&
|
() => buildProfileTaskCardSummary(taskCenter),
|
||||||
isWithinProfileInviteRedeemWindow(authUi?.user?.createdAt) &&
|
[taskCenter],
|
||||||
isReferralCenterInitialized &&
|
);
|
||||||
Boolean(referralCenter) &&
|
|
||||||
referralCenter?.hasRedeemedCode !== true;
|
|
||||||
const tabIcons: Record<
|
const tabIcons: Record<
|
||||||
PlatformHomeTab,
|
PlatformHomeTab,
|
||||||
ComponentType<{ className?: string }>
|
ComponentType<{ className?: string }>
|
||||||
@@ -4776,7 +4776,7 @@ export function RpgEntryHomeView({
|
|||||||
document.removeEventListener('visibilitychange', handleResume);
|
document.removeEventListener('visibilitychange', handleResume);
|
||||||
};
|
};
|
||||||
}, [handleWechatPayResult]);
|
}, [handleWechatPayResult]);
|
||||||
const loadTaskCenter = () => {
|
const loadTaskCenter = useCallback(() => {
|
||||||
setTaskCenterError(null);
|
setTaskCenterError(null);
|
||||||
setIsLoadingTaskCenter(true);
|
setIsLoadingTaskCenter(true);
|
||||||
void getRpgProfileTasks()
|
void getRpgProfileTasks()
|
||||||
@@ -4788,11 +4788,24 @@ export function RpgEntryHomeView({
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.finally(() => setIsLoadingTaskCenter(false));
|
.finally(() => setIsLoadingTaskCenter(false));
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeTab !== 'profile' || !isAuthenticated) {
|
||||||
|
setTaskCenter(null);
|
||||||
|
setTaskCenterError(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTaskCenter();
|
||||||
|
}, [activeTab, isAuthenticated, loadTaskCenter]);
|
||||||
|
|
||||||
const openTaskCenterPanel = () => {
|
const openTaskCenterPanel = () => {
|
||||||
setIsTaskCenterOpen(true);
|
setIsTaskCenterOpen(true);
|
||||||
setTaskClaimSuccess(null);
|
setTaskClaimSuccess(null);
|
||||||
|
if (!taskCenter) {
|
||||||
loadTaskCenter();
|
loadTaskCenter();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const openQrScannerPanel = () => {
|
const openQrScannerPanel = () => {
|
||||||
if (!authUi?.user) {
|
if (!authUi?.user) {
|
||||||
@@ -6185,14 +6198,24 @@ export function RpgEntryHomeView({
|
|||||||
每日任务
|
每日任务
|
||||||
</span>
|
</span>
|
||||||
<span className="platform-profile-daily-task-card__desc mt-4 block text-[13px] font-medium text-[var(--platform-text-base)]">
|
<span className="platform-profile-daily-task-card__desc mt-4 block text-[13px] font-medium text-[var(--platform-text-base)]">
|
||||||
完成任务可领取 <span className="text-[#c45b2a]">10</span> 泥点
|
完成任务可领取{' '}
|
||||||
|
<span className="text-[#c45b2a]">
|
||||||
|
{profileTaskCardSummary.rewardPoints}
|
||||||
|
</span>{' '}
|
||||||
|
泥点
|
||||||
</span>
|
</span>
|
||||||
<span className="platform-profile-daily-task-card__progress mt-4 flex items-center gap-3">
|
<span className="platform-profile-daily-task-card__progress mt-4 flex items-center gap-3">
|
||||||
<span className="platform-profile-daily-task-card__progress-value text-[14px] font-semibold text-[#dc3f0e]">
|
<span className="platform-profile-daily-task-card__progress-value text-[14px] font-semibold text-[#dc3f0e]">
|
||||||
0 / 1
|
{profileTaskCardSummary.progressCount} /{' '}
|
||||||
|
{profileTaskCardSummary.threshold}
|
||||||
</span>
|
</span>
|
||||||
<span className="platform-profile-daily-task-card__track">
|
<span className="platform-profile-daily-task-card__track">
|
||||||
<span className="platform-profile-daily-task-card__bar" />
|
<span
|
||||||
|
className="platform-profile-daily-task-card__bar"
|
||||||
|
style={{
|
||||||
|
width: `${profileTaskCardSummary.progressPercent}%`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -6202,7 +6225,7 @@ export function RpgEntryHomeView({
|
|||||||
className="platform-profile-daily-task-card__mascot"
|
className="platform-profile-daily-task-card__mascot"
|
||||||
/>
|
/>
|
||||||
<span className="platform-profile-daily-task-card__action">
|
<span className="platform-profile-daily-task-card__action">
|
||||||
去完成
|
{profileTaskCardSummary.actionLabel}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -6267,20 +6290,6 @@ export function RpgEntryHomeView({
|
|||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{canShowReferralRedeemShortcut ? (
|
|
||||||
<section
|
|
||||||
className="platform-profile-secondary-shortcuts"
|
|
||||||
aria-label="次级入口"
|
|
||||||
>
|
|
||||||
<ProfileSecondaryShortcutButton
|
|
||||||
label="填邀请码"
|
|
||||||
subLabel="新用户奖励"
|
|
||||||
icon={Ticket}
|
|
||||||
onClick={() => openProfilePopupPanel('redeem')}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<ProfileLegalSection onOpenDocument={setActiveLegalDocumentId} />
|
<ProfileLegalSection onOpenDocument={setActiveLegalDocumentId} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user