136 lines
3.6 KiB
TypeScript
136 lines
3.6 KiB
TypeScript
import { MockMethod } from 'vite-plugin-mock'
|
||
|
||
let tasks = [
|
||
{
|
||
id: 1,
|
||
title: 'Learn Vue 3',
|
||
description: 'Study Composition API and script setup',
|
||
dueDate: '2023-12-31',
|
||
status: 'pending'
|
||
},
|
||
{
|
||
id: 2,
|
||
title: 'Master TypeScript',
|
||
description: 'Understand generics and utility types',
|
||
dueDate: '2023-11-30',
|
||
status: 'completed'
|
||
},
|
||
{
|
||
id: 3,
|
||
title: 'Element Plus Basics',
|
||
description: 'Learn grid system and basic components',
|
||
dueDate: '2024-01-15',
|
||
status: 'pending'
|
||
}
|
||
]
|
||
|
||
export default [
|
||
{
|
||
url: '/api/study-tasks',
|
||
method: 'get',
|
||
response: () => {
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: tasks
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/study-tasks/detail',
|
||
method: 'get',
|
||
response: ({ query }: { query: any }) => {
|
||
const id = Number(query.id)
|
||
const task = tasks.find(t => t.id === id)
|
||
|
||
if (!task) {
|
||
return {
|
||
code: 1,
|
||
message: 'Task not found'
|
||
}
|
||
}
|
||
|
||
// Enrich with detail data
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: {
|
||
...task,
|
||
// Extra fields for detail view
|
||
videoUrl: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
|
||
tag: '服务岗位',
|
||
longDescription: '争吵打架争吵打架争吵打架争吵打架争吵打架争吵打架争吵打架争吵打架争吵打架\n\n员工和员工之间发生吵架、打架;与顾客发生争吵、打架。员工和员工之间发生吵架、打架;与顾客发生争吵。',
|
||
evaluationContent: '争吵打架争吵打架争吵打架争吵打架争吵打架',
|
||
standardImages: [
|
||
'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
|
||
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
|
||
'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg',
|
||
'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg'
|
||
],
|
||
livePhotos: [
|
||
'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg',
|
||
'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg'
|
||
],
|
||
lastDeduction: {
|
||
photos: [
|
||
'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg'
|
||
],
|
||
suggestion: '工作期间应该注重仪容仪表工作期间应该注重仪容仪表',
|
||
score: -3
|
||
},
|
||
score: 999,
|
||
rule: '一次性扣除',
|
||
deduction: -999
|
||
}
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/study-tasks',
|
||
method: 'post',
|
||
response: ({ body }: { body: any }) => {
|
||
const newTask = {
|
||
id: tasks.length > 0 ? Math.max(...tasks.map(t => t.id)) + 1 : 1,
|
||
...body
|
||
}
|
||
tasks.push(newTask)
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: newTask
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/study-tasks',
|
||
method: 'put',
|
||
response: ({ body }: { body: any }) => {
|
||
const index = tasks.findIndex(t => t.id === body.id)
|
||
if (index !== -1) {
|
||
tasks[index] = { ...tasks[index], ...body }
|
||
return {
|
||
code: 0,
|
||
message: 'ok',
|
||
data: tasks[index]
|
||
}
|
||
}
|
||
return {
|
||
code: 1,
|
||
message: 'Task not found'
|
||
}
|
||
}
|
||
},
|
||
{
|
||
url: '/api/study-tasks',
|
||
method: 'delete',
|
||
response: ({ query }: { query: any }) => {
|
||
const id = Number(query.id)
|
||
tasks = tasks.filter(t => t.id !== id)
|
||
return {
|
||
code: 0,
|
||
message: 'ok'
|
||
}
|
||
}
|
||
}
|
||
] as MockMethod[]
|