feat(integrations,classisland,server,web,desktop): ClassIsland 联动插件——上报课表与上课状态、下发提醒并回执、教室端推送通道

教室机器上的 ClassIsland 现在可以直接和班级小助手互通:插件走 /api/integrations/classisland/*,用设备令牌(X-ClassIsland-Token,库里只存 sha256)独立鉴权,不占用 JWT 通道。

- 服务端:新增 integrations 模块(上报 / 待弹出 / 回执 / 课表镜像 / 回写),两个迁移(设备令牌表、Class.notificationChannel);通知、叫人、联动页下发统一复用 pushToClassIsland,避免"某个页面发的通知不联动"
- 插件:packages/classisland-plugin(.NET 8,独立于 pnpm workspace)——BridgeService 上报与提醒轮询、ScheduleMapper/ClassPlanWriter 课表镜像、Avalonia 设置页、ClassHelperNotificationProvider 在 ClassIsland 上弹出提醒;本地/内网地址强制直连,躲开系统代理返回的假 404
- 客户端:设置页可选提醒通道(both / client / classisland),并订阅相应实时事件
- Web 端:新增「ClassIsland 联动」页(设备管理与提醒下发)
- 校验与打包:verify:classisland(需后端)、verify:classisland-plugin(静态契约 54 项)、build/dist:classisland-plugin 产出 .cipx
- 文档:README 与 AGENTS.md 同步新增联动说明,docs/screenshots/classisland 留三张真机截图

门禁:pnpm lint 0 error、pnpm typecheck 四包通过、verify:classisland-plugin 54/54 通过。运行期仍需在装了 ClassIsland 的机器上实测(步骤见 AGENTS.md §8)。
This commit is contained in:
LoveChengke committed 2026-09-27 14:59:12 +08:00
1 parent fe41ebb7d6
commit d0830f6830
61 files changed
+7026 -93

No files matched your search

+31
View File
@@ -11,6 +11,7 @@ import {
type CreateCourseRequest,
type CreateGradeRequest,
type CreateHomeworkRequest,
type CreateIntegrationDeviceRequest,
type CreateNotificationRequest,
type CreateScheduleRequest,
type DashboardSummary,
@@ -18,11 +19,15 @@ import {
type GradeStats,
type HomeworkDto,
type HomeworkSubmissionsDto,
type IntegrationDeviceDto,
type IntegrationDeviceTokenDto,
type LoginRequest,
type LoginResponse,
type NotificationDto,
type ScheduleDto,
type ScheduleWeekView,
type SendClassIslandNotificationRequest,
type SendClassIslandNotificationResult,
type StudentDto,
type TableImportPreview,
type TableImportResult,
@@ -31,6 +36,7 @@ import {
type TimeLayoutParsePreview,
type UpdateClassAccountRequest,
type UpdateClassRequest,
type UpdateIntegrationDeviceRequest,
type UserDto,
} from '@classhelper/shared';
import { api } from './http';
@@ -292,3 +298,28 @@ export const importApi = {
payload: unknown;
}): Promise<ClassPlanImportResultDto> => api.post(`${API_PATHS.imports}/class-plan`, payload),
};
/* ------------------------------------------------------------------ ClassIsland 联动 */
/**
* 联动设备管理 + 提醒下发。
*
* 设备令牌(chci_...)只在**创建**与**重置**两个接口的返回值里出现一次,
* 其余接口永远只回 tokenHint(前缀提示),因此拿到 token 后要立刻提示老师复制保存。
*/
export const integrationApi = {
listDevices: (classId?: string): Promise<IntegrationDeviceDto[]> =>
api.get(`${API_PATHS.integrations}/devices`, classId ? { classId } : undefined),
createDevice: (payload: CreateIntegrationDeviceRequest): Promise<IntegrationDeviceTokenDto> =>
api.post(`${API_PATHS.integrations}/devices`, payload),
updateDevice: (id: string, payload: UpdateIntegrationDeviceRequest): Promise<IntegrationDeviceDto> =>
api.patch(`${API_PATHS.integrations}/devices/${id}`, payload),
/** 重置令牌:旧令牌立即失效,插件需要重新填写 */
resetToken: (id: string): Promise<IntegrationDeviceTokenDto> =>
api.post(`${API_PATHS.integrations}/devices/${id}/token`, {}),
removeDevice: (id: string): Promise<{ id: string }> =>
api.delete(`${API_PATHS.integrations}/devices/${id}`),
/** 把一条提醒下发到该班的 ClassIsland 设备(ClassIsland 上全屏弹出) */
notify: (payload: SendClassIslandNotificationRequest): Promise<SendClassIslandNotificationResult> =>
api.post(`${API_PATHS.integrations}/classisland/notify`, payload),
};