Blame view

mock/demo/select-demo.ts 641 Bytes
1
2
3
import { MockMethod } from 'vite-plugin-mock';
import { resultSuccess } from '../_util';
4
const demoList = (keyword, count = 20) => {
5
  const result = {
vben authored
6
    list: [] as any[],
7
  };
8
  for (let index = 0; index < count; index++) {
9
    result.list.push({
10
      name: `${keyword ?? ''}选项${index}`,
11
      id: `${index}`,
12
13
14
    });
  }
  return result;
15
};
16
17
18

export default [
  {
19
    url: '/basic-api/select/getDemoOptions',
20
    timeout: 1000,
21
    method: 'get',
22
    response: ({ query }) => {
23
      const { keyword, count } = query;
24
      console.log(keyword);
25
      return resultSuccess(demoList(keyword, count));
26
27
28
    },
  },
] as MockMethod[];