| 123456789101112131415161718192021222324252627 |
- import type { AiCoursewarePage } from "@/api/aiCourseware"
- // 资源身份、静态谱图与装饰配图分别判断,不能用封面图冒充曲谱。
- export const usableResourceUrl = (value?: string) => /^(https?:\/\/|data:(image|audio|video)\/)/i.test(value || "")
- export const scoreBinding = (page: AiCoursewarePage) => (page.resourceBindings || [])
- .find(item => item.verified === true && item.resourceType === "MUSIC" && Boolean(item.resourceId))
- export const audioBindings = (page: AiCoursewarePage) => (page.resourceBindings || [])
- .filter(item => item.verified === true && item.resourceType === "SONG" && usableResourceUrl(item.contentUrl))
- export const isScorePage = (page: AiCoursewarePage) => /melody|score/.test(page.type || "") || Boolean(scoreBinding(page))
- export const needsAudio = (page: AiCoursewarePage) => /listen|phrase_sing|expressive_sing/.test(page.type || "") ||
- (page.resourceBindings || []).some(item => item.required && item.resourceType === "SONG")
- // 只识别明确的教案表述,保留“观察图片”“跟老师唱”等有效学生指令。
- export const isTeacherFacingText = (text?: string) => /(?:教师|老师)(?:讲述|提问|引导|指导|组织|巡视|示范)|(?:引导|指导|组织)学生|(?:激发|产生|建立)(?:学生)?(?:兴趣|期待|好奇)|学习表现[::]|复述课后任务要求|回顾并口头总结本课所学/.test(text || "")
- export function teacherFacingTexts(page: AiCoursewarePage): string[] {
- return [page.studentContent?.headline, page.classroomAction?.studentTask, page.subtitle,
- ...(page.studentContent?.points || []), ...(page.bullets || [])]
- .filter((text): text is string => Boolean(text) && isTeacherFacingText(text))
- }
- export function studentTexts(page: AiCoursewarePage): string[] {
- return [page.title, page.studentContent?.headline, page.classroomAction?.studentTask,
- ...(page.studentContent?.points?.length ? page.studentContent.points : page.bullets || []),
- page.interaction?.question, ...(page.interaction?.options || [])]
- .map(text => String(text || "").trim()).filter(text => Boolean(text) && !isTeacherFacingText(text))
- }
|