Template
feat: 重构页面、路由与业务组件,新增课程演示
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d3ae0a8ca7
commit
7b326ee025
29 files changed
+2005
-57
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import type {
|
||||
CourseCategory,
|
||||
CourseFlowProgress,
|
||||
CourseResource,
|
||||
CourseResourceCategory,
|
||||
} from "./CourseDemo.types";
|
||||
|
||||
export const courseResources: CourseResource[] = [
|
||||
{
|
||||
id: "policy-video",
|
||||
title: "资助政策微课",
|
||||
description: "了解国家助学政策和申请条件",
|
||||
category: "policy",
|
||||
icon: "🎬",
|
||||
},
|
||||
{
|
||||
id: "policy-guide",
|
||||
title: "申请流程图",
|
||||
description: "按步骤核对材料与办理节点",
|
||||
category: "policy",
|
||||
icon: "🗺️",
|
||||
},
|
||||
{
|
||||
id: "practice-case",
|
||||
title: "诚信申请案例",
|
||||
description: "判断案例中的规范与风险",
|
||||
category: "practice",
|
||||
icon: "🧩",
|
||||
},
|
||||
{
|
||||
id: "practice-checklist",
|
||||
title: "材料自查清单",
|
||||
description: "动手检查课程中的模拟材料",
|
||||
category: "practice",
|
||||
icon: "✅",
|
||||
},
|
||||
{
|
||||
id: "support-qa",
|
||||
title: "常见问题答疑",
|
||||
description: "查找填报和审核中的常见问题",
|
||||
category: "support",
|
||||
icon: "💬",
|
||||
},
|
||||
{
|
||||
id: "support-contact",
|
||||
title: "校园咨询渠道",
|
||||
description: "联系辅导员与学生资助中心",
|
||||
category: "support",
|
||||
icon: "☎️",
|
||||
},
|
||||
];
|
||||
|
||||
export const courseCategories: CourseCategory[] = [
|
||||
{
|
||||
id: "policy",
|
||||
title: "政策学习",
|
||||
description: "帮助理解政策与办理流程",
|
||||
icon: "📚",
|
||||
},
|
||||
{
|
||||
id: "practice",
|
||||
title: "互动实践",
|
||||
description: "需要判断、检查或动手完成",
|
||||
icon: "🧠",
|
||||
},
|
||||
{
|
||||
id: "support",
|
||||
title: "学习支持",
|
||||
description: "遇到问题时可以随时查阅",
|
||||
icon: "🤝",
|
||||
},
|
||||
];
|
||||
|
||||
export function createEmptyProgress(): CourseFlowProgress {
|
||||
return {
|
||||
placed: { policy: [], practice: [], support: [] },
|
||||
completed: false,
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
export function parseProgress(content: string): CourseFlowProgress | null {
|
||||
try {
|
||||
const value = JSON.parse(content) as Partial<CourseFlowProgress>;
|
||||
if (!value.placed || typeof value.placed !== "object") return null;
|
||||
const placed = Object.fromEntries(
|
||||
courseCategories.map(({ id }) => [
|
||||
id,
|
||||
Array.isArray(value.placed?.[id])
|
||||
? value.placed[id].filter((item): item is string =>
|
||||
courseResources.some(
|
||||
(resource) => resource.id === item && resource.category === id,
|
||||
),
|
||||
)
|
||||
: [],
|
||||
]),
|
||||
) as Record<CourseResourceCategory, string[]>;
|
||||
const placedCount = Object.values(placed).flat().length;
|
||||
return {
|
||||
placed,
|
||||
completed: placedCount === courseResources.length,
|
||||
updatedAt: value.updatedAt ?? new Date().toISOString(),
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user