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:
1 parent
fe41ebb7d6
commit
d0830f6830
61 files changed
+7026
-93
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
} from '@classhelper/shared';
|
||||
import { socketUrlOf } from '../config.js';
|
||||
import { pushCallToIsland, pushHomeworkToIsland, pushNotificationToIsland } from '../island/bridge.js';
|
||||
import { useAppStore } from './app.js';
|
||||
|
||||
type RealtimeEventName = keyof ServerToClientEvents;
|
||||
type EventHandler = (payload: unknown) => void;
|
||||
@@ -22,6 +23,18 @@ type EventHandler = (payload: unknown) => void;
|
||||
* 还会把数据写回 IndexedDB,保证断网时看到的是最后同步到的内容。
|
||||
*/
|
||||
export const useRealtimeStore = defineStore('realtime', () => {
|
||||
const app = useAppStore();
|
||||
|
||||
/**
|
||||
* 本机要不要弹这次提醒。
|
||||
*
|
||||
* 教室在设置页选了「只在 ClassIsland 上弹」时,客户端仍然把通知收进通知中心(列表里有记录、
|
||||
* 未读红点照常),但**不再弹窗、也不上岛** —— 否则老师会看到两个地方同时炸出来。
|
||||
*/
|
||||
function popupLocally(): boolean {
|
||||
return app.shouldPopupLocally();
|
||||
}
|
||||
|
||||
const connected = ref(false);
|
||||
const connecting = ref(false);
|
||||
const lastEventName = ref<string | null>(null);
|
||||
@@ -65,14 +78,16 @@ export const useRealtimeStore = defineStore('realtime', () => {
|
||||
|
||||
instance.on(SOCKET_EVENTS.notificationNew, (payload: NotificationDto) => {
|
||||
mark(SOCKET_EVENTS.notificationNew);
|
||||
ElMessage({
|
||||
message: `【${PRIORITY_LABELS[payload.priority] ?? payload.priority}】${payload.title}`,
|
||||
type: payload.priority === 'URGENT' ? 'error' : 'info',
|
||||
duration: 5000,
|
||||
showClose: true,
|
||||
});
|
||||
// 投递到桌面灵动岛:紧急通知立即展开;上课期间的非紧急通知会暂存,下课后自动弹出
|
||||
pushNotificationToIsland(payload);
|
||||
if (popupLocally()) {
|
||||
ElMessage({
|
||||
message: `【${PRIORITY_LABELS[payload.priority] ?? payload.priority}】${payload.title}`,
|
||||
type: payload.priority === 'URGENT' ? 'error' : 'info',
|
||||
duration: 5000,
|
||||
showClose: true,
|
||||
});
|
||||
// 投递到桌面灵动岛:紧急通知立即展开;上课期间的非紧急通知会暂存,下课后自动弹出
|
||||
pushNotificationToIsland(payload);
|
||||
}
|
||||
dispatch(SOCKET_EVENTS.notificationNew, payload);
|
||||
});
|
||||
|
||||
@@ -86,14 +101,16 @@ export const useRealtimeStore = defineStore('realtime', () => {
|
||||
|
||||
instance.on(SOCKET_EVENTS.callNew, (payload: NotificationDto) => {
|
||||
mark(SOCKET_EVENTS.callNew);
|
||||
ElMessage({
|
||||
message: payload.title,
|
||||
type: 'warning',
|
||||
duration: 8000,
|
||||
showClose: true,
|
||||
});
|
||||
// 叫人:无论是否上课都立即展开(老师正在等这位同学)
|
||||
pushCallToIsland(payload);
|
||||
if (popupLocally()) {
|
||||
ElMessage({
|
||||
message: payload.title,
|
||||
type: 'warning',
|
||||
duration: 8000,
|
||||
showClose: true,
|
||||
});
|
||||
// 叫人:无论是否上课都立即展开(老师正在等这位同学)
|
||||
pushCallToIsland(payload);
|
||||
}
|
||||
dispatch(SOCKET_EVENTS.callNew, payload);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user