feat: complete login and user management flow

This commit is contained in:
hectorzhao
2026-07-02 16:28:48 +08:00
parent 9c639d54b9
commit e26d8324c3
22 changed files with 1320 additions and 300 deletions
+10 -2
View File
@@ -12,7 +12,8 @@ import {
Search,
Sparkles,
} from 'lucide-react';
import { NavLink, Outlet } from 'react-router-dom';
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
import { clearSession } from '@/api/session';
export type ShellNavItem = {
label: string;
@@ -37,6 +38,7 @@ type AppShellProps = {
title: string;
subtitle: string;
workspaceName: string;
loginPath: string;
userName: string;
userRole: string;
navSections: ShellNavSection[];
@@ -47,6 +49,7 @@ export function AppShell({
title,
subtitle,
workspaceName,
loginPath,
userName,
userRole,
navSections,
@@ -56,6 +59,7 @@ export function AppShell({
const [closedSections, setClosedSections] = useState<Record<string, boolean>>({});
const [userMenuOpen, setUserMenuOpen] = useState(false);
const [noticeOpen, setNoticeOpen] = useState(false);
const navigate = useNavigate();
const ToggleIcon = collapsed ? PanelLeftOpen : PanelLeftClose;
const auditTotal = useMemo(
() => auditNotifications.reduce((sum, item) => sum + item.count, 0),
@@ -205,7 +209,11 @@ export function AppShell({
<KeyRound size={16} />
</button>
<button onClick={() => setUserMenuOpen(false)} role="menuitem" type="button">
<button onClick={() => {
clearSession();
setUserMenuOpen(false);
navigate(loginPath, { replace: true });
}} role="menuitem" type="button">
<LogOut size={16} />
退
</button>