网关基本信息
@@ -220,14 +220,7 @@ export default function Gatewayinfo() {
>
- {/* */}
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 (
-
-
+
+
用户管理
- )}>
-
-
- )
-}
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" />
- fetch(macaddr)}>查询
-
-
-
-
- 端口
- 节点
- 城市
-
-
-
- {!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()