Files
root a1daa040ef s
2026-06-07 18:06:52 +08:00

20 lines
620 B
TypeScript
Raw Permalink 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.
/**
* 课程解锁 - 校验登录态 + VIP/api/digital/vip/check
* 与 join 报名支付分离,课程解锁用 VIP 状态
*/
/** 第一模块前 2 节可试看,其余章节需 VIP 解锁 */
export function isFreeTrial(moduleIndex: number, lessonIndex: number): boolean {
return moduleIndex === 0 && lessonIndex < 2;
}
/** 章节是否可观看(需传入 vip 状态,来自 useAuthAndVip 或 /api/digital/vip/check */
export function canWatchLesson(
moduleIndex: number,
lessonIndex: number,
vip: boolean
): boolean {
if (isFreeTrial(moduleIndex, lessonIndex)) return true;
return vip;
}