Add demo mode factory reset

- Align the backend seeded default surgery template with the report editor's default report content.

- Add backend demo defaults for the default template, Kimi provider, and Xunfei speech proxy configuration.

- Change system reset into a super-admin demo mode factory reset that clears reports, audit logs, files, custom templates, and non-default users.

- Keep only the default admin, manager, doctor, and default surgery template after demo reset.

- Replace the old local-only reset all data button with a two-confirmation backend reset flow.

- Add tests covering demo default alignment and database-backed demo reset behavior.

- Update docs to describe demo mode reset semantics and production credential cautions.
This commit is contained in:
2026-05-02 02:52:30 +08:00
parent bc235b2358
commit 911b96b883
17 changed files with 361 additions and 85 deletions

View File

@@ -104,6 +104,7 @@ npm run test:e2e
- 页面级权限在前端用于体验控制,不能抵御绕过;生产安全边界以后端 API 权限校验为准。
- 报告和模板 HTML 保存时已做服务端白名单清洗;前端仍使用 HTML 渲染,继续修改时要留意 XSS 和打印兼容。
- AI Key 和讯飞语音密钥已由后端代理使用,普通用户读取系统设置时不会返回真实密钥。
- 当前 demo mode 后端默认值包含演示用第三方服务凭据,生产化前必须替换或移除,并轮换曾经暴露过的密钥。
- 视频和关键帧文件已优先进入后端文件资源;报告保存时通过 `ReportMedia` 关系表关联,新建报告保存前仍依赖浏览器对象 URL 预览。
- `VITE_ENABLE_LOCAL_FALLBACK` 控制生产构建是否允许本地兼容回退;开发模式默认允许,生产默认关闭。
@@ -192,6 +193,7 @@ npm run test:e2e
│ │ ├── audit/ # 审计日志写入和查询 API
│ │ ├── auth/ # 登录、me、logout 接口
│ │ ├── dashboard/ # 工作台统计 API
│ │ ├── demo/ # 演示模式默认模板、AI 和语音配置
│ │ ├── reports/ # 报告 API、DTO、metadata 映射和测试
│ │ ├── templates/ # 模板 API、DTO、权限映射和测试
│ │ ├── users/ # 用户、部门和模板授权 API、DTO 映射和测试