feat(teacher): 连接 Yuxi 老师并提供项目与会话只读工具

This commit is contained in:
2026-09-23 09:56:11 +08:00
parent 1f2ad3fb3a
commit e35a13079e
14 changed files with 886 additions and 30 deletions

View File

@@ -24,10 +24,11 @@ export async function handleCodingTeacherRoutes(
/^\/api\/coding\/teacher-preview\/topics(?:\/([^/]+))?(?:\/(messages|events|save|requests\/([^/]+)\/cancel))?$/
);
const config = url.pathname === '/api/coding/teacher/config';
const catalog = url.pathname === '/api/coding/teacher/teachers';
const draft = url.pathname === '/api/coding/teacher-preview';
const pending = url.pathname === '/api/coding/teacher-preview/pending-link';
if (!source && !preview && !config && !draft && !pending) return false;
if ((config || draft || pending) && req.method !== 'GET') {
if (!source && !preview && !config && !catalog && !draft && !pending) return false;
if ((config || catalog || draft || pending) && req.method !== 'GET') {
sendJson(res, 405, { error: '不支持此操作。' });
return true;
}
@@ -41,6 +42,10 @@ export async function handleCodingTeacherRoutes(
return true;
}
try {
if (catalog) {
sendJson(res, 200, await service.catalog());
return true;
}
if (config && req.method === 'GET') {
sendJson(res, 200, await service.definition());
return true;
@@ -63,8 +68,8 @@ export async function handleCodingTeacherRoutes(
return true;
}
if (!id && req.method === 'POST') {
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string }>(req);
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext));
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string; teacherVersion?: number }>(req);
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext, body.teacherVersion));
return true;
}
if (id && !action && req.method === 'GET') {