'use client' import { useState, useEffect, Suspense } from 'react' import { useRouter, useSearchParams } from 'next/navigation' import Gatewayinfo from './components/gatewayinfo' import GatewayConfig from './components/gatewayConfig' import CityNodeStats from './components/cityNodeStats' import AllocationStatus from './components/allocationStatus' import Settings from './components/settings' import Edge from './components/edge' import { LogOut } from 'lucide-react' const tabs = [ { id: 'gatewayInfo', label: '网关信息' }, { id: 'gateway', label: '网关配置' }, { id: 'city', label: '城市信息' }, { id: 'allocation', label: '分配状态' }, { id: 'edge', label: '节点信息' }, { id: 'setting', label: '设置' }, ] function DashboardContent() { const [activeTab, setActiveTab] = useState('gatewayInfo') const [isLoading, setIsLoading] = useState(false) const router = useRouter() const searchParams = useSearchParams() // 监听URL参数变化 useEffect(() => { const urlTab = searchParams.get('tab') if (urlTab && tabs.some(tab => tab.id === urlTab)) { setActiveTab(urlTab) } }, [searchParams]) // 退出登录 const handleLogout = async () => { setIsLoading(true) try { const response = await fetch('/api/auth/logout', { method: 'POST', }) if (response.ok) { // 退出成功后跳转到登录页 router.push('/login') router.refresh() } else { console.error('退出失败') } } catch (error) { console.error('退出错误:', error) } finally { setIsLoading(false) } } const handleTabClick = (tabId: string) => { setActiveTab(tabId) // 更新 URL 参数 const params = new URLSearchParams() params.set('tab', tabId) router.push(`/dashboard?${params.toString()}`) } return (
{activeTab === 'gatewayInfo' && } {activeTab === 'gateway' && } {activeTab === 'city' && } {activeTab === 'allocation' && } {activeTab === 'edge' && } {activeTab === 'setting' && }
) } export default function Dashboard() { return (

加载中...

)}>
) }