导出成功后把打包脚本的输出尾部报给用户
- useXhsMinitoolExport 的导出成功提示改为「已重新产出 .export/xhs-minitool.zip」加宿主的构建输出尾部:打包脚本会把 zip 的条目数与体积打在那里,正是上传前要核对的数字。 - ArtifactsPane 的状态行改为保留换行,多行输出不再挤成一行。 - 新增一例前端用例:导出调用只带 projectPath,成功后 notice 同时含产物路径与脚本输出尾部。
This commit is contained in:
+7
-2
@@ -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));
|
||||
|
||||
+4
-1
@@ -146,7 +146,10 @@ export function ArtifactsPane({
|
||||
) : null}
|
||||
|
||||
{downloadNotice || minitool.notice ? (
|
||||
<p role="status" className="text-xs text-[#6f5848]">
|
||||
<p
|
||||
role="status"
|
||||
className="whitespace-pre-wrap break-all text-xs text-[#6f5848]"
|
||||
>
|
||||
{downloadNotice || minitool.notice}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user