feat: 优化web

This commit is contained in:
2026-04-23 18:58:13 +08:00
commit 544a2f3428
160 changed files with 27327 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
'use client';
import { usePathname } from 'next/navigation';
import type { MenuNode } from '@/lib/api/types/menu';
import {
isLayoutOverviewNode,
NavTreeItem,
layoutNavRootsFromApi,
} from '@/components/layout/nav-shared';
export function SidebarNav(props: {
items: MenuNode[];
loading: boolean;
error: string | null;
authed: boolean;
onInternalNavigate?: () => void;
onMenuNavigate?: (path: string, title: string) => void;
}) {
const pathname = usePathname() || '';
if (!props.authed) {
return <div className="px-3 py-4 text-sm text-neutral-500"></div>;
}
if (props.loading) {
return <div className="px-3 py-4 text-sm text-neutral-500"></div>;
}
if (props.error) {
const roots = layoutNavRootsFromApi([]);
return (
<nav className="space-y-0.5 px-3 pb-4 py-1" aria-label="侧栏导航">
{roots.map((n) => (
<NavTreeItem
key={n.id}
node={n}
depth={0}
pathname={pathname}
onInternalNavigate={props.onInternalNavigate}
onMenuNavigate={props.onMenuNavigate}
/>
))}
<div className="px-2 py-2 text-sm text-red-600" title={props.error}>
</div>
</nav>
);
}
const roots = layoutNavRootsFromApi(props.items);
const onlyOverview = roots.length === 1 && isLayoutOverviewNode(roots[0]);
return (
<nav className="space-y-0.5 px-3 pb-4 py-1" aria-label="侧栏导航">
{roots.map((n) => (
<NavTreeItem
key={n.id}
node={n}
depth={0}
pathname={pathname}
onInternalNavigate={props.onInternalNavigate}
onMenuNavigate={props.onMenuNavigate}
/>
))}
{onlyOverview ? <div className="px-2 py-2 text-sm text-neutral-500"></div> : null}
</nav>
);
}