feat(*): 创作平台 - 升级短剧分镜工作流并完善模型计费与界面状态
This commit is contained in:
@@ -4,6 +4,7 @@ import { useLocation, useNavigate } from "react-router";
|
||||
import { ModelSetupGuide } from "@/components/layout/model-setup-guide";
|
||||
import { WorkspaceCommandPalette } from "@/components/layout/workspace-command-palette";
|
||||
import { WorkspaceSidebarNav } from "@/components/layout/workspace-sidebar-nav";
|
||||
import { readWorkspaceSidebarCollapsed, writeWorkspaceSidebarCollapsed } from "@/components/layout/workspace-sidebar-state";
|
||||
import { WorkspaceTopBar } from "@/components/layout/workspace-top-bar";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { isSpatialWorkbenchPath } from "@/lib/workspace-routes";
|
||||
@@ -12,7 +13,7 @@ export function AppWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
const { pathname } = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [mobileSidebarExpanded, setMobileSidebarExpanded] = useState(false);
|
||||
const [desktopSidebarCollapsed, setDesktopSidebarCollapsed] = useState(false);
|
||||
const [desktopSidebarCollapsed, setDesktopSidebarCollapsed] = useState(readWorkspaceSidebarCollapsed);
|
||||
const [paletteOpen, setPaletteOpen] = useState(false);
|
||||
|
||||
const hideChrome = pathname.startsWith("/admin") || /^\/canvas\/[^/]+/.test(pathname);
|
||||
@@ -27,7 +28,16 @@ export function AppWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
setMobileSidebarExpanded((current) => !current);
|
||||
return;
|
||||
}
|
||||
setDesktopSidebarCollapsed((current) => !current);
|
||||
setDesktopSidebarCollapsed((current) => {
|
||||
const next = !current;
|
||||
writeWorkspaceSidebarCollapsed(next);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const expandDesktopSidebar = () => {
|
||||
setDesktopSidebarCollapsed(false);
|
||||
writeWorkspaceSidebarCollapsed(false);
|
||||
};
|
||||
|
||||
const handleNavClick = () => {
|
||||
@@ -75,7 +85,7 @@ export function AppWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
collapsed={desktopSidebarCollapsed}
|
||||
onNavigate={handleNavClick}
|
||||
onOpenSearch={() => setPaletteOpen(true)}
|
||||
onExpand={() => setDesktopSidebarCollapsed(false)}
|
||||
onExpand={expandDesktopSidebar}
|
||||
/>
|
||||
</aside>
|
||||
) : null}
|
||||
|
||||
@@ -1 +1,29 @@
|
||||
export const WORKSPACE_SIDEBAR_STORAGE_KEY = "infinite-canvas:workspace-sidebar-collapsed";
|
||||
|
||||
type WorkspaceSidebarStorage = Pick<Storage, "getItem" | "setItem">;
|
||||
|
||||
function workspaceSidebarStorage(storage?: WorkspaceSidebarStorage) {
|
||||
if (storage) return storage;
|
||||
if (typeof window === "undefined") return undefined;
|
||||
try {
|
||||
return window.localStorage;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function readWorkspaceSidebarCollapsed(storage?: WorkspaceSidebarStorage) {
|
||||
try {
|
||||
return workspaceSidebarStorage(storage)?.getItem(WORKSPACE_SIDEBAR_STORAGE_KEY) === "1";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeWorkspaceSidebarCollapsed(collapsed: boolean, storage?: WorkspaceSidebarStorage) {
|
||||
try {
|
||||
workspaceSidebarStorage(storage)?.setItem(WORKSPACE_SIDEBAR_STORAGE_KEY, collapsed ? "1" : "0");
|
||||
} catch {
|
||||
// localStorage 不可用时保留当前内存状态,不能阻断侧栏交互。
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user