From 26e8ed794ddf5c7c975aa7507874b72968ad7c3f Mon Sep 17 00:00:00 2001 From: selfrelease Date: Mon, 31 Aug 2026 14:32:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=8C=89=E9=92=AE(=E6=A1=8C=E9=9D=A2Header?= =?UTF-8?q?=20+=20=E7=A7=BB=E5=8A=A8=E7=AB=AF"=E6=88=91"=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Header: 桌面端右上角退出图标,带确认弹窗 - Me页面: 底部退出登录按钮,带确认弹窗 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- web2/src/components/layout/Header.tsx | 43 ++++++++++++++++++++++++--- web2/src/pages/Me.tsx | 42 +++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/web2/src/components/layout/Header.tsx b/web2/src/components/layout/Header.tsx index 02e62e0..104edeb 100644 --- a/web2/src/components/layout/Header.tsx +++ b/web2/src/components/layout/Header.tsx @@ -1,20 +1,33 @@ /** 顶部 Header(h-14 sticky) - * 桌面:显示当前页面标题 + 用户信息 + * 桌面:显示当前页面标题 + 用户信息 + 退出按钮 * 移动:显示 Logo + 通知铃铛 */ -import { useLocation } from 'react-router-dom' -import { Bell } from 'lucide-react' +import { useState } from 'react' +import { useLocation, useNavigate } from 'react-router-dom' +import { Bell, LogOut } from 'lucide-react' import { HEADER_TITLES } from '@/lib/nav-config' -import { getName } from '@/lib/auth' +import { getName, clearAuth } from '@/lib/auth' +import { + Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, +} from '@/components/ui/dialog' +import { Button } from '@/components/ui/button' export function Header() { const { pathname } = useLocation() + const navigate = useNavigate() const name = getName() + const [confirmLogout, setConfirmLogout] = useState(false) + // 匹配标题(支持子路由,取最长匹配) const title = Object.entries(HEADER_TITLES) .filter(([p]) => pathname === p || (p !== '/' && pathname.startsWith(p))) .sort((a, b) => b[0].length - a[0].length)[0]?.[1] || '左右 BossAi' + const handleLogout = () => { + clearAuth() + navigate('/login') + } + return (
{/* 移动端 Logo */} @@ -36,6 +49,28 @@ export function Header() { {name && ( {name} )} + {/* 退出按钮(桌面) */} + + + {/* 退出确认弹窗 */} + + + + 退出登录 + 确定要退出当前账号吗? + + + + + + +
) } diff --git a/web2/src/pages/Me.tsx b/web2/src/pages/Me.tsx index 7c8acba..a61d7c5 100644 --- a/web2/src/pages/Me.tsx +++ b/web2/src/pages/Me.tsx @@ -1,13 +1,25 @@ -/** 移动端"我"聚合页:头像占位+入口列表 */ -import { NavLink } from 'react-router-dom' +/** 移动端"我"聚合页:头像占位+入口列表+退出 */ +import { useState } from 'react' +import { NavLink, useNavigate } from 'react-router-dom' import { User, History, BookOpen, Settings as SettingsIcon, ChevronRight, - Scale, TrendingUp, Heart, ShieldCheck, FileText, Users, + Scale, TrendingUp, Heart, ShieldCheck, FileText, Users, LogOut, } from 'lucide-react' -import { getName } from '@/lib/auth' +import { getName, clearAuth } from '@/lib/auth' +import { + Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, +} from '@/components/ui/dialog' +import { Button } from '@/components/ui/button' export function Me() { + const navigate = useNavigate() const name = getName() + const [confirmLogout, setConfirmLogout] = useState(false) + + const handleLogout = () => { + clearAuth() + navigate('/login') + } const brainTrust = [ { path: '/legal', label: '法务参谋', icon: Scale }, { path: '/decisions', label: '经营决策', icon: TrendingUp }, @@ -61,6 +73,28 @@ export function Me() { ))} + + {/* 退出登录 */} + + + + + + 退出登录 + 确定要退出当前账号吗? + + + + + + + ) }