feat(projects): 工作台小组件设计
This commit is contained in:
@@ -5,7 +5,7 @@ import { buildDefaultLayout } from './workbench-layout-default';
|
||||
import type { LayoutStorage } from './layout-storage';
|
||||
import { LocalStorageAdapter } from './layout-storage-local';
|
||||
import { reconcileLayout } from './workbench-layout-reconcile';
|
||||
import type { WorkbenchLayout } from './workbench-layout-types';
|
||||
import { WORKBENCH_LAYOUT_VERSION, type WorkbenchLayout } from './workbench-layout-types';
|
||||
|
||||
export type WorkbenchMode = 'normal' | 'editing';
|
||||
|
||||
@@ -28,7 +28,16 @@ export function useWorkbenchLayout(options: UseWorkbenchLayoutOptions) {
|
||||
|
||||
async function load() {
|
||||
const fromStorage = await storage.load(options.userId);
|
||||
layout.value = reconcileLayout(fromStorage ?? buildDefaultLayout(getAllModules()), getAllModules());
|
||||
if (fromStorage && fromStorage.version === WORKBENCH_LAYOUT_VERSION) {
|
||||
layout.value = reconcileLayout(fromStorage, getAllModules());
|
||||
return;
|
||||
}
|
||||
// 版本不匹配 / 无存储:走新默认布局;旧 settings 迁移过来,避免用户偏好(如 shortcut.menuKeys)被 version bump 清空
|
||||
const fresh = buildDefaultLayout(getAllModules());
|
||||
if (fromStorage?.settings) {
|
||||
fresh.settings = { ...fromStorage.settings };
|
||||
}
|
||||
layout.value = fresh;
|
||||
}
|
||||
|
||||
const persist = useDebounceFn(async () => {
|
||||
|
||||
Reference in New Issue
Block a user