table-demo.ts 1.4 KB

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