- 重写课表档案工作区并合并时间表、课表与完整档案导入导出 - 修复课前/上下课提醒遮罩与通知收回冲突 - 增加课件文件夹分类、教师归档路径和客户端本机归档 - 打通客户端下载/安装/完成状态上报并在管理端展示更新过程 - 修复侧栏折叠裁切、课时多选与上传控件样式 - 统一版本到 1.4.1
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { z } from 'zod';
|
|
import { COURSEWARE_MAX_BYTES } from '@classhelper/shared';
|
|
|
|
export const coursewareScopeSchema = z.object({ classIds: z.array(z.string().min(1).max(100)).max(100) });
|
|
const folderPath = z
|
|
.string()
|
|
.trim()
|
|
.min(1)
|
|
.max(240)
|
|
.refine(
|
|
(value) =>
|
|
value
|
|
.split('/')
|
|
.every(
|
|
(part) =>
|
|
part.length > 0 &&
|
|
part.length <= 60 &&
|
|
!/[<>:"\\|?*\u0000-\u001f]/.test(part) &&
|
|
!/[. ]$/.test(part) &&
|
|
!/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(part),
|
|
),
|
|
'文件夹名称无效,请使用 / 分隔子文件夹',
|
|
);
|
|
export const coursewareFolderSchema = z.object({ path: folderPath });
|
|
export const coursewareMoveSchema = z.object({ folderPath: folderPath.or(z.literal('')) });
|
|
export const coursewareUploadSchema = coursewareScopeSchema
|
|
.extend({
|
|
name: z
|
|
.string()
|
|
.trim()
|
|
.min(1)
|
|
.max(180)
|
|
.refine(
|
|
(name) => !/[<>:"/\\|?*\u0000-\u001f]/.test(name) && !name.endsWith('.') && !name.endsWith(' '),
|
|
'文件名含无效字符',
|
|
),
|
|
size: z.number().int().min(1).max(COURSEWARE_MAX_BYTES),
|
|
mode: z.enum(['cloud', 'push']),
|
|
folderPath: folderPath.or(z.literal('')).optional(),
|
|
})
|
|
.refine((input) => input.mode !== 'push' || input.classIds.length > 0, '推送时请选择授课班级');
|
|
export const coursewareUploadQuery = z.object({
|
|
metadata: z
|
|
.string()
|
|
.transform((value, ctx): unknown => {
|
|
try {
|
|
return JSON.parse(value);
|
|
} catch {
|
|
ctx.addIssue({ code: 'custom', message: '上传信息格式错误' });
|
|
return z.NEVER;
|
|
}
|
|
})
|
|
.pipe(coursewareUploadSchema),
|
|
});
|
|
export const coursewareDeviceQuery = z.object({ deviceKey: z.string().min(1).max(100) });
|