模板库假数据注入改为 Cargo feature 控制
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 5m37s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 4m59s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m50s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 4m58s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 4m36s
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m56s
Project CI / Frontend tests (pull_request) Failing after 4m59s
Project CI / AI game creator shell web tests (pull_request) Failing after 4m56s
Project CI / Native shell tests (pull_request) Successful in 8m58s

- 新增 feature template-library-fixtures(默认关闭):关闭时 apply_template_library_fixtures 为恒等透传,正式产物不含注入分支
- 注入实现下沉为 cfg 模块:按真实清单循环补齐假数据(唯一 id/标题/封面地址,标签追加批次分组,安装态 1/3 混合),条数由 AGC_TEMPLATE_LIBRARY_SYNTHETIC_COUNT 控制(默认 1000)
- 两种编译模式各补一条用例:默认构建必须恒等透传,开启 feature 必须补齐到配置条数;另补假数据识别/计数解析单测
- 前端补 1000 条渲染回归:1000 张卡片渲染 + 已安装/标签/关键词过滤数量自洽
- 技术方案补「本地压测假数据注入」与 1000 条实测结论(标签条膨胀、一次性渲染 1000 卡片与封面请求需后续收口)
This commit is contained in:
kdletters
2026-09-17 15:09:02 +08:00
parent a9d5ac0931
commit 19e9dea45c
4 changed files with 270 additions and 0 deletions
@@ -75,6 +75,32 @@ templates/
## 验收与验证
## 本地压测假数据注入(feature 控制)
模板库的数据源在 Rust 侧(清单校验、安装状态、下载与建项目都在这里),TS 只消费快照做渲染,所以假数据注入也放在 Rust 侧,走与真实完全一致的链路。
- 开关:Cargo feature `template-library-fixtures`(**默认关闭**)。关闭时 `apply_template_library_fixtures` 是恒等透传,正式产物里不存在注入分支,并有单测保证这一点。
- 条数:环境变量 `AGC_TEMPLATE_LIBRARY_SYNTHETIC_COUNT`(默认 1000;`0` 表示不注入;上限 20000)。
- 假数据特征:真实条目保留在最前,其余按真实条目循环复制;`id`/标题唯一,封面地址追加 `?synthetic=N`(强制逐张请求,模拟“每个模板各自封面”);标签追加 `批次-00..19`;安装态按 1/3 混合。
- 运行方式:
```bash
# 本机 dev 客户端(保留 Windows 默认 feature)
AGC_DEV_CARGO_FEATURES=cocos-editor-execute,template-library-fixtures npm run dev
# 直接跑二进制
cargo run --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml --features template-library-fixtures
# 覆盖条数
AGC_TEMPLATE_LIBRARY_SYNTHETIC_COUNT=300 AGC_DEV_CARGO_FEATURES=template-library-fixtures npm run dev
```
两种编译模式都要过模板库单测:默认构建跑「恒等透传」用例,`--features template-library-fixtures` 跑「补齐到配置条数」用例。
### 1000 条实测结论
- 页面能正常渲染 1000 张卡片(头部显示「共 1000 个模板 · 已下载 335 个」),并且滚动容器生效(窗口高度压到 430px 时右侧出现滚动条,页面内容被裁切而不是溢出到窗口外)。
- 需要后续收口的两点(本次未改):① 标签筛选条随库量膨胀——1000 条时聚合出 35 个标签、占三行;② 一次性渲染 1000 个卡片节点并触发 1000 次封面请求。建议标签只展示 Top N + 「更多」,卡片列表加分页或虚拟滚动。
- 前端回归:1000 条渲染 + 已安装过滤(334)/标签过滤(50)/关键词过滤数量自洽,见 `apps/ai-game-creator-shell/tests/templateLibraryView.test.tsx`。
```bash
# 模板库单测(清单校验、键安全、解压路径逃逸、安装与建项目)
cargo test --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml --bin genarrative-ai-game-creator-shell template_library