diff --git a/apps/ai-game-creator-shell/src/view/project-development/export/state/useXhsMinitoolExport.ts b/apps/ai-game-creator-shell/src/view/project-development/export/state/useXhsMinitoolExport.ts index 571241657..53169172e 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/export/state/useXhsMinitoolExport.ts +++ b/apps/ai-game-creator-shell/src/view/project-development/export/state/useXhsMinitoolExport.ts @@ -191,8 +191,13 @@ export function useXhsMinitoolExport({ setNotice(''); setFailure(null); try { - await runXhsMinitoolExportBuild(invoke, projectPath); - setNotice(`已重新产出 ${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}`); + const result = await runXhsMinitoolExportBuild(invoke, projectPath); + // 打包脚本会把 zip 的条目数与体积打在输出尾部,正是用户上传前要核对的数字。 + setNotice( + [`已重新产出 ${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}`, result.outputTail] + .filter((line) => line.trim() !== '') + .join('\n'), + ); } catch (error) { const structured = asXhsMinitoolFailure(error); if (structured) setFailure(failureState(structured)); diff --git a/apps/ai-game-creator-shell/src/view/project-development/export/tabs/xiaohongshu/ArtifactsPane.tsx b/apps/ai-game-creator-shell/src/view/project-development/export/tabs/xiaohongshu/ArtifactsPane.tsx index b1d91a496..1cd649d8a 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/export/tabs/xiaohongshu/ArtifactsPane.tsx +++ b/apps/ai-game-creator-shell/src/view/project-development/export/tabs/xiaohongshu/ArtifactsPane.tsx @@ -146,7 +146,10 @@ export function ArtifactsPane({ ) : null} {downloadNotice || minitool.notice ? ( -

+

{downloadNotice || minitool.notice}

) : null} diff --git a/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx b/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx index 910a8b4ea..7e1e6a4ef 100644 --- a/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx +++ b/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx @@ -273,6 +273,38 @@ describe('状态 hook', () => { ); }); + it('导出把打包脚本的输出尾部一并报给用户', async () => { + const invoke = vi.fn(async (command: string) => { + if (command === 'read_xhs_minitool_export') { + return { form: FORM, hasScript: true, contentHash: CONTENT_HASH }; + } + return { + outputTail: + 'zip 已生成:.export/xhs-minitool.zip(3 个条目,0.42 MiB)', + }; + }); + installTauriRuntime({ core: { invoke } }); + const { result } = renderHook(() => + useXhsMinitoolExport({ + enabled: true, + projectPath: PROJECT_PATH, + submitTurn: vi.fn(async () => true), + }), + ); + await waitFor(() => expect(result.current.form).toEqual(FORM)); + + await act(async () => { + await result.current.runExport(); + }); + + expect(invoke).toHaveBeenCalledWith('run_xhs_minitool_export_build', { + projectPath: PROJECT_PATH, + }); + expect(result.current.notice).toContain('.export/xhs-minitool.zip'); + expect(result.current.notice).toContain('3 个条目'); + expect(result.current.running).toBe(false); + }); + it('适配把指令当成一条用户消息交给同一个会话', async () => { const submitTurn = vi.fn(async () => true); installTauriRuntime({