164 lines
5.5 KiB
TypeScript
164 lines
5.5 KiB
TypeScript
import { MockMethod } from 'vite-plugin-mock'
|
||
|
||
const courses = [
|
||
{
|
||
id: 1,
|
||
title: '餐饮职业服务管理实操从入门到精通',
|
||
chapters: 18,
|
||
learners: 3,
|
||
status: 0, // 0: 未学习, 1: 进行中, 2: 已学习
|
||
cover: 'https://dummyimage.com/300x400/409eff/ffffff&text=Service+Management',
|
||
category: 'personal_growth'
|
||
},
|
||
{
|
||
id: 2,
|
||
title: '企业前厅培训服务流程',
|
||
chapters: 18,
|
||
learners: 3,
|
||
status: 1,
|
||
cover: 'https://dummyimage.com/300x400/79bbff/ffffff&text=Front+Desk+Training',
|
||
category: 'personal_growth'
|
||
},
|
||
{
|
||
id: 3,
|
||
title: '一本书搞懂餐厅经营管理',
|
||
chapters: 18,
|
||
learners: 3,
|
||
status: 1,
|
||
cover: 'https://dummyimage.com/300x400/337ecc/ffffff&text=Restaurant+Management',
|
||
category: 'personal_growth'
|
||
},
|
||
{
|
||
id: 4,
|
||
title: '从零开始学习做餐饮管理之经营篇实操要点说明',
|
||
chapters: 18,
|
||
learners: 3,
|
||
status: 2,
|
||
cover: 'https://dummyimage.com/300x400/529b2e/ffffff&text=Zero+to+Hero',
|
||
category: 'personal_growth'
|
||
},
|
||
{
|
||
id: 5,
|
||
title: '餐饮门店营销实战',
|
||
chapters: 12,
|
||
learners: 15,
|
||
status: 0,
|
||
cover: 'https://dummyimage.com/300x400/e6a23c/ffffff&text=Marketing',
|
||
category: 'skill'
|
||
},
|
||
{
|
||
id: 6,
|
||
title: '食品安全与卫生管理',
|
||
chapters: 8,
|
||
learners: 42,
|
||
status: 2,
|
||
cover: 'https://dummyimage.com/300x400/f56c6c/ffffff&text=Safety',
|
||
category: 'rules'
|
||
}
|
||
]
|
||
|
||
// Mock Detail Data
|
||
const courseDetails = {
|
||
1: {
|
||
...courses[0],
|
||
updateTime: '2025-10-20 23:24',
|
||
totalTime: '4时 28分 38秒',
|
||
views: 18390,
|
||
completedChapters: 3,
|
||
totalChapters: 20, // Override simple list count for detail realism
|
||
outline: [
|
||
{ id: 101, title: '第1章—基础入门课程UI/UX基础入门...', type: 'video', duration: '3分23秒', status: 2 },
|
||
{ id: 102, title: '第2章—转战B端UI设计入门课程', type: 'audio', duration: '3分23秒', status: 2 },
|
||
{ id: 103, title: '第3章—多风格插画设计赋能', type: 'doc', duration: '3分23秒', status: 2 },
|
||
{ id: 104, title: '第4章—基础入门课程UI/UX基础入门...', type: 'video', duration: '暂未学习', status: 0 },
|
||
{ id: 105, title: '第5章—进阶交互设计实战', type: 'video', duration: '15分00秒', status: 0 },
|
||
{ id: 106, title: '第6章—设计系统搭建指南', type: 'doc', duration: '10页', status: 0 },
|
||
]
|
||
}
|
||
}
|
||
|
||
// Mock Chapter Detail Data
|
||
const chapterDetails = {
|
||
101: {
|
||
id: 101,
|
||
title: '第1章—基础入门课程UI/UX基础入门...',
|
||
videoUrl: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
|
||
content: '本章节主要介绍了UI/UX设计的基础概念,包括色彩理论、排版原则以及用户体验的核心要素。通过实际案例分析,帮助学员建立正确的设计思维。',
|
||
comments: [
|
||
{ id: 1, user: '范平', role: '设计师', content: '我体会到了不仅要在专业技能上有所提升用稻盛讲到“要用正确的人做我体会到了不仅要在专业技能上有所提升...', time: '1小时前', likes: 99 },
|
||
{ id: 2, user: '赵婵涛', role: 'UI设计师', content: '灵感是业余者的专属,我们专业人士只要在早上打卡上班即可。', time: '1小时前', likes: 99 },
|
||
{ id: 3, user: '巩香晓', role: '平面设计师', content: '永远不要跟别人比幸运,我从来没想过我比别人幸运,我也许比他们更有毅力,在最困难的时候,他们熬不住了,我可以多熬一秒钟。', time: '1小时前', likes: 99 }
|
||
]
|
||
},
|
||
102: {
|
||
id: 102,
|
||
title: '第2章—转战B端UI设计入门课程',
|
||
videoUrl: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
|
||
content: 'B端设计注重效率和逻辑。本章深入探讨B端产品的特点,如何构建清晰的信息架构,以及复杂表单和数据可视化的设计技巧。',
|
||
comments: []
|
||
}
|
||
}
|
||
|
||
export default [
|
||
{
|
||
url: '/api/training/courses',
|
||
method: 'get',
|
||
response: ({ query }: { query: any }) => {
|
||
const { category, type } = query
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: {
|
||
list: courses,
|
||
stats: {
|
||
learned: 5,
|
||
total: 15
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/training/course/detail',
|
||
method: 'get',
|
||
response: ({ query }: { query: any }) => {
|
||
const { id } = query
|
||
const numericId = Number(id)
|
||
const detail = courseDetails[numericId as keyof typeof courseDetails] || {
|
||
...courses.find(c => c.id === numericId) || courses[0],
|
||
updateTime: '2025-10-20 23:24',
|
||
totalTime: '2时 15分 00秒',
|
||
views: 1205,
|
||
completedChapters: 0,
|
||
totalChapters: 18,
|
||
outline: [
|
||
{ id: 201, title: '第1章—课程介绍', type: 'video', duration: '5分00秒', status: 0 },
|
||
{ id: 202, title: '第2章—基础知识', type: 'video', duration: '10分00秒', status: 0 }
|
||
]
|
||
}
|
||
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: detail
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/training/chapter/detail',
|
||
method: 'get',
|
||
response: ({ query }: { query: any }) => {
|
||
const { id } = query
|
||
const numericId = Number(id)
|
||
// Default to chapter 101 if not found for demo purposes
|
||
const detail = chapterDetails[numericId as keyof typeof chapterDetails] || chapterDetails[101]
|
||
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: detail
|
||
}
|
||
}
|
||
}
|
||
] as MockMethod[]
|