Files
dth/openspec/changes/chg_0004_experiment_platform_frontend/spec.md
T
xstudio agentandClaude Opus 4.8 10acc8114d merge sandbox/7975338+28c26c5+cd2cfc4: chg_0004 experiment_platform_frontend — React SPA 4 views + 5 components + Vite proxy + 14 e2e cases (gate PASS)
- docs/dth/experiment-platform/web-design.md: T1 架构设计
- src/frontend/src/main.tsx + App.tsx: 入口 + 路由
- src/frontend/src/api/{auth,operators,runs,client}.ts: 4 文件
- src/frontend/src/components/{AuthContext,ProtectedRoute,OperatorCard,RunResult,Radar}.tsx: 5 组件(Radar SVG 自绘 139 行)
- src/frontend/src/views/{Login,Dashboard,OperatorList,Run}.tsx: 4 页
- src/frontend/src/styles.css: 159 行(< 200 预算,无 UI 库)
- src/frontend/vite.config.ts: proxy /api → :30000
- tests/e2e/dth_frontend.test.sh: 14 case (5 API + 4 routes + 2 static + 3 list)
- openspec/changes/chg_0004_experiment_platform_frontend/{5 工件}
- package-lock.json: +react/react-dom/react-router-dom/axios + vite/typescript

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-28 11:42:47 +08:00

2.0 KiB
Raw Blame History

change_id, owner, status, requires_human_validation
change_id owner status requires_human_validation
chg_0004 pd@dth draft false

Spec: experiment_platform_web

Requirement

提供 React SPA 前端,承载用户登录 + 实验台 dashboard + 算子运行 + 结果可视化能力。

ADDED Scenarios

S1 page_login_form_submit

  • WHEN 用户访问 http://127.0.0.1:5173/login 输入 admin / 123456 后 submit
  • THEN 调用 POST /api/ssw/dth/auth/login,body {username:"admin",password:"123456"}
  • AND 成功后 token 存 localStorage,路由跳 /dashboard

S2 page_login_success_redirect_to_dashboard

  • WHEN 登录成功
  • THEN 路由跳 /dashboard,dashboard 渲染 3 张统计卡

S3 page_login_failure_show_401_message

  • WHEN 登录错误密码
  • THEN 后端返 {code:401,msg:"凭据无效"}(来自 envelope)
  • AND 前端表单下显示红色错误条 "登录失败:凭据无效"

S4 page_operator_list_shows_three_cards

  • WHEN 已登录用户访问 /operators
  • THEN 调 GET /api/ssw/dth/experiment/operators(带 Bearer token)
  • AND 渲染 N 张 OperatorCard,每张含 code / name / version / "运行"按钮

S5 page_run_form_submit_starts_run_with_run_id

  • WHEN 用户在 /operators/hello-mpc/run 表单填 {x:42} submit
  • THEN 调 POST /api/ssw/dth/experiment/runs body {operator:"hello-mpc",input:{x:42}}
  • AND 响应 data.run_id 36 位 UUID 渲染在结果区

S6 page_run_result_shows_output_json_with_real_data

  • WHEN run 状态 success
  • THEN 调 GET /api/ssw/dth/experiment/runs/:id
  • AND RunResult 组件渲染 data.output_json 真字段(output_json.ok=true + echo.x=42)
  • AND Radar 组件按算子类型显示 5 项雷达分数(hello_mpc=基础5项;pir=检索5项;vertical-lr=LR 5项)

UX / Interaction(UI 类变更填写)

  • 原型位置:先 MVP,4 页 + 简单样式;不做 design system
  • 交互决策:路由跳用 react-router-dom v6 <Navigate>;token 校验用 <Outlet> 守卫