From 27de14f752d48008086596ee71c9b3187630d1b0 Mon Sep 17 00:00:00 2001 From: Chen Gu Date: Sat, 9 May 2026 14:32:04 +0800 Subject: [PATCH] fix: unified nav - TopHud back btn + window controls + login close --- src/components/layout/TopHud.tsx | 42 +++++++++++++++++++++++++++++--- src/pages/Login.tsx | 21 ++++++++++------ src/pages/SchemeDetail.tsx | 2 +- src/router.tsx | 6 ++++- 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/src/components/layout/TopHud.tsx b/src/components/layout/TopHud.tsx index ec71491..9a47400 100644 --- a/src/components/layout/TopHud.tsx +++ b/src/components/layout/TopHud.tsx @@ -4,12 +4,26 @@ interface TopHudProps { title?: string; subtitle?: string; sections?: { label: string; value: string }[]; + onBack?: () => void; } -export default function TopHud({ title = '码枪堂 2.0', subtitle, sections = [] }: TopHudProps) { +function callElectron(method: string) { + try { (window as any).electronAPI?.[method](); } catch {} +} + +export default function TopHud({ title = '码枪堂 2.0', subtitle, sections = [], onBack }: TopHudProps) { return ( -
+
+ {/* Back button */} + {onBack && ( + + )}

{title}

{subtitle && ( @@ -19,7 +33,7 @@ export default function TopHud({ title = '码枪堂 2.0', subtitle, sections = [ )}
-
+
{sections.map((s, i) => ( {s.label} @@ -27,7 +41,27 @@ export default function TopHud({ title = '码枪堂 2.0', subtitle, sections = [ ))} - V0.2.1 + + {/* Window controls */} + + + + V0.2.1
); diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 5fad043..d58db6e 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -7,6 +7,10 @@ import { useAuth } from '../hooks/useAuth'; import { useAuthStore } from '../stores/authStore'; import { getVipStatus, activateVip } from '../services/auth.api'; +function callElectron(method: string) { + try { (window as any).electronAPI?.[method](); } catch {} +} + export default function Login() { const navigate = useNavigate(); const { login } = useAuth(); @@ -50,15 +54,20 @@ export default function Login() { return (
- {/* 品牌 */} + {/* 关闭按钮 */} + +

码枪堂 2.0

用户认证系统

- {/* 认证卡片 */} - {/* 标签页 */}
{(['login', 'register', 'vip'] as const).map(t => ( +

方案详情

{scheme.isOfficial && 官方} diff --git a/src/router.tsx b/src/router.tsx index 6a61fc9..3d9bc64 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -1,5 +1,5 @@ import React, { Suspense, lazy } from 'react'; -import { Routes, Route } from 'react-router-dom'; +import { Routes, Route, useNavigate } from 'react-router-dom'; import PageContainer from './components/layout/PageContainer'; import TopHud from './components/layout/TopHud'; @@ -30,6 +30,9 @@ const pageTitles: Record = { }; function PageShell({ children, currentPage }: { children: React.ReactNode; currentPage: string }) { + const navigate = useNavigate(); + const isHome = currentPage === 'home'; + return (
navigate(-1)} /> }>