import Icon from "../../components/common/Icon"; import { useAuth, usePermission } from "../../context/AuthContext"; const TREND_VALUES = [38, 55, 44, 73, 61, 86, 78] as const; const TREND_LABELS = ["周一", "周二", "周三", "周四", "周五", "周六", "今天"] as const; const ACTIVITY_ROWS = [ ["数据探索.ipynb 发布稳定版本 v3.0", "张三", "成功", "16:42"], ["每日模型训练流程完成调度运行", "Scheduler", "成功", "15:25"], ["批量预测.py 更新工作副本", "王五", "已同步", "14:18"], ["风险验证流程完成 DAG 校验", "李四", "成功", "11:06"], ] as const; function LegendDot({ className }: { className: string }) { return ; } export function DashboardPage({ scriptCount, online, onNavigate, }: { scriptCount: number; online: boolean; onNavigate: (page: "scripts" | "schedules" | "system") => void; }) { const { user, currentWorkspace } = useAuth(); const hasSystemView = usePermission("system:view"); const notebookCount = Math.max(1, Math.round(scriptCount * 0.67)); const pythonCount = Math.max(0, scriptCount - Math.round(scriptCount * 0.67)); return ( MODEL DEVELOPMENT PLATFORM 下午好,{user?.display_name ?? "用户"} 当前位于 {currentWorkspace?.workspace_name ?? "(未选择 Workspace)"} ,可以继续构建脚本或配置调度。 {online ? "服务正常" : "服务连接中"} {[ { icon: "script" as const, value: scriptCount, label: "工作副本" }, { icon: "workspace" as const, value: 2, label: "Workspace" }, { icon: "settings" as const, value: 4, label: "平台用户" }, { icon: "check" as const, value: online ? "正常" : "检查中", label: "平台状态", }, ].map((item) => ( {item.value} {item.label} ))} onNavigate("scripts")} > 构建脚本 onNavigate("schedules")} > 调度配置 {hasSystemView && ( onNavigate("system")} > 系统管理 )} 运行趋势 近 7 天调度执行 成功率 92.6% {TREND_VALUES.map((value, index) => ( {Math.round(value / 7)} {TREND_LABELS[index]} ))} 脚本资产 类型分布 {scriptCount} 全部脚本 {[ { color: "bg-[#318de0]", title: "Notebook", detail: `${notebookCount} 个 · 67%`, }, { color: "bg-[#72c9b0]", title: "Python", detail: `${pythonCount} 个 · 33%`, }, { color: "bg-[#f3b75c]", title: "稳定版本", detail: "3 个已发布", }, ].map((item) => ( {item.title} {item.detail} ))} ACTIVITY 最近平台活动 查看全部 操作内容 执行人 状态 时间 {ACTIVITY_ROWS.map((row) => ( {row[0]} {row[1]} {row[2]} {row[3]} ))} ); }
当前位于 {currentWorkspace?.workspace_name ?? "(未选择 Workspace)"} ,可以继续构建脚本或配置调度。