From 91e406f5ee4fb8e9d06a50deadd63470f1c0759a Mon Sep 17 00:00:00 2001 From: shangfangjian Date: Thu, 17 Sep 2026 02:43:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E2=80=94=20=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=20+=20=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=20+=20LLM=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移动端自适应: - AdminLayout: 汉堡菜单 + 可折叠侧边栏 + 遮罩层 + ESC 关闭 - 所有页面响应式布局 (grid-cols-1 sm:grid-cols-2 lg:grid-cols-4) - 触摸友好按钮 (min-h-[44px]) - 表格移动端卡片视图 新增页面: - DataSources: 数据源状态 + API Key 脱敏 + 测试连接 - LLMConfig: LLM 配置 + 测试连接 + 使用统计 + 最近预测 增强功能: - Config: 配置列表 + 修改指南 + 快捷导航 - types: 新增 DataSourceStatus, LLMUsageStats 等类型 - dal: 新增 testDataSource, fetchDataSourceStatuses, testLLMConnection 等 --- frontend/src/admin/AdminLayout.tsx | 92 ++++++-- frontend/src/admin/README.md | 76 +++++-- frontend/src/admin/components.tsx | 72 ++++++- frontend/src/admin/dal.ts | 87 ++++++++ frontend/src/admin/pages/Backtest.tsx | 112 +++++++--- frontend/src/admin/pages/Collection.tsx | 106 +++++++--- frontend/src/admin/pages/Config.tsx | 217 +++++++++++++++---- frontend/src/admin/pages/Dashboard.tsx | 77 ++++++- frontend/src/admin/pages/DataSources.tsx | 174 +++++++++++++++ frontend/src/admin/pages/LLMConfig.tsx | 259 +++++++++++++++++++++++ frontend/src/admin/pages/Monitoring.tsx | 92 ++++++-- frontend/src/admin/pages/Predictions.tsx | 58 +++-- frontend/src/admin/routes.tsx | 6 +- frontend/src/admin/types.ts | 58 +++++ 14 files changed, 1312 insertions(+), 174 deletions(-) create mode 100644 frontend/src/admin/pages/DataSources.tsx create mode 100644 frontend/src/admin/pages/LLMConfig.tsx diff --git a/frontend/src/admin/AdminLayout.tsx b/frontend/src/admin/AdminLayout.tsx index 55e194a..89c5e5f 100644 --- a/frontend/src/admin/AdminLayout.tsx +++ b/frontend/src/admin/AdminLayout.tsx @@ -1,11 +1,13 @@ /** * Admin 后台 - 布局组件 * - * 提供管理界面的基本结构:顶栏 + 侧边栏 + 内容区 + * 响应式布局: 移动端汉堡菜单 + 可折叠侧边栏 + * 桌面端: 固定侧边栏 + 内容区 * 暗色主题,参考线性风格设计 */ -import { NavLink, Outlet } from 'react-router-dom' +import { useState, useEffect, useCallback } from 'react' +import { NavLink, Outlet, useLocation } from 'react-router-dom' const NAV_ITEMS = [ { to: '/admin', label: '仪表盘', icon: '◇', end: true }, @@ -13,22 +15,72 @@ const NAV_ITEMS = [ { to: '/admin/predictions', label: '预测管理', icon: '◆' }, { to: '/admin/backtest', label: '回测管理', icon: '◉' }, { to: '/admin/monitoring', label: '监控面板', icon: '◐' }, - { to: '/admin/config', label: '配置管理', icon: '◑' }, + { to: '/admin/data-sources', label: '数据源', icon: '◫' }, + { to: '/admin/llm-config', label: 'LLM 配置', icon: '◬' }, + { to: '/admin/config', label: '系统配置', icon: '◑' }, ] export default function AdminLayout() { + const [sidebarOpen, setSidebarOpen] = useState(false) + const location = useLocation() + + // 路由变化时关闭移动端菜单 + const closeSidebar = useCallback(() => setSidebarOpen(false), []) + + useEffect(() => { + closeSidebar() + }, [location.pathname, closeSidebar]) + + // ESC 键关闭菜单 + useEffect(() => { + const handler = (e: KeyboardEvent) => { + if (e.key === 'Escape') setSidebarOpen(false) + } + document.addEventListener('keydown', handler) + return () => document.removeEventListener('keydown', handler) + }, []) + return (
+ {/* ── 移动端遮罩层 ── */} + {sidebarOpen && ( +
setSidebarOpen(false)} + aria-hidden="true" + /> + )} + {/* ── 侧边栏 ── */} -