feat(admin): 管理后台 - 统一桌面端信息架构与视觉规范

This commit is contained in:
HANG LU
2026-08-30 05:05:46 +08:00
parent d89f170a08
commit 10cebf8c69
32 changed files with 17070 additions and 1860 deletions

View File

@@ -1,4 +1,5 @@
export const WORKSPACE_SIDEBAR_STORAGE_KEY = "infinite-canvas:workspace-sidebar-collapsed";
export const WORKSPACE_SIDEBAR_CHANGE_EVENT = "workspace:sidebar-collapsed-change";
type WorkspaceSidebarStorage = Pick<Storage, "getItem" | "setItem">;
@@ -27,3 +28,21 @@ export function writeWorkspaceSidebarCollapsed(collapsed: boolean, storage?: Wor
// localStorage 不可用时保留当前内存状态,不能阻断侧栏交互。
}
}
export function publishWorkspaceSidebarCollapsed(collapsed: boolean) {
writeWorkspaceSidebarCollapsed(collapsed);
window.dispatchEvent(new CustomEvent(WORKSPACE_SIDEBAR_CHANGE_EVENT, { detail: { collapsed } }));
}
export function subscribeWorkspaceSidebarCollapsed(onChange: (collapsed: boolean) => void) {
const handleChange = (event: Event) => onChange(Boolean((event as CustomEvent<{ collapsed?: boolean }>).detail?.collapsed));
const handleStorage = (event: StorageEvent) => {
if (event.key === WORKSPACE_SIDEBAR_STORAGE_KEY) onChange(event.newValue === "1");
};
window.addEventListener(WORKSPACE_SIDEBAR_CHANGE_EVENT, handleChange);
window.addEventListener("storage", handleStorage);
return () => {
window.removeEventListener(WORKSPACE_SIDEBAR_CHANGE_EVENT, handleChange);
window.removeEventListener("storage", handleStorage);
};
}