Commit Graph
100 Commits
Author SHA1 Message Date
xuyueandClaude Opus 5.5 40f3063b91 feat: 预览里的学生代码可以用 localStorage
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
预览 iframe 没有 allow-same-origin,访问 localStorage 会抛异常。现在在学生代码之前
注入一个替身(支持常用方法、属性读写、Object.keys 等):

- 自己的编辑器(教程、挑战、自由创作):写入通过 postMessage 交给主页面,按“用户 + 任务”
  存到本站 localStorage 的 preview-storage:* 下,下次渲染注入回去,刷新后数据还在
- 看别人的作品:只存在内存里
- 单个任务最多 10 万字符,总共 50 万字符,超出时先删最久没用的,不挤占登录 token 的配额
- 下载的 index.html 不带替身

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:55:31 +08:00
xuyueandClaude Opus 5.5 dc91b9b5db chore: 数据已迁到 SQLite,删掉 Postgres 迁移脚本、webpreview-db 服务和迁移文档
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
school 服务器以后要切换时,从 cdeb7c1 里找回(deploy.yaml 里写了)。
备份方法挪到 CLAUDE.md。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:36:33 +08:00
xuyueandClaude Opus 5.5 cdeb7c18ef fix: 修复中危问题:注册接口、模型名、LLM 超时、WebSocket 断线、未公开任务泄露等
服务端
- 删掉没人用的 /account/register,外网不能再批量注册小号
- 模型名只放行豆包和配置的 LLM_MODEL,浏览器里存的旧模型名换成默认模型;
  聊天默认模型改读 LLM_MODEL
- 流式生成改成 120 秒无数据才超时(另有 15 分钟总上限),思考模型不会被中途掐断;
  SSE 最后一行没有换行时不再丢内容
- WebSocket:token 无效 401、任务不存在 404,建对话失败时关闭连接;
  引导出错时把没有回复的提问移出上下文
- 未公开的教程只有超管能看,未公开的挑战和素材管理员也能看,其他人 404
- Caddy:/media 加 CSP sandbox 和 nosniff,上传的 html/svg 直接打开不能跑脚本;
  加 CORS,预览 iframe 里的代码可以读取字体和 fetch 素材

前端
- 新增 ReconnectingSocket:意外断开后退避重连,握手失败先刷新 token;
  断线时清掉“生成中”状态,旧连接的事件不再改写新连接
- marked 扩展抽到 utils/markdown.ts:教程用独立实例,不再改全局 marked;
  学生内容的渲染保留高亮,不带会渲染原始 HTML 的 preview 扩展
- 挑战页、创作页加载完成前离开时不再建立连接,离开时关闭引导弹窗
- 教程、提交列表、用户管理跟随浏览器前进后退;快速翻页只用最后一次结果,
  改筛选条件不再请求两次
- 随机评分弹窗在 AI 回复完之后不再弹出

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:33:44 +08:00
xuyueandClaude Opus 5.5 73788c4595 fix: 修复学生代码窃取 token、提示词链 XSS 和打分没有上限的问题
- 运行提交代码的 iframe(编辑器预览、随机评分弹窗、/submission/:id、全屏预览)
  加上 sandbox,不给 allow-same-origin,代码读不到 localStorage 里的 token
- 提示词和 AI 回复的 markdown 渲染时转义原始 HTML,链接只放行 http(s)/mailto;
  ChainModal 也改用这个渲染函数
- 打分限定 1-5 分(超出返回 422),不能给自己的提交打分

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:33:26 +08:00
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
xuyue a69ee16004 update
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
2026-10-26 19:45:43 +08:00
xuyue 0e3d97027a 使用 dsflash 和 doubao-seed-2.1
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
2026-10-26 19:39:59 +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 351e4b9499 chore: 去掉 maxkb 聊天挂件
页面不再加载 maxkb 的嵌入脚本,删除对应的 PUBLIC_MAXKB_URL 配置。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:10:35 +08:00
xuyueandClaude Opus 5.5 38137a828a ci: actions/checkout 和 setup-node 升到 v7(Node 24)
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:51:29 +08:00
xuyueandClaude Opus 5.5 4616bd9469 ci: 部署脚本出错即失败,git pull 显式指定 origin main
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
服务器上的 main 没有设置上游分支,git pull --ff-only 报错后脚本照常往下执行,
用旧代码重新构建,CI 却显示成功,导致 e6a3da1 等提交一直没上线。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:49:25 +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 e6a3da14b0 perf: 提交列表等查询改走覆盖索引,避免读取 html/css/js 大行
SQLite 把 html/css/js 存在行内,而 user_id、task_id、flag 等列排在它们后面,
读这些列也要先读完整段代码;线上库也没有统计信息,规划器常挑错索引。

- 新增覆盖索引 submission_submission_slim
- 提交列表、随机打分先在索引上取 rowid,再只读这一页 / 这一行的完整内容
- 列表的 flag / zone 筛选用一元 + 避开单列索引
- 打开数据库时执行 PRAGMA optimize,之后每小时一次

线上备份实测:提交列表 844 ms → 6 ms,打分后重算分数 11.5 ms → 0.2 ms。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:36:54 +08:00
xuyueandClaude Opus 5.5 4b8109caaa ci: 暂时停用 school 服务器的部署
Deploy / deploy (build, debian, 22) (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:02:43 +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
xuyueandClaude Opus 5.5 70983a12a5 chore: 合并后端仓库 webpreviewapi 的历史
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:01:25 +08:00
xuyueandClaude Opus 5.5 d1c6b8c201 chore: 将前端移动到 client/ 目录,准备合并为单仓库
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:01:25 +08:00
xuyueandClaude Opus 5.5 0591eda56f chore: 将后端移动到 api/ 目录,准备合并为单仓库
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:01:25 +08:00
xuyueandClaude Opus 5 e172ffc0b3 add creation
自由创作:新增 Creation 模型(继承 Task,display 自动递增)与
/api/creation/ 路由,支持增删改和代码保存,只有创作者本人和超管可访问。
自由创作不进入提交/评分体系;prompt 的两个 WebSocket consumer
连接时校验 can_access_task。补充 task/tests.py 覆盖上述行为。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 09:29:02 -06:00
xuyueandClaude Opus 5 1f6935e31e add creation
自由创作:新增 /creation 列表与详情页、Creation API 与类型定义,
TaskPanel 增加入口,PromptPanel 支持 allowSubmit 控制提交按钮。
顺带升级依赖并按 prettier 重新格式化。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 09:28:05 -06:00
xuyue 2588ea42fd update 2026-06-28 06:06:25 -06:00
xuyue fd0fffb185 update 2026-06-28 06:06:23 -06:00
xuyue 4497af940f add grade 2026-06-28 05:59:54 -06:00
xuyue 663fb8d1dc add grade 2026-06-28 05:59:50 -06:00
xuyue ae32732cf6 add grade 2026-06-25 23:55:48 -06:00
xuyue 9c652a6b3d add grade 2026-06-25 23:55:46 -06:00
xuyue 29bb89a257 add grade 2026-06-25 23:49:38 -06:00
xuyue c4196e61e9 add grade 2026-06-25 23:49:35 -06:00
xuyue 681c6ff4f4 update 2026-06-14 06:32:09 -06:00
xuyue 5bb8a1eaa3 update 2026-06-11 21:24:50 -06:00
xuyue 4f288a1fef fix 2026-06-11 21:22:02 -06:00
xuyue a335eb22e8 fix 2026-06-11 21:08:40 -06:00
xuyue c12c77ac7e fix 2026-06-11 21:08:35 -06:00
xuyue 8cddff6684 fix 2026-06-11 20:49:27 -06:00
xuyue 3102e1178a fix 2026-06-11 20:48:51 -06:00
xuyue a15b3d9c76 rating when ai is steaming 2026-06-11 19:53:15 -06:00
xuyue 6938133775 rating when ai is steaming 2026-06-11 19:53:13 -06:00
xuyue 05ecf6bebf update 2026-06-11 22:35:14 +08:00
xuyue 54d9861bd8 update 2026-06-11 22:21:59 +08:00
xuyue 596ceec880 fix 2026-06-10 20:29:40 -06:00
xuyue 6f99688667 update 2026-06-07 05:50:51 -06:00
xuyue cd6d67ac97 update 2026-06-07 05:50:47 -06:00
xuyue 4b32330b60 check if stable 2026-06-07 05:05:52 -06:00
xuyue 9fbab91cf9 check if stale 2026-06-07 05:05:46 -06:00
xuyue 39051980df fix 2026-06-02 20:56:57 -06:00
xuyue 1566a4e275 update 2026-06-02 20:25:41 -06:00
xuyue 4660b51de3 fix 2026-05-09 01:30:39 -06:00
xuyue f7817d8c26 fix 2026-05-09 01:30:36 -06:00
xuyue 48e6ddeeac add ds thinking 2026-05-07 21:25:34 -06:00
xuyue 53a0759507 add ds thinking 2026-05-07 21:25:25 -06:00
xuyue e2b3f61863 fix 2026-05-07 21:08:19 -06:00
xuyue 2a93c4d19c update 2026-05-07 10:16:14 -06:00
xuyue 1e160d192b add prompt assistant 2026-05-07 09:51:54 -06:00
xuyue 22c3b65e28 add prompt assistant 2026-05-07 09:51:47 -06:00
xuyue a46848b1c9 feat: add guidance LLM helpers and system prompt 2026-05-07 09:26:09 -06:00
xuyue 7daf62cbaf fix 2026-05-07 08:48:16 -06:00
xuyue 31671d8006 fix actions 2026-05-07 08:45:59 -06:00
xuyue 7a72c94238 fix 2026-05-07 08:45:34 -06:00
xuyue efb535eb3d update 2026-05-07 01:31:14 -06:00
xuyue 819b7a82f4 fix 2026-05-07 00:57:15 -06:00
xuyue 0180f6e803 test 2026-05-07 00:56:39 -06:00
xuyue 80aa091602 update 2026-05-06 20:41:51 -06:00
xuyue 983e87403c style: refine prompt history selection state 2026-05-06 07:34:37 -06:00
xuyue 5aaba42068 update 2026-05-06 07:30:12 -06:00
xuyue 19c26dc5b7 update 2026-05-06 07:24:31 -06:00
xuyue 5ecf8caf83 update 2026-05-06 07:24:27 -06:00
xuyue 8845845bf0 add message history 2026-05-06 07:13:06 -06:00
xuyue 2b216878ca add message history 2026-05-06 07:12:52 -06:00
xuyue 4ce19c5e40 update static files 2026-05-06 06:42:37 -06:00
xuyue 77aca640ac add challenge author 2026-05-06 06:28:49 -06:00
xuyue 455d684bd4 add challenge author 2026-05-06 06:28:39 -06:00
xuyue 9a8e5ad48e add view count 2026-05-05 19:16:58 -06:00
xuyue 4af9ae90c9 fix 2026-05-05 10:03:52 -06:00
xuyue f63f7cbbce fix 2026-05-05 10:00:40 -06:00
xuyue 21e3a7f39b revert 2026-05-05 09:53:04 -06:00
xuyue f255367b08 fix 2026-05-05 09:28:32 -06:00
xuyue edbf66874b fix back 2026-05-05 09:24:30 -06:00
xuyue e8992edabc use naive-ui for default 2026-05-05 09:18:55 -06:00
xuyue f3eed84f7c fix 2026-05-05 09:01:38 -06:00
xuyue b5e0421fd4 fix 2026-05-05 08:42:17 -06:00
xuyue c0084462eb update 2026-05-05 06:59:09 -06:00
xuyue 5fced6b4c2 fix preview 2026-05-02 09:35:14 -06:00
xuyue 2e6e3aacec update 2026-05-02 09:15:49 -06:00
xuyue 64dc1c9234 update 2026-05-02 08:07:56 -06:00
xuyue 2abf95888b feat: add admin gradebook page 2026-05-02 08:01:15 -06:00
xuyue eff635fb49 feat: add gradebook frontend API types 2026-05-02 08:01:04 -06:00
xuyue 57df250b55 feat: expose gradebook API and CSV export 2026-05-02 07:56:19 -06:00
xuyue b10e030298 feat: add gradebook aggregation service 2026-05-02 07:55:06 -06:00
xuyue 274b5b1981 test: add gradebook API coverage 2026-05-02 07:53:30 -06:00
xuyue 3136be2df7 chore: ignore worktrees 2026-05-01 08:44:59 -06:00
xuyue 0998ee0f4b chore: ignore worktrees 2026-05-01 08:44:59 -06:00
xuyue 99ec8cdf02 add showcase manage 2026-05-01 08:24:30 -06:00
xuyue efecef4e98 add showcase manage 2026-05-01 08:24:20 -06:00
xuyue 17948a69f3 fix 2026-04-30 10:14:53 -06:00
xuyue f025ebfa2e update UI 2026-04-30 09:54:24 -06:00
xuyue 375a78b852 fix chain modal 2026-04-30 09:42:38 -06:00
xuyue e522765e3e fix chain modal 2026-04-30 09:42:31 -06:00
xuyue c4362321e5 rm test file 2026-04-30 09:30:18 -06:00