Store calculation history on server with bazi input and chart snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-13 09:57:16 +08:00
parent fcf071cfaa
commit 123a5cce6d
17 changed files with 419 additions and 54 deletions
+8
View File
@@ -25,6 +25,10 @@ cp .env.example .env.local
nano .env.local
chmod 600 .env.local
# 测算历史持久化目录(挂载到容器)
mkdir -p data/history
chmod 755 data/history
# 构建并启动
docker compose build
docker compose up -d
@@ -109,10 +113,13 @@ pm2 restart zhimingge
| `AUTH_USERNAME` | 否* | 登录用户名;与下面两项同时配置后启用登录 |
| `AUTH_PASSWORD` | 否* | 登录密码 |
| `AUTH_SESSION_SECRET` | 否* | 会话签名密钥,建议 32 位以上随机字符串 |
| `HISTORY_DATA_DIR` | 否 | 测算历史 JSON 存储目录;Docker 默认 `/app/data/history` |
| `PORT` | 否 | 容器内 3130 |
\* 三项认证变量**同时**填写时,六爻/八字/综合测算与 AI 解读需登录;任一项留空则关闭登录限制。
测算历史保存在服务器 `data/history/`(Compose 挂载到容器),按登录用户名分文件;八字/综合测算会保存出生信息与四柱排盘。
验证容器内是否生效(示例):
```bash
@@ -262,6 +269,7 @@ docker compose up -d --build
| AI 失败 | 检查 `.env.local``OPENAI_API_KEY``docker exec zhimingge printenv OPENAI_API_KEY` |
| 页面 AI 空白、curl 本地正常 | Nginx/宝塔未关缓冲或未反代域名,见 [BAOTA.md](./BAOTA.md) |
| 卦辞 404 | 确认镜像内 `/app/content/zhouyi/docs` 存在 |
| 测算历史保存失败 | 确认 `data/history` 存在且容器可写:`mkdir -p data/history && chmod 777 data/history`(或 `chown 1001:1001` |
| 磁盘满 / 镜像过多 | `bash scripts/docker-prune.sh`,见 [镜像清理](#镜像清理) |
构建在镜像内完成,**无需**在宿主机单独 `npm install` / `npm run build`