提取编辑器历史上限常量

为撤销历史容量 100 增加命名常量,便于理解和调节内存权衡
This commit is contained in:
2026-09-03 13:14:43 +08:00
parent d60d93a327
commit 071998fee9
@@ -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 = [];