内容后台上线:网页里改网站内容(账号密码 + 首次强制改密 + 草稿/预览/发布/回滚 + 画展传图);新世界线自动排位;星球预设 18 种

Browse Source
- backend-site/cms.py(新):账号(scrypt 加盐哈希)、服务端会话(只存哈希,30 天滑动,可撤销)、
  admin/admin 首次登录强制改密(改密前其它接口一律 403)、CSRF / 来源 / https / 登录冷却、
  内容校验、发布写 content/ 与 prices.json / payinfo.json、版本与回滚、传图核验 + 去元数据 + ffmpeg 缩略图
- server.py 把 /api/cms/* 交给 cms.py;admin.py 加 user list/add/passwd/reset/disable/enable/sessions
- portal/admin/(新):内容后台页面;门户顶栏加不带字的淡色铅笔入口
- 门户 / 下单页读 content/site.js、order/content/order.js(代码里的数据降级为兜底);?preview=1 预览草稿
- portal/assets/universe/layout.js(新):新点亮的世界线自动排到中圈不挤的位置、补给线接附近的星、已有的都不动
- planets.js:加 10 种卡通预设(类地 / 海洋 / 丛林 / 荒漠 / 冻原 / 熔岩 / 毒雾 / 荒芜岩球 / 冰巨星 / 带环巨星)
- galaxy.js:名牌 / 档案卡文字一律转义
- tests/内容后台测试.py(75 条);回归 27 + 数据库 38 照旧全过;端到端浏览器 36 条
- 文档:交接文档-2026-10.md(变更 / 接口 / 部署 7.1b / 测试 / 第 10 节)、内容后台设计.md(实现对照)、星系图交接说明、nginx 片段 ④

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-10-05 21:25:06 +00:00
co-authored by Claude Opus 5.5
parent 6b05fc849a
commit 12e66badc6
24 changed files with 3607 additions and 62 deletions
+30
View File
@@ -55,6 +55,36 @@ location /order/api/ {
} }
``` ```
### ④ 内容后台(2026-10-05 加)
```nginx
# 登录 / 内容接口。⚠️ 必须带 X-Forwarded-Proto —— 后端看它判断是不是 https,不带一律拒绝(内容后台只走 https)
location /order/api/cms/ {
limit_req zone=<ZONE_ORDER> burst=20 nodelay;
limit_req_status 429;
client_max_body_size 16m; # 画展传图:单张 10MB,base64 后约 13.4MB
proxy_pass http://localhost:<PORT>/api/cms/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 后台发布出来的内容文件:文件名不变、内容会变 → 让浏览器每次都问一下有没有新的
location /content/ { add_header Cache-Control "no-cache"; }
location /order/content/ { add_header Cache-Control "no-cache"; }
# 后台页面本身不缓存(改版后别人拿到旧页面会调错接口)
location /admin/ { add_header Cache-Control "no-store"; }
# 画展上传的图(文件名是随机的,可以长缓存)
location /uploads/ { add_header Cache-Control "public, max-age=2592000"; }
# 整站 http → https,并加 HSTS(登录页绝不能走 http)
server { listen 80; server_name shop.example.com; return 301 https://$host$request_uri; }
# 在 443 的 server 块里加:
# add_header Strict-Transport-Security "max-age=31536000" always;
```
> 没配好证书之前**不要开放内容后台**:后端会拒绝所有非 https 的请求(返回 403「内容后台只能用 https 打开」)。
⚠️ **打包下载(zip)那条要另外配**:`proxy_buffering off` + 更长的 `proxy_read_timeout`, ⚠️ **打包下载(zip)那条要另外配**:`proxy_buffering off` + 更长的 `proxy_read_timeout`,
因为它是**先落临时文件再边读边发**的,不能在 nginx 这层再缓存一份(小机器内存受不住)。 因为它是**先落临时文件再边读边发**的,不能在 nginx 这层再缓存一份(小机器内存受不住)。