From 2ca98cccfb68b5ff47dd59883e5ed7763e6327ab Mon Sep 17 00:00:00 2001 From: fly6516 Date: Sat, 17 May 2025 09:57:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(store):=20=E9=87=8D=E6=9E=84=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E9=85=8D=E7=BD=AE=E7=8A=B6=E6=80=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 useEditorConfigStore 的实现 - 修改了 resetConfig 的实现,使用 state.defaultConfig 作为默认配置- 重命名 EditorConfigState为 EditorConfigState2 --- src/lib/store.ts | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/lib/store.ts b/src/lib/store.ts index e5b8efe..267b1ea 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -32,31 +32,11 @@ export const useEditorConfigStore = create((set) => { resetConfig: () => set((state) => { localStorage.removeItem('editorConfig'); return { config: state.defaultConfig }; - }), + }) }; }); -export interface EditorConfigState { +interface EditorConfigState2 { config: any; setConfig: (config: any) => void; } - -export const useEditorConfigStore = create((set) => { - // 从localStorage读取保存的配置 - let savedConfig = null; - if (typeof window !== 'undefined') { - savedConfig = localStorage.getItem('editorConfig'); - } - - const parsedConfig = savedConfig ? JSON.parse(savedConfig) : {}; - - return { - config: parsedConfig, - setConfig: (config) => { - if (typeof window !== 'undefined') { - localStorage.setItem('editorConfig', JSON.stringify(config)); - } - set({ config }); - } - }; -});