From 071998fee9641ee86cc7b729bdc319e9164ed424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 3 Sep 2026 13:14:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E4=B8=8A=E9=99=90=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为撤销历史容量 100 增加命名常量,便于理解和调节内存权衡 --- .../src/features/ui-editor/useUiEditorState.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/src/features/ui-editor/useUiEditorState.ts b/apps/ai-game-creator-shell/src/features/ui-editor/useUiEditorState.ts index f15be0431..2ef8569e5 100644 --- a/apps/ai-game-creator-shell/src/features/ui-editor/useUiEditorState.ts +++ b/apps/ai-game-creator-shell/src/features/ui-editor/useUiEditorState.ts @@ -33,6 +33,8 @@ export const EMPTY_UI_EDITOR_STATE: State = { font_assets: {}, }; +const MAX_HISTORY_LENGTH = 100; + export type UiEditorOperationFailureReason = | 'locked' | 'duplicate' @@ -567,7 +569,7 @@ export function useUiEditorState(initialState: State = EMPTY_UI_EDITOR_STATE) { before: cloneState(current), after: cloneState(nextState), }); - if (undoStackRef.current.length > 100) { + if (undoStackRef.current.length > MAX_HISTORY_LENGTH) { undoStackRef.current.shift(); } redoStackRef.current = [];