网页端共创主题:共创 Tab + 主题页(逐根内嵌作品树)+ 详情页主题入口 + 网关清单
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled

- 客户端:新增 listThemes(游标分页,读 nextCursor)与 getTheme(404 由页面渲染成降级态);getGame 的返回类型增量 themes(匿名也返回;无主题时是空数组而不是缺键)
- 共创 Tab:广场页新增「游戏 / 共创」页签,复用既有 game-category-tabs 结构与类名,切到 /games/themes
- 主题列表页 GameThemesPage:卡片展示 name / summary / badge / memberCount;只有 nextCursor 非空才渲染「加载更多」并在点击时追加;空态与失败重试照既有写法
- 主题页 GameThemePage:标题 / 简介 / 角标 + 成员根清单;**逐根内嵌渲染作品树**——直接复用族谱页(GameLineagePage 新增 embedded 变体,只隐藏页面外壳:返回按钮 / 页头 / 脚注),树查询、可见性过滤、稳定排序与截断全部走 M3 那一份实现,不新建第二套树查询或树渲染(每根一次 /lineage 的 N+1 是技术方案 §3.10.4 已接受的取舍);已发布但可见成员为空 → 明确空态而不是错误;主题不存在 / 未发布 → 错误态
- 详情页:共创信息卡渲染所属主题角标(点击进主题页),第 N 代作品同样可见(服务端按根反查);无主题时不渲染空容器
- 路由登记:新增 /games/themes 与 /games/theme(详情用 ?id=),四处同批登记(STAGE_ROUTE_ENTRIES + SelectionStage 类型 + 壳层 lazy/回调/渲染分支 + 页面标题),并同步三份 nginx SPA allowlist 与 Pingora MAIN_SPA_PATHS:check:nginx-spa-routes(20 SPA routes / 3 模板)与 check:pingora-route-parity 均绿
- 测试:主题列表三例(渲染与卡片跳转 / 有游标时的加载更多与追加 / 空态与失败重试)、主题页三例(逐根两棵树且复用 lineage 查询 + 全屏入口参数 / 空成员空态 / 404 错误态)、详情页主题入口两例(渲染并可跳转 / 无主题不渲染容器)、路由与标题登记断言、壳层三例(页签切换 / 列表进主题页 / 主题页按 ?id= 渲染并复用族谱查询)
This commit is contained in:
2026-10-06 03:45:38 +08:00
parent 58da0e67db
commit 909f3d5fa2
19 changed files with 1186 additions and 28 deletions
@@ -55,6 +55,8 @@ const gameDistributionMock = vi.hoisted(() => ({
getDerivedGames: vi.fn(),
getGame: vi.fn(),
getGameLineage: vi.fn(),
getTheme: vi.fn(),
listThemes: vi.fn(),
getGameVersion: vi.fn(),
getMyGame: vi.fn(),
listGames: vi.fn(),
@@ -1494,3 +1496,106 @@ describe('创作族谱', () => {
);
});
});
describe('共创主题', () => {
it('广场「共创」页签切到主题列表', async () => {
window.history.replaceState(null, '', '/games');
gameDistributionMock.listGames.mockResolvedValue([]);
gameDistributionMock.listThemes.mockResolvedValue({
themes: [],
nextCursor: null,
});
const setSelectionStage = vi.fn();
render(
<PlatformEntryFlowShellImpl
selectionStage="games"
setSelectionStage={setSelectionStage}
/>,
);
fireEvent.click(await screen.findByRole('tab', { name: '共创' }));
expect(setSelectionStage).toHaveBeenCalledWith('game-themes', {
path: '/games/themes',
});
});
it('主题列表页渲染主题并进入主题页', async () => {
window.history.replaceState(null, '', '/games/themes');
gameDistributionMock.listThemes.mockResolvedValue({
themes: [
{
themeId: 'theme-1',
name: '精选共创',
summary: '运营精选',
badge: '精选',
memberCount: 1,
},
],
nextCursor: null,
});
const setSelectionStage = vi.fn();
render(
<PlatformEntryFlowShellImpl
selectionStage="game-themes"
setSelectionStage={setSelectionStage}
/>,
);
fireEvent.click(await screen.findByRole('button', { name: /精选共创/u }));
expect(setSelectionStage).toHaveBeenCalledWith('game-theme', {
path: '/games/theme?id=theme-1',
});
});
it('主题详情按 ?id= 渲染主题名与成员根,并复用族谱查询', async () => {
window.history.replaceState(null, '', '/games/theme?id=theme-1');
gameDistributionMock.getTheme.mockResolvedValue({
themeId: 'theme-1',
name: '精选共创',
summary: '运营精选',
badge: '精选',
memberCount: 1,
roots: [
{
id: 'game-root-1',
title: '根作品',
summary: '根',
description: '',
category: '动作',
tags: [],
coverColor: '#d77a51',
icon: '✦',
author: { id: 'author-1', name: '测试作者' },
deviceSupport: { desktop: true, mobile: true, touch: true },
status: 'published',
currentVersion: null,
playCount: 1,
createdAt: '2026-09-18T00:00:00.000Z',
},
],
});
gameDistributionMock.getGameLineage.mockResolvedValue({
rootGameId: 'game-root-1',
root: null,
nodes: [],
truncated: false,
});
render(
<PlatformEntryFlowShellImpl
selectionStage="game-theme"
setSelectionStage={vi.fn()}
/>,
);
expect(await screen.findByRole('heading', { name: '精选共创' })).toBeTruthy();
expect(screen.getByText('根作品')).toBeTruthy();
expect(gameDistributionMock.getTheme).toHaveBeenCalledWith('theme-1');
// 树复用既有族谱查询:按根请求一次。
expect(gameDistributionMock.getGameLineage).toHaveBeenCalledWith(
'game-root-1',
);
});
});