import { Calendar, Check, FileText, LayoutGrid, Settings, type LucideIcon, } from "lucide-react"; 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: FileText, value: scriptCount, label: "工作副本" }, { Icon: LayoutGrid, value: 2, label: "Workspace" }, { Icon: Settings, value: 4, label: "平台用户" }, { Icon: Check, value: online ? "正常" : "检查中", label: "平台状态", }, ] as Array<{ Icon: LucideIcon; value: number | string; label: string }> ).map((item) => (
{item.value} {item.label}
))}
{hasSystemView && ( )}
运行趋势

近 7 天调度执行

成功率 92.6%
{TREND_VALUES.map((value, index) => (
{Math.round(value / 7)} {TREND_LABELS[index]}
))}
成功 75 失败 6
脚本资产

类型分布

{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]}
))}
); }