diff --git a/playground/src/router/guard.ts b/playground/src/router/guard.ts index b85c813..66a0b27 100644 --- a/playground/src/router/guard.ts +++ b/playground/src/router/guard.ts @@ -105,6 +105,14 @@ const setupAccessGuard = (router: Router) => { accessStore.setAccessMenus(accessibleMenus) accessStore.setAccessRoutes(accessibleRoutes) accessStore.setIsAccessChecked(true) + + const teacherToken = accessStore.accessToken?.trim() + if (teacherToken && window.teacherApi?.setToken) { + void window.teacherApi.setToken(teacherToken).catch((error) => { + console.warn('[guard] sync accessToken to teacher client failed', error) + }) + } + let redirectPath: string if (from.query.redirect) { redirectPath = from.query.redirect as string diff --git a/playground/src/types/global.d.ts b/playground/src/types/global.d.ts index d841532..095d410 100644 --- a/playground/src/types/global.d.ts +++ b/playground/src/types/global.d.ts @@ -6,6 +6,8 @@ interface Window { unique: number /** teacher-electron 注入,仅在桌面客户端内嵌题库页时存在 */ teacherApi?: { + /** 登录后将 accessToken 同步至教师端(纯 token,不含 `Bearer `)。 */ + setToken?: (accessToken?: string | null) => Promise startSfu: () => Promise<{ port: number; already?: boolean }> stopSfu: () => Promise /** 可选传入班级学员列表、班级名称与班级 id;名称用于教师端共享窗口标题「{名称} - 屏幕共享」,id 用于教师端业务与心跳。 */ @@ -13,15 +15,12 @@ interface Window { classStudentRows?: unknown[], className?: string, classId?: string | number, - /** 管理端当前登录 accessToken,供教师端主进程请求 teacherScreenShare 接口时带 Authorization */ - accessToken?: string | null, ) => Promise /** 打开学员屏幕监控独立窗口(teacher-electron);名称用于窗口标题,班级 id 下发至监控页。 */ openStudentScreenMonitorWindow?: ( classStudentRows?: unknown[], className?: string, classId?: string | number, - accessToken?: string | null, ) => Promise setShareClassStudentsListener?: ( cb: ((rows: unknown[]) => void) | null, diff --git a/playground/src/views/org/classroom-monitor/home.vue b/playground/src/views/org/classroom-monitor/home.vue index 2ab8b32..a6900fb 100644 --- a/playground/src/views/org/classroom-monitor/home.vue +++ b/playground/src/views/org/classroom-monitor/home.vue @@ -9,14 +9,12 @@ import type { import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue' import { useRouter } from 'vue-router' -import { useAccessStore } from '@vben/stores' import { classStudentService } from '../../../api/service/org/class-student' import { classroomMonitorService } from '../../../api/service/org/classroom-monitor' import hud from '../../../utils/hud' const router = useRouter() -const accessStore = useAccessStore() const classLoading = ref(false) const detailLoading = ref(false) @@ -276,12 +274,7 @@ async function openTeacherScreenShareWindow(item: ClassroomItem) { classId: item.id, }) const rows = (page as any)?.data?.rows ?? page?.rows ?? [] - const token = accessStore.accessToken?.trim() - if (token) { - await api.openScreenShareWindow(rows, item.name ?? '', item.id, token) - } else { - await api.openScreenShareWindow(rows, item.name ?? '', item.id) - } + await api.openScreenShareWindow(rows, item.name ?? '', item.id) } catch (error) { console.error(error) throw error @@ -308,12 +301,7 @@ async function openStudentScreenMonitorWindow(item: ClassroomItem) { classId: item.id, }) const rows = (page as any)?.data?.rows ?? page?.rows ?? [] - const token = accessStore.accessToken?.trim() - if (token) { - await openMon(rows, item.name ?? '', item.id, token) - } else { - await openMon(rows, item.name ?? '', item.id) - } + await openMon(rows, item.name ?? '', item.id) } catch (error) { console.error(error) throw error diff --git a/playground/src/views/sys/setting/debug-mgr/column.tsx b/playground/src/views/sys/setting/debug-mgr/column.tsx index aa6d1c7..23c33f4 100644 --- a/playground/src/views/sys/setting/debug-mgr/column.tsx +++ b/playground/src/views/sys/setting/debug-mgr/column.tsx @@ -12,7 +12,11 @@ export default (event: anyObj): TableColumn[] => [ width: 100, render: (h, scope) => ( - {scope.row.updateType === 1 ? 'WEB' : 'APK'} + {scope.row.updateType === 1 + ? 'WEB' + : scope.row.updateType === 2 + ? 'APK' + : 'TEA'} ), }, diff --git a/playground/src/views/sys/setting/update-mgr/column.tsx b/playground/src/views/sys/setting/update-mgr/column.tsx index aa6d1c7..23c33f4 100644 --- a/playground/src/views/sys/setting/update-mgr/column.tsx +++ b/playground/src/views/sys/setting/update-mgr/column.tsx @@ -12,7 +12,11 @@ export default (event: anyObj): TableColumn[] => [ width: 100, render: (h, scope) => ( - {scope.row.updateType === 1 ? 'WEB' : 'APK'} + {scope.row.updateType === 1 + ? 'WEB' + : scope.row.updateType === 2 + ? 'APK' + : 'TEA'} ), }, diff --git a/playground/src/views/sys/setting/update-mgr/dia.vue b/playground/src/views/sys/setting/update-mgr/dia.vue index 0420324..44ac3e6 100644 --- a/playground/src/views/sys/setting/update-mgr/dia.vue +++ b/playground/src/views/sys/setting/update-mgr/dia.vue @@ -80,7 +80,7 @@ async function handleSave(formEl: FormInstance | undefined) { await formEl.validate() await addVersion({ ...form, - model: form.updateType === 1 ? undefined : form.model, + model: form.updateType === 2 ? form.model : undefined, }) show.value = false emit('onRefresh') @@ -110,6 +110,7 @@ async function handleSave(formEl: FormInstance | undefined) { +