From de0116ddc83ffd51e23edd5f4cc1259daddf2f8c Mon Sep 17 00:00:00 2001 From: aiyimickey <39365912+aiyimickey@users.noreply.github.com> Date: Wed, 1 Jul 2026 23:05:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=AA=E8=A1=A8=E7=9B=98=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=94=B9=E4=B8=BA=20/dashboard=20+=20Forbidden=20?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/auth/callback/route.ts | 2 +- src/app/dashboard/page.tsx | 93 ++++++++++++++++++++++++++++++ src/app/login/page.tsx | 2 +- src/app/page.tsx | 92 +---------------------------- src/components/Sidebar.tsx | 4 +- 5 files changed, 99 insertions(+), 94 deletions(-) create mode 100644 src/app/dashboard/page.tsx diff --git a/src/app/api/auth/callback/route.ts b/src/app/api/auth/callback/route.ts index dfd99d2..27946a7 100644 --- a/src/app/api/auth/callback/route.ts +++ b/src/app/api/auth/callback/route.ts @@ -77,7 +77,7 @@ export async function GET(request: NextRequest) { payload: { username: userinfo.preferred_username, displayName: userinfo.name, role: user.role }, }) - const response = NextResponse.redirect(new URL('/', baseUrl)) + const response = NextResponse.redirect(new URL('/dashboard', baseUrl)) // 签发 tlyq_session cookie response.cookies.set('tlyq_session', token, { diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx new file mode 100644 index 0000000..0fd3703 --- /dev/null +++ b/src/app/dashboard/page.tsx @@ -0,0 +1,93 @@ +'use client' +// src/app/dashboard/page.tsx — 仪表盘首页(四层结构) +import { useState, useEffect } from 'react' + +export default function DashboardPage() { + const [data, setData] = useState<{ services: Array>; counts: Record }>({ services: [], counts: { normal: 0, abnormal: 0, unknown: 0 } }) + + useEffect(() => { + fetch('/api/status').then(r => r.json()).then(setData) + const timer = setInterval(() => fetch('/api/status').then(r => r.json()).then(setData), 30_000) + return () => clearInterval(timer) + }, []) + + const { services, counts } = data + + return ( +
+ {/* 标题 */} +
+

服务状态监控 · {services.length} 个服务

+

实时健康检查 · 30 秒轮询

+
+ + {/* 状态统计条 */} +
+
+ 正常 + {counts.normal} + 共 {services.length} 个监控服务 +
+
+ 异常 + {counts.abnormal} + {services.filter(s => s.current_status === 'abnormal').map(s => s.name).join(', ') || '—'} +
+
+ 未知 + {counts.unknown} + {counts.unknown > 0 ? '待首次检查' : '全部已检查'} +
+
+ 最后检查 + 刚刚 + 自动刷新 30s +
+
+ + {/* KPI 统计条 */} +
+
+ 本月可用率 + +
+
+ 活跃渠道 + +
+
+ + {/* 分割线 */} +
+ + {/* 服务卡片网格 */} +
+ {services.length === 0 && ( +
+ 请先在「服务管理」中添加被监控服务 +
+ )} + {services.map((s) => { + const isAbnormal = s.current_status === 'abnormal' + return ( +
+
+ + + {String(s.name)} + + + {String(s.alert_level)} + +
+ {isAbnormal + ?
异常
+ :
运行中
+ } +
+ ) + })} +
+
+ ) +} diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index f7328b8..886b07e 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -2,5 +2,5 @@ import LoginPage from '@shared/ui/login-page' export default function Page() { - return + return } diff --git a/src/app/page.tsx b/src/app/page.tsx index 5a08bbc..2742b58 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,93 +1,5 @@ -'use client' -// src/app/page.tsx — 仪表盘首页(四层结构) -import { useState, useEffect } from 'react' +import { redirect } from 'next/navigation' export default function HomePage() { - const [data, setData] = useState<{ services: Array>; counts: Record }>({ services: [], counts: { normal: 0, abnormal: 0, unknown: 0 } }) - - useEffect(() => { - fetch('/api/status').then(r => r.json()).then(setData) - const timer = setInterval(() => fetch('/api/status').then(r => r.json()).then(setData), 30_000) - return () => clearInterval(timer) - }, []) - - const { services, counts } = data - - return ( -
- {/* 标题 */} -
-

服务状态监控 · {services.length} 个服务

-

实时健康检查 · 30 秒轮询

-
- - {/* 状态统计条 */} -
-
- 正常 - {counts.normal} - 共 {services.length} 个监控服务 -
-
- 异常 - {counts.abnormal} - {services.filter(s => s.current_status === 'abnormal').map(s => s.name).join(', ') || '—'} -
-
- 未知 - {counts.unknown} - {counts.unknown > 0 ? '待首次检查' : '全部已检查'} -
-
- 最后检查 - 刚刚 - 自动刷新 30s -
-
- - {/* KPI 统计条 */} -
-
- 本月可用率 - -
-
- 活跃渠道 - -
-
- - {/* 分割线 */} -
- - {/* 服务卡片网格 */} -
- {services.length === 0 && ( -
- 请先在「服务管理」中添加被监控服务 -
- )} - {services.map((s) => { - const isAbnormal = s.current_status === 'abnormal' - return ( -
-
- - - {String(s.name)} - - - {String(s.alert_level)} - -
- {isAbnormal - ?
异常
- :
运行中
- } -
- ) - })} -
-
- ) + redirect('/dashboard') } diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 4738d7c..e05a7c3 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -18,7 +18,7 @@ export default function Sidebar() { const sections: NavSection[] = [ { items: [ - { label: '仪表盘', href: '/', icon: LayoutDashboard }, + { label: '仪表盘', href: '/dashboard', icon: LayoutDashboard }, ], }, { @@ -49,7 +49,7 @@ export default function Sidebar() {