From 274b77131920219c840b30f35c5532ea3f300d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 20 Aug 2026 15:47:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20UI=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 普通保存异常统一显示固定安全摘要 保留保存冲突专用提示并补充回归测试 Co-authored-by: Junie --- .../src/view/ui-editor/useUiEditorPage.ts | 4 +-- .../tests/uiEditorPage.test.ts | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts b/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts index da5894660..e25984e5b 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts +++ b/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts @@ -1040,8 +1040,8 @@ export function useUiEditorSession( setSavedStateSignature(snapshotSignature); } return true; - } catch (error) { - setSaveError(error instanceof Error ? error.message : String(error)); + } catch { + setSaveError('保存失败,请稍后重试。'); return false; } finally { setIsSaving(false); diff --git a/apps/ai-game-creator-shell/tests/uiEditorPage.test.ts b/apps/ai-game-creator-shell/tests/uiEditorPage.test.ts index 2bfe26d0f..667e030f0 100644 --- a/apps/ai-game-creator-shell/tests/uiEditorPage.test.ts +++ b/apps/ai-game-creator-shell/tests/uiEditorPage.test.ts @@ -549,6 +549,9 @@ describe('UiEditorPage', () => { fireEvent.click(await screen.findByRole('button', { name: '仍然保存' })); expect((await screen.findByRole('alert')).textContent).toContain( + '保存失败,请稍后重试。', + ); + expect(screen.getByRole('alert').textContent).not.toContain( '临时存储不可用', ); expect(screen.getByRole('button', { name: '保存' })).toBeTruthy(); @@ -558,4 +561,28 @@ describe('UiEditorPage', () => { fireEvent.click(await screen.findByRole('button', { name: '仍然保存' })); expect(stateStore.save).toHaveBeenCalledTimes(2); }); + + it('keeps the dedicated message for a save conflict', async () => { + const stateStore: UiDesignStateStore = { + load: vi.fn().mockResolvedValue(structuredClone(EMPTY_SNAPSHOT)), + save: vi.fn().mockResolvedValue({ + status: 'conflict', + currentRevision: 1, + }), + }; + render( + createElement(UiEditorPage, { + projectPath: '/tmp/ui-editor', + resourceId: 'ui-resource', + stateStore, + }), + ); + + fireEvent.click(await screen.findByRole('button', { name: '保存' })); + fireEvent.click(await screen.findByRole('button', { name: '仍然保存' })); + + expect((await screen.findByRole('alert')).textContent).toContain( + '资源已在别处更新;请重新加载后再保存。', + ); + }); });