From 7fb66927930322f9a81dce6730156d0e9f967cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 1 Sep 2026 15:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A6=E6=9D=9F=20UI=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=BF=9D=E5=AD=98=E4=B8=8E=E7=94=9F=E6=88=90=E5=B9=B6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提取按钮文案条件并在保存、生成及保存并返回入口统一互斥状态 要求生成基于已加载的持久化 revision,并同步更新会话边界文档 --- .../src/view/ui-editor/index.tsx | 17 ++++++++++++----- .../src/view/ui-editor/useUiEditorPage.ts | 3 +++ ...【前端架构】UI编辑会话模块边界-2026-08-19.md | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/index.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/index.tsx index d4c470643..515ba744c 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/index.tsx +++ b/apps/ai-game-creator-shell/src/view/ui-editor/index.tsx @@ -22,6 +22,12 @@ import { useUiEditorSession, } from './useUiEditorPage'; +function saveAndGenerateLabel(isSaving: boolean, isGenerating: boolean) { + if (isSaving) return '保存中…'; + if (isGenerating) return '生成中…'; + return '保存并生成代码'; +} + export default function UiEditorPage({ projectPath, resourceId, @@ -146,6 +152,7 @@ export default function UiEditorPage({ className="rounded-lg bg-orange-600 px-3 py-1.5 text-sm font-semibold text-white disabled:opacity-60" disabled={ session.save.isSaving || + session.save.isGenerating || session.save.isLoading || Boolean(session.save.loadError) || session.save.persistedRevision === null || @@ -168,11 +175,10 @@ export default function UiEditorPage({ } onClick={requestSaveAndGenerate} > - {session.save.isSaving - ? '保存中…' - : session.save.isGenerating - ? '生成中…' - : '保存并生成代码'} + {saveAndGenerateLabel( + session.save.isSaving, + session.save.isGenerating, + )} @@ -275,6 +281,7 @@ export default function UiEditorPage({ className="rounded-lg bg-orange-600 px-3 py-2 text-xs font-semibold text-white disabled:opacity-60" disabled={ session.save.isSaving || + session.save.isGenerating || Boolean(session.save.loadError) || session.save.persistedRevision === null || session.save.isLocked 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 f70feaa56..06adc9a8f 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 @@ -1039,6 +1039,7 @@ export function useUiEditorSession( if ( !resourceId || isSaving || + isGenerating || isLoading || loadError || persistedRevision === null || @@ -1077,8 +1078,10 @@ export function useUiEditorSession( if ( !resourceId || isGenerating || + isSaving || isLoading || loadError || + persistedRevision === null || editor.isLocked ) { return null; diff --git a/docs/technical/【前端架构】UI编辑会话模块边界-2026-08-19.md b/docs/technical/【前端架构】UI编辑会话模块边界-2026-08-19.md index 84d8d2694..33d14aea0 100644 --- a/docs/technical/【前端架构】UI编辑会话模块边界-2026-08-19.md +++ b/docs/technical/【前端架构】UI编辑会话模块边界-2026-08-19.md @@ -14,3 +14,5 @@ - `save`:加载 / revision 状态、脏状态、保存警告和保存意图。 预览树在会话边界归一化为 `UITree | null`:尚未选择界面图、正在加载或尚未识别树时均以 `null` 表示,不能把 `Array.find` 的 `undefined` 传播到视图接口。 + +保存与代码生成共享同一份持久化 State/revision。会话层在保存或生成进行期间互斥拦截,且代码生成必须基于已加载的持久化 revision;视图层的保存按钮和“保存并返回”按钮同步遵守该互斥状态。