"use client" import { useState, useEffect } from "react" import { ChevronRight, Settings, Bell, LogOut } from "lucide-react" import { Card } from "@/components/ui/card" 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" import ClientOnly from "@/components/ClientOnly" import { getClientRandomId } from "@/lib/utils" const menuItems = [ { href: "/devices", label: "设备管理" }, { href: "/wechat-accounts", label: "微信号管理" }, { href: "/traffic-pool", label: "流量池" }, { href: "/content", label: "内容库" }, ] export default function ProfilePage() { const router = useRouter() const [showLogoutDialog, setShowLogoutDialog] = useState(false) const [userInfo, setUserInfo] = useState(null) // 从localStorage获取用户信息 useEffect(() => { const userInfoStr = localStorage.getItem('userInfo') if (userInfoStr) { setUserInfo(JSON.parse(userInfoStr)) } }, []) const handleLogout = () => { // 清除本地存储的用户信息 localStorage.removeItem('token') localStorage.removeItem('token_expired') localStorage.removeItem('s2_accountId') localStorage.removeItem('userInfo') setShowLogoutDialog(false) router.push("/login") } return (

我的

{/* 用户信息卡片 */}
{userInfo?.username ? userInfo.username.slice(0, 2) : "用户"}

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

账号: {userInfo?.account || Math.floor(10000000 + Math.random() * 90000000).toString()}

{/* 功能菜单 */} {menuItems.map((item) => (
(item.href ? router.push(item.href) : null)} >
{item.label}
))}
{/* 退出登录按钮 */}
{/* 退出登录确认对话框 */} 确认退出登录 您确定要退出登录吗?退出后需要重新登录才能使用完整功能。
) }