添加设置模块修复网关信息MAC地址跳转问题,删除冗余的文件和代码

This commit is contained in:
wmp
2025-09-16 18:12:55 +08:00
parent a25ce604f0
commit 3322d6a8e4
11 changed files with 641 additions and 80 deletions

View File

@@ -1,11 +1,12 @@
'use client'
import { useState, useEffect } from 'react'
import { useRouter } from 'next/navigation'
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'
@@ -14,24 +15,23 @@ const tabs = [
{ id: 'gateway', label: '网关配置' },
{ id: 'city', label: '城市信息' },
{ id: 'allocation', label: '分配状态' },
{ id: 'edge', label: '节点信息' }
{ id: 'edge', label: '节点信息' },
{ id: 'setting', label: '设置'}
]
export default function Dashboard() {
const [activeTab, setActiveTab] = useState('gatewayInfo')
const [isLoading, setIsLoading] = useState(false)
const router = useRouter()
const searchParams = useSearchParams()
// URL 中获取 tab 参数
// 监听URL参数变化
useEffect(() => {
if (typeof window !== 'undefined') {
const urlParams = new URLSearchParams(window.location.search)
const urlTab = urlParams.get('tab')
if (urlTab && tabs.some(tab => tab.id === urlTab)) {
setActiveTab(urlTab)
}
const urlTab = searchParams.get('tab')
if (urlTab && tabs.some(tab => tab.id === urlTab)) {
setActiveTab(urlTab)
}
}, [])
}, [searchParams])
// 退出登录
const handleLogout = async () => {
@@ -58,7 +58,9 @@ export default function Dashboard() {
const handleTabClick = (tabId: string) => {
setActiveTab(tabId)
// 更新 URL 参数
router.push(`/dashboard?tab=${tabId}`)
const params = new URLSearchParams(searchParams.toString())
params.set('tab', tabId)
router.push(`/dashboard?${params.toString()}`)
}
return (
@@ -108,6 +110,7 @@ export default function Dashboard() {
{activeTab === 'city' && <CityNodeStats />}
{activeTab === 'allocation' && <AllocationStatus detailed />}
{activeTab === 'edge' && <Edge />}
{activeTab === 'setting' && <Settings/>}
</div>
</div>
</div>