From 010990ea3c90313249faa11107e11fb5c614ef03 Mon Sep 17 00:00:00 2001 From: wmp <17516219072@163.com> Date: Tue, 14 Oct 2025 16:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E6=94=B9=E9=80=A0=E4=BD=BF=E7=94=A8=E8=B7=AF=E7=94=B1=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=9B=B4=E6=96=B0=E4=B8=AD=E9=97=B4=E4=BB=B6?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(auth)/login/page.tsx | 2 +- .../allocationStatus/page.tsx} | 2 +- .../cityNodeStats/page.tsx} | 4 +- .../edge.tsx => (root)/edge/page.tsx} | 6 +- .../gatewayConfig/page.tsx} | 0 .../gatewayMonitor/page.tsx} | 0 .../gatewayinfo/page.tsx} | 13 +- src/app/(root)/layout.tsx | 103 +++++++++++++ .../settings.tsx => (root)/settings/page.tsx} | 4 +- src/app/dashboard/page.tsx | 138 ------------------ src/app/debug/config/page.tsx | 108 -------------- src/app/debug/layout.tsx | 11 -- src/components/ui/loadingCard.tsx | 2 +- src/middleware.ts | 2 +- 14 files changed, 117 insertions(+), 278 deletions(-) rename src/app/{dashboard/components/allocationStatus.tsx => (root)/allocationStatus/page.tsx} (99%) rename src/app/{dashboard/components/cityNodeStats.tsx => (root)/cityNodeStats/page.tsx} (95%) rename src/app/{dashboard/components/edge.tsx => (root)/edge/page.tsx} (98%) rename src/app/{dashboard/components/gatewayConfig.tsx => (root)/gatewayConfig/page.tsx} (100%) rename src/app/{dashboard/components/gatewayConfigs.tsx => (root)/gatewayMonitor/page.tsx} (100%) rename src/app/{dashboard/components/gatewayinfo.tsx => (root)/gatewayinfo/page.tsx} (93%) create mode 100644 src/app/(root)/layout.tsx rename src/app/{dashboard/components/settings.tsx => (root)/settings/page.tsx} (99%) delete mode 100644 src/app/dashboard/page.tsx delete mode 100644 src/app/debug/config/page.tsx delete mode 100644 src/app/debug/layout.tsx diff --git a/src/app/(auth)/login/page.tsx b/src/app/(auth)/login/page.tsx index c6366c0..a07b46f 100644 --- a/src/app/(auth)/login/page.tsx +++ b/src/app/(auth)/login/page.tsx @@ -41,7 +41,7 @@ export default function LoginPage() { }) setAuth(true) await new Promise(resolve => setTimeout(resolve, 1000)) - router.push('/dashboard') + router.push('/gatewayinfo') router.refresh() } else { diff --git a/src/app/dashboard/components/allocationStatus.tsx b/src/app/(root)/allocationStatus/page.tsx similarity index 99% rename from src/app/dashboard/components/allocationStatus.tsx rename to src/app/(root)/allocationStatus/page.tsx index dc8f0cc..8610f1e 100644 --- a/src/app/dashboard/components/allocationStatus.tsx +++ b/src/app/(root)/allocationStatus/page.tsx @@ -139,7 +139,7 @@ export default function AllocationStatus({ detailed = false }: { detailed?: bool if (error) return return ( -
+

节点分配状态

diff --git a/src/app/dashboard/components/cityNodeStats.tsx b/src/app/(root)/cityNodeStats/page.tsx similarity index 95% rename from src/app/dashboard/components/cityNodeStats.tsx rename to src/app/(root)/cityNodeStats/page.tsx index c9900ed..a804b36 100644 --- a/src/app/dashboard/components/cityNodeStats.tsx +++ b/src/app/(root)/cityNodeStats/page.tsx @@ -30,7 +30,7 @@ export default function CityNodeStats() { if (loading) { return ( -
+

城市节点数量分布

加载中...
@@ -38,7 +38,7 @@ export default function CityNodeStats() { } return ( -
+

城市节点数量分布

diff --git a/src/app/dashboard/components/edge.tsx b/src/app/(root)/edge/page.tsx similarity index 98% rename from src/app/dashboard/components/edge.tsx rename to src/app/(root)/edge/page.tsx index 9ef961b..f88e2ba 100644 --- a/src/app/dashboard/components/edge.tsx +++ b/src/app/(root)/edge/page.tsx @@ -166,14 +166,14 @@ export default function Edge() { }, []) if (loading) return ( -
+

节点列表

加载节点数据中...
) if (error) return ( -
+

节点列表

{error}
*/}
diff --git a/src/app/(root)/layout.tsx b/src/app/(root)/layout.tsx new file mode 100644 index 0000000..60f50d6 --- /dev/null +++ b/src/app/(root)/layout.tsx @@ -0,0 +1,103 @@ +'use client' + +import { ReactNode, useState } from 'react' +import { useRouter, usePathname } from 'next/navigation' +import { logout } from '@/actions/auth' +import { LogOut } from 'lucide-react' +import Link from 'next/link' + +export default function DashboardLayout({ + children, +}: { + children: React.ReactNode +}) { + const [isLoading, setIsLoading] = useState(false) + const router = useRouter() + const pathname = usePathname() + + const handleLogout = async () => { + setIsLoading(true) + try { + const response = await logout() + if (response) { + router.push('/login') + router.refresh() + } + } + catch (error) { + console.error('退出错误:', error) + } + finally { + setIsLoading(false) + } + } + + const isActive = (path: string) => { + return pathname === path + } + + return ( +
+ {/* 顶部导航栏 */} + + + {/* 主要内容区域 */} +
+ {/* 侧边栏 */} +
+ +
+ + {/* 内容区域 */} +
+ {children} +
+
+
+ ) +} + +function NavbarItem(props: { + href: string + active: boolean + children: ReactNode +}) { + return ( + + {props.children} + + ) +} diff --git a/src/app/dashboard/components/settings.tsx b/src/app/(root)/settings/page.tsx similarity index 99% rename from src/app/dashboard/components/settings.tsx rename to src/app/(root)/settings/page.tsx index 8ae4f30..53a7d69 100644 --- a/src/app/dashboard/components/settings.tsx +++ b/src/app/(root)/settings/page.tsx @@ -123,8 +123,8 @@ export default function Settings() { ) return ( -
-
+
+

用户管理

-
-
- - -
-
- -
- -
- {activeTab === 'gatewayInfo' && } - {activeTab === 'gateway' && } - {activeTab === 'gateways' && } - {activeTab === 'city' && } - {activeTab === 'allocation' && } - {activeTab === 'edge' && } - {activeTab === 'setting' && } -
-
-
- ) -} - -export default function Dashboard() { - return ( - -
-
-

加载中...

-
-
- )}> - - - ) -} diff --git a/src/app/debug/config/page.tsx b/src/app/debug/config/page.tsx deleted file mode 100644 index 5fd3a83..0000000 --- a/src/app/debug/config/page.tsx +++ /dev/null @@ -1,108 +0,0 @@ -'use client' -import { findConfigs } from '@/actions/config' -import { gatewayConfigGet } from '@/actions/remote' -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' -import { useState } from 'react' -import { Input } from '@/components/ui/input' -import { Button } from '@/components/ui/button' - -type EdgeConfig = { - port?: string - edge?: string - city?: string - _index: number -} - -export default function DebugConfigPage() { - const [macaddr, setMacaddr] = useState('') - const [remotes, setRemotes] = useState([]) - const [locals, setLocals] = useState([]) - - const fetch = async (macaddr: string) => { - try { - console.log('fetch', macaddr) - if (!macaddr) return - - const rawLocal = await findConfigs({ macaddr }) - console.log('raw local', rawLocal) - - const rawRemote = await gatewayConfigGet({ macaddr }) - console.log('raw remote', rawRemote) - - setLocals(rawLocal.map(rule => ({ - port: rule.network, - edge: rule.edge, - city: rule.cityhash, - _index: parseInt(rule.network.split('.')[3] || '0'), - })).sort((a, b) => a._index - b._index)) - - setRemotes(rawRemote.rules.map((rule) => { - const port = rule.network.find(n => !!n) - return ({ - port: port, - edge: rule.edge.find(n => !!n), - city: rule.cityhash, - _index: port ? parseInt(port.split('.')[3]) : 0, - }) - }).sort((a, b) => a._index - b._index)) - } - catch (e) { - console.error('数据获取失败', e) - } - } - - return ( -
-
- setMacaddr(e.target.value)} className="flex-none basis-60" /> - -
- - - - 端口 - 节点 - 城市 - - - - {!locals.length || !remotes.length ? ( - - 获取数据为空 - - ) : locals.length !== remotes.length ? ( - - 本地和远程规则数量不匹配 - - ) : ( - locals.map((item, index) => ( - - - {item.port === remotes[index].port ? ( - {item.port} - ) : ( - {item.port} : {remotes[index].port} - )} - - - {item.edge === remotes[index].edge ? ( - {item.edge} - ) : ( - {item.edge} : {remotes[index].edge} - )} - - - {item.city === remotes[index].city ? ( - {item.city} - ) : ( - {item.city} : {remotes[index].city} - )} - - - )) - )} - -
-
- ) -} diff --git a/src/app/debug/layout.tsx b/src/app/debug/layout.tsx deleted file mode 100644 index 4adfd0d..0000000 --- a/src/app/debug/layout.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { ReactNode } from 'react' - -export default async function DebugLayout(props: { - children: ReactNode -}) { - return ( -
- {props.children} -
- ) -} diff --git a/src/components/ui/loadingCard.tsx b/src/components/ui/loadingCard.tsx index 123f77d..a32fcf0 100644 --- a/src/components/ui/loadingCard.tsx +++ b/src/components/ui/loadingCard.tsx @@ -1,6 +1,6 @@ export default function LoadingCard({ title }: { title: string }) { return ( -
+
diff --git a/src/middleware.ts b/src/middleware.ts index 48e322f..6aa0cc9 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -26,7 +26,7 @@ export async function middleware(request: NextRequest) { // 给没有页面的路径添加跳转页面 if (request.nextUrl.pathname === '/') { - return NextResponse.redirect(new URL('/dashboard', request.url)) + return NextResponse.redirect(new URL('/gatewayinfo', request.url)) } return NextResponse.next()