diff --git a/apps/ai-game-creator-shell/src/services/gameDistributionPublish.ts b/apps/ai-game-creator-shell/src/services/gameDistributionPublish.ts index 75c581f68..7b0e44e3b 100644 --- a/apps/ai-game-creator-shell/src/services/gameDistributionPublish.ts +++ b/apps/ai-game-creator-shell/src/services/gameDistributionPublish.ts @@ -175,9 +175,11 @@ function normalizeMetadata( // 封面校验不在这里:`coverObjectKey === null` 表示用草稿 `coverPath`,只有宿主读到 // `.export/taonier.json` 后才能判断「草稿也没有封面」,所以由原生发布命令按统一文案失败关闭。 const coverObjectKey = (metadata?.coverObjectKey ?? '').trim() || null; - const screenshots = (metadata?.screenshots ?? []) - .map((screenshot) => (screenshot === null ? null : screenshot.trim())) - .filter((screenshot) => screenshot !== ''); + // 槽位顺序与最终截图一一对应:空串/纯空白按「没有沿用值」归一成 `null`(消费草稿本地图), + // 不能直接 filter 掉,否则后面的槽位会整体前移,与草稿里的截图顺序错位。 + const screenshots = (metadata?.screenshots ?? []).map((screenshot) => + screenshot === null || screenshot.trim() === '' ? null : screenshot.trim(), + ); if (screenshots.length > MAX_AGC_GAME_SCREENSHOTS) { throw new Error('游戏截图最多 6 张'); } diff --git a/apps/ai-game-creator-shell/tests/gameDistributionPublish.test.ts b/apps/ai-game-creator-shell/tests/gameDistributionPublish.test.ts index 9b2e3ed78..514c5f708 100644 --- a/apps/ai-game-creator-shell/tests/gameDistributionPublish.test.ts +++ b/apps/ai-game-creator-shell/tests/gameDistributionPublish.test.ts @@ -159,7 +159,7 @@ describe('Rust 发布 facade', () => { }); }); - test('截图槽位里的 null 与沿用 objectKey 原样透传', async () => { + test('截图槽位里的 null、沿用 objectKey 与空串按序透传', async () => { const { invoke, calls } = installNativeInvoke((command) => { if (command === 'publish_local_project_game') return PUBLISH_RESULT; throw new Error(`未预期的命令:${command}`); @@ -172,7 +172,7 @@ describe('Rust 发布 facade', () => { manifest: MANIFEST, metadata: { coverObjectKey: null, - // 第 2 张沿用线上、其余从草稿本地图按序补齐;空串在归一化时被丢弃。 + // 第 2 张沿用线上,其余用草稿本地图;空串归一成 `null` 保留槽位顺序,不能被丢掉。 screenshots: [null, 'generated/shot-online.png', null, ' '], }, versionNumber: 4, @@ -180,7 +180,7 @@ describe('Rust 发布 facade', () => { expect(calls[0]?.args).toMatchObject({ metadata: { - screenshots: [null, 'generated/shot-online.png', null], + screenshots: [null, 'generated/shot-online.png', null, null], }, }); });