import { useEffect, useRef, useState } from "react" import { Activity, ArrowUpRight, BarChart3, Bell, BookOpen, ChevronRight, CircleDot, Database, FlaskConical, LayoutDashboard, LockKeyhole, RefreshCw, Server, Settings2, ShieldCheck, Sparkles, Users } from "lucide-react" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { getHealth, type Health } from "@/lib/api" import {type User} from "@/lib/auth" import {ProvidersPanel} from "@/components/ProvidersPanel" import {NotificationTasksPanel} from "@/components/NotificationTasksPanel" import {SimulationQuotesPanel} from "@/components/SimulationQuotesPanel" import {MarketPanel} from "@/components/MarketPanel" import {BacktestsPanel} from "@/components/BacktestsPanel" import {StrategiesPanel} from "@/components/StrategiesPanel" import {CandidatesPanel} from "@/components/CandidatesPanel" import {AuditPanel} from "@/components/AuditPanel" import {UsersPanel} from "@/components/UsersPanel" const workspaces = [ {name:"总览", icon:LayoutDashboard}, {name:"候选审核",icon:BookOpen}, {name:"策略中心",icon:Settings2}, {name:"回测研究",icon:FlaskConical}, {name:"数据健康",icon:Database}, {name:"模型配置",icon:Sparkles}, {name:"通知任务",icon:Bell}, {name:"用户管理",icon:Users}, {name:"审计日志",icon:ShieldCheck}, {name:"系统设置",icon:LockKeyhole}, ] const label = {ready:"连接正常",unavailable:"无法连接",not_configured:"待配置"} export default function App({user,onLogout,onSessionExpired}:{user:User;onLogout:()=>Promise;onSessionExpired:()=>void}) { const [page,setPage] = useState("总览") const [health,setHealth] = useState(null) const [error,setError] = useState("") const [loading,setLoading] = useState(false) const [logoutError,setLogoutError] = useState("") const [signingOut,setSigningOut] = useState(false) async function signOut() {setSigningOut(true);setLogoutError("");try {await onLogout()} catch(e) {setLogoutError(e instanceof Error ? e.message : "退出失败,请重试。")} finally {setSigningOut(false)}} const controller = useRef(null) async function refresh() { controller.current?.abort() const next = new AbortController() controller.current = next setLoading(true) try { const data = await getHealth(next.signal); if (!next.signal.aborted) {setHealth(data);setError("")} } catch (e) { if (!next.signal.aborted) {setHealth(null);setError(e instanceof Error ? e.message : "暂时无法连接 API 服务")} } finally {if (!next.signal.aborted) setLoading(false)} } useEffect(()=>{void refresh();return ()=>controller.current?.abort()},[]) const overview = page === "总览" || page === "数据健康" return
工作空间 {page}
{user.display_name}LOCAL · 开发环境
{logoutError &&

{logoutError}

}

VEYRA / {overview ? "SYSTEM OVERVIEW" : "WORKSPACE"}

{page === "总览" ? "把每一步,建立在依据之上。" : page}

{overview ? "查看服务连接与建设进度,从可靠的基础开始。" : page === "模型配置" || page === "系统设置" ? "配置供应商连接信息,按需启用。" : page === "审计日志" ? "查看后台配置的操作记录。" : page === "通知任务" ? "查看持久化事件与站内通知处理状态。" : page === "候选审核" ? "录入证据、审核修订并发布模拟候选。" : page === "策略中心" ? "管理研究参数与版本历史。" : page === "回测研究" ? "提交历史数据,查看可追溯的 Python 回测结果。" : "该工作区的业务功能正在建设中。"}

{overview && }
{overview ? <> {error &&
无法读取当前服务状态。请检查 API 是否启动。{error}
}
{[ {title:"API 服务",subtitle:"Go · Gin",icon:Server,value:loading ? "检查中" : health ? "运行中" : "未连接"}, {title:"PostgreSQL",subtitle:"业务事实与版本化迁移",icon:Database,value:loading ? "检查中" : health ? label[health.components.postgresql.status] : "未知"}, {title:"Redis",subtitle:"缓存与订阅索引",icon:Activity,value:loading ? "检查中" : health ? label[health.components.redis.status] : "未知"}, ].map(({title,subtitle,icon:Icon,value})=>
{title}

{value}

{subtitle}

)}
第一条产品闭环模拟流程已接通
先验证完整流程,再扩大策略与数据范围。
    {["管理端审核并发布观察候选","用户查看证据,确认买入计划","条件满足后发送提醒","记录实际成交,建立持仓监控","记录退出成交,生成成本后复盘"].map((v,i)=>
  1. 0{i+1}{v}已接通模拟流程
  2. )}
数据接入后,开始观察。候选数量、策略表现与账户指标将在业务功能与数据接入完成后展示。
当前状态来源:Go API 实时探测
最近检查:{health ? new Date(health.checked_at).toLocaleString("zh-CN") : "尚未取得状态"}
{page==="数据健康"&&<>} : page==="候选审核" ? : page==="回测研究" ? : page==="策略中心" ? : page==="通知任务" ? : page==="用户管理" ? : page==="模型配置" ? : page==="系统设置" ? : page==="审计日志" ? :

{page}尚未开放

该模块完成业务接口、权限与验证后开放。

}
}