Commit Graph
6 Commits
Author SHA1 Message Date
xuyueandClaude Opus 5.5 4014aaabbf build: 改成 Bun workspaces 的 monorepo
- 根目录新增 package.json(workspaces: client、server),两边共用一个 bun.lock,
  依赖版本与原来两个 lockfile 完全一致
- 根目录脚本:bun run dev / build / build:staging / test / typecheck / fmt,
  取代 dev.sh;client 的 start 改名为 dev,包名改为 webpreview-client
- workspaces 用 isolated 安装,补上 client 一直直接 import 却没声明的 @codemirror/view
- server 镜像改用仓库根目录做构建上下文,只装 server 的依赖;
  .dockerignore 用白名单,不再把 node_modules、数据库等发给 docker
- CI 在根目录安装并构建前端

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:57:29 +08:00
xuyueandClaude Opus 5.5 26827e31d5 feat: 登录改用 JWT(access token + refresh token),不再用 cookie
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
- 登录返回 15 分钟的 access token(HS256,密钥 JWT_SECRET,未配置则每次启动随机)
  和 14 天的 refresh token;请求带 Authorization: Bearer,WebSocket 用 ?token=
- refresh token 只存 sha256,放在新表 auth_refresh_token(删除旧的 auth_session);
  POST /account/refresh 换新的 access token,退出、改密码、封号时作废
- 带了无效或过期的 token 一律 401,前端据此刷新:快过期时提前刷新、并发请求只刷新一次,
  401 时刷新后重试一次,refresh token 也失效才退出登录
- 不再用 cookie,去掉 CORS credentials 和写请求的 Origin 校验

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:10:55 +08:00
xuyueandClaude Opus 5.5 dde976cacb build: 前端改用 Bun + Vite,格式化改用 bun fmt
- 包管理和运行时换成 Bun:bun.lock 取代 package-lock.json,脚本用 bun --bun 运行,
  CI 改用 oven-sh/setup-bun(1.4.4,与后端镜像一致)
- 构建工具从 Rsbuild 换成 Vite 8,沿用 PUBLIC_ 环境变量前缀和 3000 端口;
  浏览器目标保持 Chrome 87 起(机房是 Chrome 105),用 plugin-legacy 按需注入
  core-js(toSorted 等),不生成旧浏览器的兼容包
- fmt 改用 Bun 自带的格式化,配置从 .prettierrc.toml 移到 bunfig.toml;
  prettier 包仍保留,编辑器里的「整理」按钮在浏览器里用它

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:10:50 +08:00
xuyueandClaude Opus 5.5 ceba1c68f2 fix: 修复注册和上传素材在 await 前后的并发竞态;补充 SQLite 写法说明
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
- 注册 / 新建用户 / 批量建用户:先算密码哈希,再同步地查重和插入,
  同名并发请求返回 400 而不是撞唯一约束变成 500
- 上传任务素材改用 INSERT ... ON CONFLICT DO UPDATE
- CLAUDE.md 补充同步阻塞、行内大文本列、索引、类型差异等注意事项
- 忽略根目录的 db.sqlite3(线上数据备份)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:36:54 +08:00
xuyueandClaude Opus 5.5 26f05d1d76 refactor: 后端从 Django 换成 Bun + SQLite
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
Deploy / deploy (build:staging, school, 8822) (push) Canceled after 0s
Django 多个 worker 内存占用 1-2 GB,换成 Bun 单进程后约 25 MB,
同时去掉 Postgres 和 Redis,只剩 Caddy + Bun 两个容器。

- server/:Hono + bun:sqlite + Bun 原生 WebSocket,接口与原 django-ninja
  保持兼容;表结构、时间/UUID 存储格式、密码哈希与 Django 一致,旧数据可直接使用
- 评分加权、贝叶斯平滑、成绩册的计算结果与原实现逐位一致(复刻 Python round/sum)
- scripts/:Postgres → SQLite 迁移、新建超管、提示词层级标注、重算分数
- 前端:Django Admin 去掉后,用户新建/修改改为页面内弹窗;
  非超管的挑战公开按钮置灰
- 权限不足返回 JSON 403(原来是重定向到不存在的登录页)
- docker-compose / Caddyfile / dev.sh / CLAUDE.md 更新,删除 AGENTS.md
- 服务器切换步骤见 docs/migrate-to-bun.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:45:09 +08:00
xuyueandClaude Opus 5.5 47d4679984 chore: 合并为单仓库,统一部署流程
- 根目录加入 docker-compose、Caddyfile、文档等原本不在仓库里的文件
- 前后端两份 GitHub Actions 合并成根目录的一个 deploy workflow:
  构建前端上传到 build/,再在服务器上 git pull 并重建容器

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:02:12 +08:00