|
1
|
import { MockMethod } from 'vite-plugin-mock';
|
|
2
|
import { Random } from 'mockjs';
|
|
3
4
|
import { resultPageSuccess } from '../_util';
|
|
5
6
7
8
9
10
11
12
|
function getRandomPics(count = 10): string[] {
const arr: string[] = [];
for (let i = 0; i < count; i++) {
arr.push(Random.image('800x600', Random.color(), Random.color(), Random.title()));
}
return arr;
}
|
|
13
14
|
const demoList = (() => {
const result: any[] = [];
|
|
15
|
for (let index = 0; index < 200; index++) {
|
|
16
17
18
19
20
21
|
result.push({
id: `${index}`,
beginTime: '@datetime',
endTime: '@datetime',
address: '@city()',
name: '@cname()',
|
vben
authored
|
22
23
24
25
26
27
28
29
|
name1: '@cname()',
name2: '@cname()',
name3: '@cname()',
name4: '@cname()',
name5: '@cname()',
name6: '@cname()',
name7: '@cname()',
name8: '@cname()',
|
|
30
31
32
|
avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()),
imgArr: getRandomPics(Math.ceil(Math.random() * 3) + 1),
imgs: getRandomPics(Math.ceil(Math.random() * 3) + 1),
|
|
33
34
|
date: `@date('yyyy-MM-dd')`,
time: `@time('HH:mm')`,
|
|
35
|
'no|100000-10000000': 100000,
|
vben
authored
|
36
|
'status|1': ['normal', 'enable', 'disable'],
|
|
37
38
39
40
41
42
43
|
});
}
return result;
})();
export default [
{
|
Vben
authored
|
44
|
url: '/basic-api/table/getDemoList',
|
Vben
authored
|
45
|
timeout: 100,
|
|
46
47
48
49
50
51
52
|
method: 'get',
response: ({ query }) => {
const { page = 1, pageSize = 20 } = query;
return resultPageSuccess(page, pageSize, demoList);
},
},
] as MockMethod[];
|