feat(举手与协作): 顶栏「N 人举手」点开按题分组带错法;看板多一列「在写」点了就能看他的代码;帮完了回看板、还有人就「下一个」

学生那边按钮写「xuyue 在帮你 / 在看你的代码」。顺带修了老师接单后编辑器里留着自己的
草稿或模板、学生的代码插在前面、两边从此不一致的问题。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-13 13:04:57 +08:00
1 parent 573a0f967f
commit 1fcd12f6f4
13 files changed
+621 -178

No files matched your search

+10 -2
View File
@@ -66,9 +66,17 @@ export function useCollabDoc() {
const ytext = doc.getText("codemirror")
awareness = new awarenessProtocol.Awareness(doc)
// ★ 顺序不能反:先把内容写进 ytext,再挂 yCollab。
// yCollab 挂上去时会用 ytext 覆盖编辑器内容,先挂就会把学生的代码清空。
// ★ 先把内容写进 ytext,再挂 yCollab。yCollab 挂上去**不会**拿 ytext 覆盖编辑器,
// 只同步此后的改动 —— 所以两边挂之前编辑器里的内容必须和 ytext 一致:
// 学生端 ytext = 编辑器内容(种子);教师端 ytext 是空的,编辑器也得清空。
if (seedContent) ytext.insert(0, seedContent)
// 教师端编辑器里原本是老师自己这道题的草稿或模板。不清的话它一直留在老师那边,学生的代码
// 同步过来插在它前面,两边从此不一致(实测:老师看到两行一样的 input(),学生只有一行)。
// 清空会顺着 v-model 写回 codeStore,但协作中的老师不存草稿(ProblemEditor 的 persistCode),
// 结束后 loadCode 会把他的草稿读回来
if (seedContent === null && editorView.state.doc.length) {
editorView.dispatch({ changes: { from: 0, to: editorView.state.doc.length, insert: "" } })
}
const send = (build: (encoder: any) => void) => {
const encoder = encoding.createEncoder()