提取编辑器历史上限常量
为撤销历史容量 100 增加命名常量,便于理解和调节内存权衡
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user