feat: ship OA drafts/badges, role dual-track, and test-env deploy tooling.
Add approval instance drafts with menu badges, dual-track user/role read model and role bound names, form-designer outline docs, and bare-metal test deploy scripts. Ignore local test-server credential file. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7af53fc344
commit
de22678c87
56 files changed
+11861
-6082
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# 角色列表有效用户与关联职位 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 角色列表支持名称快捷查看,并展示有效拥有用户与关联职位。
|
||||
|
||||
**Architecture:** 后端在 `list_roles` 批量 enrichment `boundUserNames` / `boundPostNames`;前端对齐职位列表的 link 与多值换行单元格。
|
||||
|
||||
**Tech Stack:** FastAPI/SQLAlchemy、Vue 3 + Element Plus
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 后端 enrichment
|
||||
|
||||
**Files:** `backend/app/crud/role.py`, `backend/tests/test_role_list_bound_names.py`
|
||||
|
||||
- [x] 实现 `_bound_user_names_by_role_ids`、`_bound_post_names_by_role_ids`
|
||||
- [x] `list_roles` / `_row_to_dict` 输出新字段
|
||||
- [x] 空入参与 enrichment 调用的单测
|
||||
|
||||
### Task 2: 前端列表
|
||||
|
||||
**Files:** `web-admin/src/types/api.d.ts`, `web-admin/src/views/system/role/index.vue`
|
||||
|
||||
- [x] `RoleItem` 增加字段
|
||||
- [x] 角色名称 link → `handleView`
|
||||
- [x] 「拥有用户」「关联职位」两列
|
||||
|
||||
### Task 3: 验证与图谱
|
||||
|
||||
- [x] `pytest` 相关用例(4 passed)
|
||||
- [ ] `./scripts/update-graph.sh backend`(graphify 因节点数变化拒绝覆盖,可后续 `force` 重跑)
|
||||
@@ -0,0 +1,128 @@
|
||||
# OA 发起审批草稿箱 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 发起审批可暂存草稿,并新增「草稿箱」菜单支持再编辑、保存、提交与删除。
|
||||
|
||||
**Architecture:** 独立表 `oa_instance_draft` 存发起人填写草稿;提交时复用 `oa_engine.start_instance`,成功后软删草稿。前端在发起弹窗加「暂存草稿」,新建 `drafts/index.vue` 列表页。
|
||||
|
||||
**Tech Stack:** FastAPI + SQLAlchemy + MySQL;Vue 3 + Element Plus;Fresh Mint UI。
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-08-06-oa-approval-instance-draft-design.md`
|
||||
**UI Demo:** `docs/demos/oa-approval-draft-box-demo.html`
|
||||
|
||||
---
|
||||
|
||||
## File map
|
||||
|
||||
| 文件 | 职责 |
|
||||
|------|------|
|
||||
| `docs/sql/oa_instance_draft.sql` | 建表 + `sys_menu` 草稿箱 |
|
||||
| `backend/app/models/models.py` | `OaInstanceDraft` |
|
||||
| `backend/app/crud/oa_instance_draft.py` | 草稿 CRUD |
|
||||
| `backend/app/api/oa_approval.py` | drafts 路由 |
|
||||
| `backend/tests/test_oa_instance_draft.py` | 权限/序列化/提交后软删等单测 |
|
||||
| `web-admin/src/api/oaApproval.ts` | drafts API |
|
||||
| `web-admin/src/router/modules/sqxp.ts` | 路由「草稿箱」 |
|
||||
| `web-admin/src/views/oa-approval/drafts/index.vue` | 草稿箱页 |
|
||||
| `web-admin/src/views/oa-approval/start/index.vue` | 暂存按钮 + draftId 回填 |
|
||||
| `待同步到生产的sql脚本` | 追加本 SQL 引用说明(若团队习惯) |
|
||||
|
||||
---
|
||||
|
||||
### Task 1: SQL 建表与菜单
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/sql/oa_instance_draft.sql`
|
||||
|
||||
- [x] **Step 1: 编写 SQL**
|
||||
- [x] **Step 2: 本地执行 SQL(若有 DB)** — 脚本已写入 `docs/sql/oa_instance_draft.sql`,需在目标库手动执行
|
||||
- [x] **Step 3: Commit** — 待用户要求再提交
|
||||
|
||||
---
|
||||
|
||||
### Task 2: SQLAlchemy 模型
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/models/models.py`(紧挨 `OaInstance` 之前或之后)
|
||||
|
||||
- [ ] **Step 1: 增加 `OaInstanceDraft`**
|
||||
- [ ] **Step 2: Commit** `feat(backend): add OaInstanceDraft model.`
|
||||
|
||||
---
|
||||
|
||||
### Task 3: CRUD + API(TDD)
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/crud/oa_instance_draft.py`
|
||||
- Modify: `backend/app/api/oa_approval.py`
|
||||
- Create: `backend/tests/test_oa_instance_draft.py`
|
||||
|
||||
- [ ] **Step 1: 写失败/单元测试**(`_row_to_dict` 字段、owner 校验逻辑可用纯函数;提交后 `del_flag` 行为可用 mock Session)
|
||||
|
||||
- [ ] **Step 2: 实现 CRUD**
|
||||
- `list_drafts`, `get_draft`, `create_draft`, `update_draft`, `soft_delete`, `batch_soft_delete`
|
||||
- list join `OaApp` 取 `appName`、version_no;仅 `owner_user_id`
|
||||
|
||||
- [ ] **Step 3: 挂路由**
|
||||
- GET/POST `/drafts`
|
||||
- GET/PUT/DELETE `/drafts/{id}`
|
||||
- POST `/drafts/batch-delete`
|
||||
- POST `/drafts/{id}/submit` → `start_instance` + soft delete
|
||||
|
||||
- [ ] **Step 4: pytest 通过**
|
||||
- [ ] **Step 5: Commit** `feat(backend): OA instance draft CRUD and submit API.`
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 前端 API + 路由
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/api/oaApproval.ts`
|
||||
- Modify: `web-admin/src/router/modules/sqxp.ts`(发起审批与待办之间插入 drafts)
|
||||
- Modify: `web-admin/src/types/api.d.ts`(若有 OA 类型需补)
|
||||
|
||||
- [ ] **Step 1: API 封装**
|
||||
- [ ] **Step 2: 路由 meta.title=`草稿箱`, menuCode=`oa:drafts`**
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
---
|
||||
|
||||
### Task 5: 草稿箱页面
|
||||
|
||||
**Files:**
|
||||
- Create: `web-admin/src/views/oa-approval/drafts/index.vue`
|
||||
|
||||
- [ ] **Step 1: 按 Demo +「我发起的」模式做列表**(筛选、表格、分页、操作列 min-width≥260、状态 Tag)
|
||||
- [ ] **Step 2: 编辑打开弹窗(可内嵌复用 start 逻辑或跳转 `start?draftId=`)——**采用 `start?draftId=`** 减少重复
|
||||
- [ ] **Step 3: 提交/删除/批量删除接线**
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
---
|
||||
|
||||
### Task 6: 发起页暂存与回填
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/oa-approval/start/index.vue`
|
||||
|
||||
- [ ] **Step 1: footer 增加「暂存草稿」**(取消 / 暂存 / 提交;主色仅提交)
|
||||
- [ ] **Step 2: `route.query.draftId` 加载详情并回填;保存走 PUT**
|
||||
- [ ] **Step 3: 暂存成功提示并关弹窗**
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
---
|
||||
|
||||
### Task 7: 收尾
|
||||
|
||||
- [ ] **Step 1:** `./scripts/update-graph.sh all`(或 backend+frontend)
|
||||
- [ ] **Step 2:** 自测清单对照 spec「测试要点」
|
||||
- [ ] **Step 3:** 确认 `App.vue` panelTitleBarTextRules 含「草稿箱」(若需要竖条)
|
||||
|
||||
---
|
||||
|
||||
## 验收
|
||||
|
||||
1. 发起弹窗可暂存,草稿箱可见。
|
||||
2. 编辑回填 → 再保存 → 提交后出现在「我发起的」,草稿消失。
|
||||
3. 他人账号看不到该草稿。
|
||||
4. 暂存不产生待办任务。
|
||||
@@ -0,0 +1,41 @@
|
||||
# OA 草稿箱/待办菜单角标 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 侧栏「草稿箱」「待办中心」展示数量角标,对齐「抄送我的」。
|
||||
|
||||
**Architecture:** 后端增加轻量 count 接口;前端扩展 `oa-menu-badge` store 与 `refreshOaMenuBadges`,在相关页操作后刷新。
|
||||
|
||||
**Tech Stack:** FastAPI / SQLAlchemy / Vue 3 / Pinia
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-08-06-oa-drafts-pending-menu-badge-design.md`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Backend count helpers + API
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/oa_engine.py`(`count_pending_tasks`)
|
||||
- Modify: `backend/app/crud/oa_instance_draft.py`(`count_drafts`)
|
||||
- Modify: `backend/app/api/oa_approval.py`
|
||||
- Test: `backend/tests/test_oa_menu_badge_counts.py`
|
||||
|
||||
- [x] Step 1: 写失败单测(mock query.count)
|
||||
- [x] Step 2: 实现 `count_pending_tasks` / `count_drafts` + 路由
|
||||
- [x] Step 3: 跑通 pytest
|
||||
|
||||
### Task 2: Frontend badge wiring
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/store/modules/oa-menu-badge.ts`
|
||||
- Modify: `web-admin/src/utils/oa-menu-badge.ts`
|
||||
- Modify: `web-admin/src/api/oaApproval.ts`
|
||||
- Modify: `web-admin/src/views/oa-approval/drafts/index.vue`
|
||||
- Modify: `web-admin/src/views/oa-approval/pending/index.vue`
|
||||
- Modify: `web-admin/src/views/oa-approval/start/index.vue`
|
||||
- Modify: `web-admin/src/views/oa-approval/instances/detail.vue`
|
||||
- Modify: `web-admin/src/store/modules/user.ts`
|
||||
|
||||
- [x] Step 1: API + store codes + refresh 并行拉取
|
||||
- [x] Step 2: 页面操作后 refresh;logout clear
|
||||
- [x] Step 3: 更新 graphify(frontend + backend;HTML viz 过大时跳过)
|
||||
@@ -0,0 +1,21 @@
|
||||
# OA Form Designer Outline Style E Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Reduce canvas outline noise in OA form designer using hybrid style E (soft dashed for containers, hover/active for leaves).
|
||||
|
||||
**Architecture:** CSS-only overrides in `oa-fc-host/App.vue` targeting FormCreate `_fd-drag-tool`. Containers detected via `:has(._fd-drag-tool)`.
|
||||
|
||||
**Tech Stack:** Vue 3, `@form-create/designer`, SCSS/CSS in iframe host.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Add hybrid outline CSS
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/oa-fc-host/App.vue`
|
||||
|
||||
- [x] Add leaf default transparent outline + hover solid soft mint + active solid mint
|
||||
- [x] Add container `:has(._fd-drag-tool)` soft dashed default
|
||||
- [x] Override hardcoded `#2E73FF` on `.active` outline and `._fd-drag-btn` to mint
|
||||
- [ ] Manual verify in `/#/system-manage/oa-approval/designer/:id` → 表单设计 tab
|
||||
@@ -0,0 +1,453 @@
|
||||
# 测试环境裸机部署 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 在 `101.35.245.122` 的 `/root/zkxw` 以裸机方式部署 web-admin(Nginx :10001)与 backend(127.0.0.1:10002),中间件复用本机开发环境的 `47.99.164.66`。
|
||||
|
||||
**Architecture:** 本机 `pnpm build:test` + rsync 前端静态资源;本机 rsync backend 源码;测试机安装 Nginx、用已有 Python 3.12.3 建 `.venv`、`start-test.sh` 绑定本机回环。Nginx 反代 `/api` 与 `/health`,不反代 MinIO。
|
||||
|
||||
**Tech Stack:** Nginx、Python 3.12.3 + venv + uvicorn、`backend/start-test.sh`、Vue 3 web-admin(`pnpm build:test`)、rsync/ssh
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-08-06-test-env-bare-metal-deploy-design.md`
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
| 路径 | 职责 |
|
||||
|------|------|
|
||||
| `测试环境部署/zkxw-test-10001.conf` | 新建:测试机 Nginx server 块(10001) |
|
||||
| `测试环境部署/README.md` | 改写:新拓扑、端口、安装与发版步骤 |
|
||||
| `web-admin/.env.test` | 仅更新注释中的访问入口 IP/端口 |
|
||||
| `docs/superpowers/specs/2026-08-06-test-env-bare-metal-deploy-design.md` | 已存在,实现时勿改需求;若步骤偏差仅改计划 |
|
||||
| 服务器 `/root/zkxw/**` | 运行时产物与 `.env.test`(不进 git) |
|
||||
| `测试环境机器的账号密码` | 仅本机 SSH 用,**禁止** commit / 写入计划正文 |
|
||||
|
||||
不新建 Docker compose;不在服务器装 Node。
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 仓库内新增 Nginx site 片段
|
||||
|
||||
**Files:**
|
||||
- Create: `测试环境部署/zkxw-test-10001.conf`
|
||||
|
||||
- [ ] **Step 1: 创建完整 Nginx 配置文件**
|
||||
|
||||
写入以下内容(无 MinIO 反代;API/health 指向本机 10002):
|
||||
|
||||
```nginx
|
||||
# ZKXW 测试环境(裸机)— 部署到 101.35.245.122
|
||||
# 用法(按发行版二选一):
|
||||
# Ubuntu/Debian: 复制到 /etc/nginx/sites-available/zkxw-test-10001.conf
|
||||
# ln -sf ... /etc/nginx/sites-enabled/
|
||||
# RHEL/CentOS: 复制到 /etc/nginx/conf.d/zkxw-test-10001.conf
|
||||
# nginx -t && systemctl reload nginx
|
||||
|
||||
server {
|
||||
listen 10001;
|
||||
listen [::]:10001;
|
||||
server_name 101.35.245.122 localhost 127.0.0.1;
|
||||
|
||||
root /root/zkxw/web-admin/dist;
|
||||
index index.html;
|
||||
|
||||
client_max_body_size 100M;
|
||||
|
||||
access_log /var/log/nginx/zkxw_admin_10001_access.log;
|
||||
error_log /var/log/nginx/zkxw_admin_10001_error.log;
|
||||
|
||||
location = /health {
|
||||
proxy_pass http://127.0.0.1:10002/health;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
|
||||
location ^~ /docs {
|
||||
proxy_pass http://127.0.0.1:10002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location = /openapi.json {
|
||||
proxy_pass http://127.0.0.1:10002/openapi.json;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location ^~ /api/ {
|
||||
proxy_pass http://127.0.0.1:10002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_send_timeout 120s;
|
||||
proxy_read_timeout 120s;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 本地核对关键指令**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
grep -E 'listen|proxy_pass|root |minio' 测试环境部署/zkxw-test-10001.conf
|
||||
```
|
||||
|
||||
Expected: `listen 10001`;`root /root/zkxw/web-admin/dist`;`proxy_pass` 均为 `127.0.0.1:10002`;**无** `minio` 行。
|
||||
|
||||
- [ ] **Step 3: Commit(仅当用户要求提交时执行;否则跳过)**
|
||||
|
||||
```bash
|
||||
git add 测试环境部署/zkxw-test-10001.conf
|
||||
git commit -m "$(cat <<'EOF'
|
||||
docs: add nginx site for test env on port 10001
|
||||
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: 更新测试部署 README 与前端 env 注释
|
||||
|
||||
**Files:**
|
||||
- Modify: `测试环境部署/README.md`(全文按新拓扑重写核心章节;可保留文末修订记录并追加一行)
|
||||
- Modify: `web-admin/.env.test`(仅注释)
|
||||
|
||||
- [ ] **Step 1: 重写 `测试环境部署/README.md` 关键**
|
||||
|
||||
用下列结构覆盖/重写文档(保留必要历史可放「修订记录」)。**正文不要写入任何数据库密码或机器 root 密码。**
|
||||
|
||||
必须包含:
|
||||
|
||||
1. 拓扑表:
|
||||
|
||||
| 角色 | 地址 |
|
||||
|------|------|
|
||||
| 入口 | `http://101.35.245.122:10001` |
|
||||
| Nginx 静态 | `/root/zkxw/web-admin/dist` |
|
||||
| 后端 | `127.0.0.1:10002`(仅本机) |
|
||||
| 中间件 | 与本机 `backend/.env` 相同(`47.99.164.66`) |
|
||||
| MinIO 浏览器 | `http://47.99.164.66:20004/zkxw`(直连,Nginx 不反代) |
|
||||
|
||||
2. 机装:Python **已有 3.12.3**;**需安装 Nginx**;探测 `apt`/`yum`/`dnf` 后安装示例:
|
||||
|
||||
```bash
|
||||
# Debian/Ubuntu
|
||||
sudo apt-get update && sudo apt-get install -y nginx
|
||||
|
||||
# RHEL/CentOS/Alma(示例)
|
||||
sudo yum install -y nginx # 或 dnf install -y nginx
|
||||
sudo systemctl enable --now nginx
|
||||
```
|
||||
|
||||
3. 目录、`.env.test` 来源(从本机 `backend/.env` 复制为服务器 `.env.test`)、启动:
|
||||
|
||||
```bash
|
||||
cd /root/zkxw/backend
|
||||
python3.12 -m venv .venv
|
||||
./.venv/bin/pip install -U pip
|
||||
./.venv/bin/pip install -r requirements.txt
|
||||
HOST=127.0.0.1 PORT=10002 ./start-test.sh start
|
||||
```
|
||||
|
||||
4. Nginx 启用 `zkxw-test-10001.conf` 的命令。
|
||||
|
||||
5. 日常发版 rsync 命令(与 spec §6.2 一致)。
|
||||
|
||||
6. 验收 curl(与 spec §7 一致)。
|
||||
|
||||
7. 说明:旧 8112 / 双机拓扑已废弃,以本文件为准。
|
||||
|
||||
- [ ] **Step 2: 更新 `web-admin/.env.test` 注释**
|
||||
|
||||
将文件头注释改为类似:
|
||||
|
||||
```env
|
||||
# Web Admin 测试环境(打包:pnpm build:test)
|
||||
# 访问入口:http://101.35.245.122:10001
|
||||
# Nginx 将 /api 反代至本机 127.0.0.1:10002
|
||||
# MinIO:浏览器直连 http://47.99.164.66:20004/zkxw(不经测试机 Nginx)
|
||||
```
|
||||
|
||||
保持现有 `VITE_*` 变量值不变(`VITE_API_URL=/api`、`VITE_MINIO_BASE_URL=http://47.99.164.66:20004/zkxw` 等)。
|
||||
|
||||
- [ ] **Step 3: Commit(仅当用户要求时)**
|
||||
|
||||
```bash
|
||||
git add 测试环境部署/README.md web-admin/.env.test
|
||||
git commit -m "$(cat <<'EOF'
|
||||
docs: document bare-metal test deploy on 10001/10002
|
||||
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: SSH 探测服务器并安装 Nginx
|
||||
|
||||
**Files:** 无仓库文件;操作目标 `101.35.245.122`
|
||||
|
||||
前置:本机可 SSH 登录(密钥或密码)。**不要**把密码写进仓库或命令历史脚本文件。
|
||||
|
||||
- [ ] **Step 1: 探测 OS、Python、端口占用**
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 'set -e
|
||||
uname -a
|
||||
cat /etc/os-release | head -20
|
||||
python3.12 --version || python3 --version
|
||||
which nginx || true
|
||||
ss -lntp | grep -E "10001|10002" || true
|
||||
mkdir -p /root/zkxw/web-admin/dist /root/zkxw/backend /root/zkxw/nginx
|
||||
'
|
||||
```
|
||||
|
||||
Expected: Python 显示 3.12.x;nginx 可能不存在;目录创建成功。
|
||||
|
||||
- [ ] **Step 2: 按发行版安装 Nginx 并开机自启**
|
||||
|
||||
若 `ID` 为 ubuntu/debian:
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 'export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y nginx
|
||||
systemctl enable nginx
|
||||
systemctl start nginx
|
||||
nginx -v
|
||||
'
|
||||
```
|
||||
|
||||
若为 rhel/centos/almalinux/rocky:
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 'yum install -y nginx || dnf install -y nginx
|
||||
systemctl enable nginx
|
||||
systemctl start nginx
|
||||
nginx -v
|
||||
'
|
||||
```
|
||||
|
||||
Expected: `nginx version: nginx/...`
|
||||
|
||||
- [ ] **Step 3: 上传并启用 site**
|
||||
|
||||
```bash
|
||||
scp 测试环境部署/zkxw-test-10001.conf root@101.35.245.122:/root/zkxw/nginx/zkxw-test-10001.conf
|
||||
```
|
||||
|
||||
然后在服务器上(按 Step 1 探测结果选一条路径):
|
||||
|
||||
Debian/Ubuntu:
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 '
|
||||
cp /root/zkxw/nginx/zkxw-test-10001.conf /etc/nginx/sites-available/zkxw-test-10001.conf
|
||||
ln -sfn /etc/nginx/sites-available/zkxw-test-10001.conf /etc/nginx/sites-enabled/zkxw-test-10001.conf
|
||||
# 若 default 占口冲突可保留;本 site 仅 10001
|
||||
nginx -t && systemctl reload nginx
|
||||
'
|
||||
```
|
||||
|
||||
RHEL 系:
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 '
|
||||
cp /root/zkxw/nginx/zkxw-test-10001.conf /etc/nginx/conf.d/zkxw-test-10001.conf
|
||||
nginx -t && systemctl reload nginx
|
||||
'
|
||||
```
|
||||
|
||||
Expected: `nginx: configuration file ... test is successful`
|
||||
|
||||
- [ ] **Step 4: 提醒安全组**
|
||||
|
||||
确认云控制台入站已放行 **TCP 10001**(本步无法在代码中完成;执行者勾选确认)。
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 部署 backend 并启动
|
||||
|
||||
**Files:** 服务器 `/root/zkxw/backend`;本机源 `backend/`
|
||||
|
||||
- [ ] **Step 1: rsync 源码**
|
||||
|
||||
在仓库根目录执行:
|
||||
|
||||
```bash
|
||||
rsync -avz \
|
||||
--exclude '.venv' \
|
||||
--exclude 'venv' \
|
||||
--exclude '__pycache__' \
|
||||
--exclude '*.pyc' \
|
||||
--exclude 'logs' \
|
||||
--exclude 'graphify-out' \
|
||||
--exclude '.env' \
|
||||
--exclude '.env.*' \
|
||||
backend/ root@101.35.245.122:/root/zkxw/backend/
|
||||
```
|
||||
|
||||
Expected: `start-test.sh`、`requirements.txt`、`app/` 出现在远端。
|
||||
|
||||
- [ ] **Step 2: 生成并上传 `.env.test`(不进 git)**
|
||||
|
||||
本机:
|
||||
|
||||
```bash
|
||||
cp backend/.env /tmp/zkxw-env.test
|
||||
# 确认中间件段与开发一致;勿把 /tmp/zkxw-env.test 加入 git
|
||||
scp /tmp/zkxw-env.test root@101.35.245.122:/root/zkxw/backend/.env.test
|
||||
rm -f /tmp/zkxw-env.test
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 建 venv 并装依赖**
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 '
|
||||
set -e
|
||||
cd /root/zkxw/backend
|
||||
python3.12 -m venv .venv
|
||||
./.venv/bin/pip install -U pip
|
||||
./.venv/bin/pip install -r requirements.txt
|
||||
./.venv/bin/python -c "import uvicorn; print(uvicorn.__version__)"
|
||||
chmod +x start-test.sh
|
||||
'
|
||||
```
|
||||
|
||||
Expected: 打印 uvicorn 版本;无 pip 失败。
|
||||
|
||||
- [ ] **Step 4: 探测中间件连通性(从测试机)**
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 '
|
||||
set -e
|
||||
timeout 5 bash -c "echo >/dev/tcp/47.99.164.66/3306" && echo mysql_ok
|
||||
timeout 5 bash -c "echo >/dev/tcp/47.99.164.66/16379" && echo redis_ok
|
||||
timeout 5 bash -c "echo >/dev/tcp/47.99.164.66/20004" && echo minio_ok
|
||||
'
|
||||
```
|
||||
|
||||
Expected: 三行 `*_ok`。若失败:先修安全组/防火墙,**不要**继续启动(否则后端会连库失败)。
|
||||
|
||||
- [ ] **Step 5: 启动后端**
|
||||
|
||||
```bash
|
||||
ssh root@101.35.245.122 '
|
||||
cd /root/zkxw/backend
|
||||
HOST=127.0.0.1 PORT=10002 ./start-test.sh start
|
||||
HOST=127.0.0.1 PORT=10002 ./start-test.sh status
|
||||
curl -s http://127.0.0.1:10002/health
|
||||
'
|
||||
```
|
||||
|
||||
Expected: status 为 RUNNING;health 返回 JSON/成功体(非连接拒绝)。
|
||||
|
||||
---
|
||||
|
||||
### Task 5: 本机打包前端并 rsync
|
||||
|
||||
**Files:**
|
||||
- Build: `web-admin/dist/`
|
||||
- Remote: `/root/zkxw/web-admin/dist/`
|
||||
|
||||
- [ ] **Step 1: 打包**
|
||||
|
||||
```bash
|
||||
cd web-admin
|
||||
pnpm install
|
||||
pnpm build:test
|
||||
ls dist/index.html
|
||||
```
|
||||
|
||||
Expected: `dist/index.html` 存在。
|
||||
|
||||
- [ ] **Step 2: 上传**
|
||||
|
||||
```bash
|
||||
rsync -avz --delete web-admin/dist/ root@101.35.245.122:/root/zkxw/web-admin/dist/
|
||||
```
|
||||
|
||||
(在仓库根执行时路径如上;若已在 `web-admin` 目录则用 `dist/`。)
|
||||
|
||||
Expected: rsync 完成无 error。
|
||||
|
||||
---
|
||||
|
||||
### Task 6: 端到端验收
|
||||
|
||||
- [ ] **Step 1: 本机/外网验收命令**
|
||||
|
||||
```bash
|
||||
curl -s -o /dev/null -w '%{http_code}\n' http://101.35.245.122:10001/
|
||||
curl -s http://101.35.245.122:10001/health
|
||||
curl -s -o /dev/null -w '%{http_code}\n' --connect-timeout 5 http://101.35.245.122:10002/health || echo '10002_closed_ok'
|
||||
```
|
||||
|
||||
Expected:
|
||||
|
||||
- 第一行:`200`
|
||||
- 第二行:健康检查成功响应
|
||||
- 第三行:失败或超时,并打印 `10002_closed_ok`(证明未对公网开放)
|
||||
|
||||
- [ ] **Step 2: API 冒烟**
|
||||
|
||||
```bash
|
||||
curl -s -o /dev/null -w '%{http_code}\n' \
|
||||
http://101.35.245.122:10001/api/web/auth/login-rsa-public-key
|
||||
```
|
||||
|
||||
Expected: `200`(或业务约定的成功码;非 502/504)。
|
||||
|
||||
- [ ] **Step 3: 浏览器手工**
|
||||
|
||||
打开 `http://101.35.245.122:10001/`,确认页面加载;用测试账号登录(默认文档账号以环境实际为准,常见 `admin`)。附件若打不开,检查浏览器到 `47.99.164.66:20004` 是否可达。
|
||||
|
||||
- [ ] **Step 4: 更新设计/README 修订记录(可选)**
|
||||
|
||||
在 `测试环境部署/README.md` 修订记录追加:`2026-08-06 | 裸机部署 10001/10002 于 101.35.245.122`。
|
||||
|
||||
- [ ] **Step 5: Commit 仓库文档变更(仅当用户要求)**
|
||||
|
||||
将 Task 1–2 产生的仓库文件与本计划、spec 一并提交(**排除** `测试环境机器的账号密码`、任何 `.env.test`)。
|
||||
|
||||
---
|
||||
|
||||
## Spec coverage (self-review)
|
||||
|
||||
| Spec 要求 | Task |
|
||||
|-----------|------|
|
||||
| 无 Docker 应用部署 | Task 3–5(裸机) |
|
||||
| Nginx 10001 + 静态 + /api + /health | Task 1, 3 |
|
||||
| 后端 127.0.0.1:10002 | Task 4 |
|
||||
| 中间件照搬本机 .env | Task 4 Step 2 |
|
||||
| MinIO 直连不反代 | Task 1(配置无 minio)、验收说明 |
|
||||
| 安装 Nginx;Python 用 3.12.3 | Task 3, 4 |
|
||||
| 本机 build:test + rsync | Task 5 |
|
||||
| 验收清单 | Task 6 |
|
||||
| 更新 README / env 注释 / nginx 片段 | Task 1–2 |
|
||||
| 不提交密钥 | 全文约束 |
|
||||
|
||||
Placeholder scan: 无 TBD;发行版分支在 Task 3 用探测后二选一,非占位。
|
||||
|
||||
---
|
||||
|
||||
## Execution notes for agents
|
||||
|
||||
- SSH 失败时先修网络/密钥,勿把 root 密码写入 git。
|
||||
- `start-test.sh` 每次启停都带上 `HOST=127.0.0.1 PORT=10002`,避免回到默认 `0.0.0.0:8112`。
|
||||
- 依赖安装若因缺少 `python3.12-venv` 失败:Debian 上 `apt-get install -y python3.12-venv` 后再建 venv。
|
||||
Reference in new issue
Block a user