From 463341c4bd850a1278c732089ab6e97f30667981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 5 Oct 2026 16:59:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E5=8A=9F=E5=90=8E?= =?UTF-8?q?=E6=8A=8A=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=B0=BE=E9=83=A8=E6=8A=A5=E7=BB=99=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useXhsMinitoolExport 的导出成功提示改为「已重新产出 .export/xhs-minitool.zip」加宿主的构建输出尾部:打包脚本会把 zip 的条目数与体积打在那里,正是上传前要核对的数字。 - ArtifactsPane 的状态行改为保留换行,多行输出不再挤成一行。 - 新增一例前端用例:导出调用只带 projectPath,成功后 notice 同时含产物路径与脚本输出尾部。 --- .../export/state/useXhsMinitoolExport.ts | 9 ++++-- .../export/tabs/xiaohongshu/ArtifactsPane.tsx | 5 ++- .../tests/xhsMinitoolExport.test.tsx | 32 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) 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({