From 0f8ea428a81f940d302326e4b409bfae73fc98fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Mon, 31 Mar 2025 10:40:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=AE=A2=E5=AE=9D=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/app/profile/page.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Cunkebao/app/profile/page.tsx b/Cunkebao/app/profile/page.tsx index 360210b1..32b02d09 100644 --- a/Cunkebao/app/profile/page.tsx +++ b/Cunkebao/app/profile/page.tsx @@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { useRouter } from "next/navigation" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" +import { useAuth } from "@/app/components/AuthProvider" const menuItems = [ { href: "/devices", label: "设备管理" }, @@ -17,12 +18,12 @@ const menuItems = [ export default function ProfilePage() { const router = useRouter() - const [isAuthenticated, setIsAuthenticated] = useState(true) // 模拟认证状态 + const { isAuthenticated, user, logout } = useAuth() const [showLogoutDialog, setShowLogoutDialog] = useState(false) - const [accountId] = useState(() => Math.floor(10000000 + Math.random() * 90000000).toString()) + const [accountId] = useState(() => user?.account || Math.floor(10000000 + Math.random() * 90000000).toString()) const handleLogout = () => { - setIsAuthenticated(false) + logout() // 使用AuthProvider中的logout方法删除本地保存的用户信息 setShowLogoutDialog(false) router.push("/login") } @@ -53,12 +54,12 @@ export default function ProfilePage() {
- - KR + + {user?.username?.slice(0, 2) || "KR"}
-

卡若

-

账号: {accountId}

+

{user?.username || "用户"}

+

账号: {user?.account || accountId}