dfb0ea2d8f
修复 ScriptsPage 执行契约(script_id/command、历史过滤、长任务/凭据)及 SchedulesPage 缺失能力(target_path、next_run、push/script、cron/once、sync_mode);后端补迁移与 schedule_runner 传参。
46 lines
1.6 KiB
Markdown
46 lines
1.6 KiB
Markdown
# Changelog — 2026-06-07 脚本库 SPA 对齐设计文档
|
||
|
||
## 摘要
|
||
|
||
修复脚本库前后端多处契约断裂:库内脚本执行不传 command、分类校验失败、执行历史无法按 script_id 过滤、执行状态/重试/长任务/DB 凭据等设计能力在 SPA 缺失。
|
||
|
||
## 动机
|
||
|
||
用户反馈脚本库「大量问题」;对照 `docs/project/script-execution.md` 与 `ScriptsPage.vue` 发现执行链路几乎不可用(422/tracking id 错误),且 UI 未覆盖长任务、凭据、停止/重试/详情等 SSOT 能力。
|
||
|
||
## 变更
|
||
|
||
### 后端
|
||
|
||
- `ScriptExecute`:`command` 与 `script_id` 二选一;API 按 `script_id` 加载脚本内容
|
||
- `GET /api/scripts/executions?script_id=` 过滤单脚本历史
|
||
- 创建脚本时自动写入 `created_by`
|
||
|
||
### 前端
|
||
|
||
- 新建 `ScriptContentEditor.vue`(Monaco shell 编辑)
|
||
- 重写 `ScriptsPage.vue`:分类下拉、exec-config 提示、长任务/DB 凭据、执行状态条(10s 轮询)、停止/重试/标记卡住、历史与详情(含长任务拉日志)
|
||
- 修正 `ScriptItem` / `ScriptExecItem` / `DbCredentialItem` 类型
|
||
|
||
## 涉及文件
|
||
|
||
- `server/api/schemas.py`, `server/api/scripts.py`
|
||
- `server/application/services/script_service.py`
|
||
- `server/infrastructure/database/script_repo.py`
|
||
- `frontend/src/pages/ScriptsPage.vue`
|
||
- `frontend/src/components/ScriptContentEditor.vue`
|
||
- `frontend/src/types/api.ts`
|
||
|
||
## 迁移 / 重启
|
||
|
||
- 需部署后端 + 前端构建
|
||
- 无 DB 迁移
|
||
|
||
## 验证
|
||
|
||
```bash
|
||
cd frontend && npx vite build
|
||
# 脚本库:新建(ops 分类) → 选服务器执行 → 状态条出现 #id
|
||
# 历史对话框仅显示该脚本记录;失败可重试;长任务可勾选
|
||
```
|