lingxixue-admin/playground/src/api/service/org/classroom-monitor.ts
shawko 228ee4ba68
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
fix: 监控页面改为自己绑定的班级
2026-05-11 10:56:40 +08:00

150 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { PageResponse } from '#/api/http'
import { get, post } from '#/api/http'
export type ClassroomItem = {
id: number | string
name: string
/** 1 监控开启0 关闭 */
monitorState?: number
}
export type ClassMonitorCurrent = {
classId: number | string
intervalMs: number
monitoring: boolean
sessionId: number | string
startTime: string
teacherId: number | string
}
export type ClassMonitorSnapshot = {
avatar: string
latestTs: number
latestUrl: string
staleSeconds: number
studentId: number | string
studentName: string
}
export type ClassMonitorStudentSnapshot = {
ts: number
url: string
}
export type ClassMonitorSessionRow = {
classId: number | string
className: string
durationSec: number
endTime: string
intervalMs: number
schoolId: number | string
sessionId: number | string
snapshotCount: number
startTime: string
status: number
studentCount: number
teacherId: number | string
teacherName: string
}
/** `/school/classMonitor/sessionDetail` 中 data 内单条学生(与列表快照字段接近,可能含 snapshotCount */
export type ClassMonitorSessionDetailStudent = {
avatar: string
latestTs: number
latestUrl: string
snapshotCount?: number
staleSeconds?: number
studentId: number | string
studentName: string
}
/** `/school/classMonitor/sessionDetail` 返回的 data 对象 */
export type ClassMonitorSessionDetail = {
classId: number | string
className: string
durationSec: number
endTime: string
intervalMs: number
schoolId: number | string
sessionId: number | string
snapshotCount: number
startTime: string
status: number
studentCount: number
students: ClassMonitorSessionDetailStudent[]
teacherId: number | string
teacherName: string
}
/** 分页里的扩展字段 rainbow 暂不消费 */
export type ClassMonitorSessionsPage = PageResponse<ClassMonitorSessionRow> & {
rainbow?: unknown[]
}
class ClassroomMonitorService {
/** 教师名下班级列表,与 `/api/main/org/class/listByTeacher` 一致 */
async getClassList(): Promise<ClassroomItem[]> {
const res = await get<any>('/org/class/listByTeacher')
const list = Array.isArray(res) ? res : (res?.rows ?? res?.data ?? [])
return list as ClassroomItem[]
}
async getCurrent(classId: number | string) {
return await get<ClassMonitorCurrent>('/school/classMonitor/current', {
classId,
})
}
async getLatestSnapshots(classId: number | string) {
return await get<ClassMonitorSnapshot[]>(
'/school/classMonitor/latestSnapshots',
{ classId },
)
}
async getStudentSnapshots(
sessionId: number | string,
studentId: number | string,
) {
return await get<ClassMonitorStudentSnapshot[]>(
'/school/classMonitor/studentSnapshots',
{ sessionId, studentId },
)
}
async getSessions(
classId: number | string,
params?: { current?: number; size?: number },
) {
return await post<ClassMonitorSessionsPage>('/school/classMonitor/sessions', {
classId,
current: params?.current ?? 1,
size: params?.size ?? 10,
})
}
async getSessionDetail(
sessionId: number | string,
classId?: number | string,
) {
const params: Record<string, number | string> = { sessionId }
if (classId !== undefined && classId !== '') {
params.classId = classId
}
return await get<ClassMonitorSessionDetail>(
'/school/classMonitor/sessionDetail',
params,
)
}
async updateMonitorStatus(classId: number | string, status: 0 | 1) {
return await post('/school/classMonitor/control', {
classId,
status,
})
}
}
export const classroomMonitorService = new ClassroomMonitorService()