fix(account-service): 管理页接口走部署前缀并改中文错误提示

公网 /account/ 下绝对路径 /api/admin 会被 OpenIM 接走,无条件 res.json()
把非 JSON 响应打成英文异常。按页面路径拼接前缀,并先看状态再解析。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
编码工程师
2026-08-31 09:27:28 +08:00
co-authored by Cursor multica-agent
parent 2f8a76da3f
commit 8842a74d68
6 changed files with 550 additions and 21 deletions
+7 -1
View File
@@ -41,7 +41,7 @@ POST /api/login
| POST | `/api/admin/reset_password` | 重置密码 `{staffNo, password}` |
| POST | `/api/admin/delete` | 删除 `{staffNo}`,立即无法登录并被踢下线(OpenIM 侧同名用户保留但本服务不再为其签发令牌,等于不可用) |
管理页:浏览器打开 `http://<服务器IP>:10010/`,输入管理口令即可操作,无需写接口
管理页:浏览器打开 `http://<服务器IP>:10010/`(公网反代场景为 `https://<域名>/account/`),输入管理口令即可操作,无需写接口。页面会按当前地址自动带上部署前缀请求 `/api/admin/...`,不要改成以 `/` 开头的绝对路径,否则公网会被 OpenIM 根路由接走
## 部署
@@ -57,3 +57,9 @@ docker compose up -d --build account-server
- `ACCOUNT_ADMIN_TOKEN`:管理口令,**部署时务必改掉默认值**
重启/升级:改代码后 `docker compose up -d --build account-server`;数据在 `./data/account/employees.json`,重建容器不丢。
管理页热修自测(不连现网、不读真实员工数据):
```bash
node account-service/test-admin-page.js
```