约束 UI 编辑器保存与生成并发
提取按钮文案条件并在保存、生成及保存并返回入口统一互斥状态 要求生成基于已加载的持久化 revision,并同步更新会话边界文档
This commit is contained in:
@@ -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,
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,3 +14,5 @@
|
||||
- `save`:加载 / revision 状态、脏状态、保存警告和保存意图。
|
||||
|
||||
预览树在会话边界归一化为 `UITree | null`:尚未选择界面图、正在加载或尚未识别树时均以 `null` 表示,不能把 `Array.find` 的 `undefined` 传播到视图接口。
|
||||
|
||||
保存与代码生成共享同一份持久化 State/revision。会话层在保存或生成进行期间互斥拦截,且代码生成必须基于已加载的持久化 revision;视图层的保存按钮和“保存并返回”按钮同步遵守该互斥状态。
|
||||
|
||||
Reference in New Issue
Block a user