refactor(profile): split view/container and update nav state
Some checks failed
Client CMS Check Build (NixCN CMS) TeamCity build failed
Backend Check Build (NixCN CMS) TeamCity build finished

Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
2026-01-31 18:30:34 +08:00
parent 635b0fbb73
commit 65d493b91b
20 changed files with 173 additions and 73 deletions

View File

@@ -1,13 +1,23 @@
import { createFileRoute, Outlet } from '@tanstack/react-router';
import { createFileRoute, Outlet, useRouterState } from '@tanstack/react-router';
import { AppSidebar } from '@/components/sidebar/app-sidebar';
import { SiteHeader } from '@/components/site-header';
import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar';
import { navData } from '@/lib/navData';
export const Route = createFileRoute('/_workbenchLayout')({
component: RouteComponent,
});
function RouteComponent() {
const pathname = useRouterState({ select: state => state.location.pathname });
const allNavItems = [...navData.navMain, ...navData.navSecondary];
const title
= allNavItems.find(item =>
item.url === '/'
? pathname === '/'
: pathname.startsWith(item.url),
)?.title ?? '工作台';
return (
<SidebarProvider
style={
@@ -17,9 +27,9 @@ function RouteComponent() {
} as React.CSSProperties
}
>
<AppSidebar variant="inset" />
<AppSidebar navData={navData} variant="inset" />
<SidebarInset>
<SiteHeader />
<SiteHeader title={title} />
<div className="flex flex-1 flex-col">
<div className="@container/main flex flex-1 flex-col gap-2">
<Outlet />