学生那边按钮写「xuyue 在帮你 / 在看你的代码」。顺带修了老师接单后编辑器里留着自己的 草稿或模板、学生的代码插在前面、两边从此不一致的问题。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { useCollabStore } from "shared/store/collab"
|
|
|
|
/**
|
|
* 老师接单 / 主动打开学生的编辑器。两处入口(顶栏举手面板、课堂看板)共用。
|
|
*
|
|
* 只发消息,不跳页面:房间开好(room_open 到了)才跳到那道题,跳转统一在 CollabHost 里做
|
|
* —— 原来是点完就跳,服务端拒了(别的老师先接走、学生刚走)前端也已经跳过去了。
|
|
*
|
|
* 一个老师同时只在一个房间(服务端也拦)。这里先拦一道:不拦的话等新房间开好跳过去,
|
|
* 等于把手上这场协作断掉。返回 false = 没发出去
|
|
*/
|
|
export function useTeacherHelp() {
|
|
const collabStore = useCollabStore()
|
|
const message = useMessage()
|
|
|
|
function busy() {
|
|
if (!collabStore.room) return false
|
|
message.warning("请先结束当前协作")
|
|
return true
|
|
}
|
|
|
|
return {
|
|
help(studentId: number) {
|
|
if (busy()) return false
|
|
collabStore.accept(studentId)
|
|
return true
|
|
},
|
|
peek(studentId: number) {
|
|
if (busy()) return false
|
|
collabStore.peek(studentId)
|
|
return true
|
|
},
|
|
}
|
|
}
|