tree-demo.ts 922 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { MockMethod } from 'vite-plugin-mock';
  2. import { resultSuccess, baseUrl } from '../_util';
  3. const demoTreeList = (keyword) => {
  4. const result = {
  5. list: [] as Recordable[],
  6. };
  7. for (let index = 0; index < 5; index++) {
  8. const children: Recordable[] = [];
  9. for (let j = 0; j < 3; j++) {
  10. children.push({
  11. title: `${keyword ?? ''}选项${index}-${j}`,
  12. value: `${index}-${j}`,
  13. key: `${index}-${j}`,
  14. });
  15. }
  16. result.list.push({
  17. title: `${keyword ?? ''}选项${index}`,
  18. value: `${index}`,
  19. key: `${index}`,
  20. children,
  21. });
  22. }
  23. return result;
  24. };
  25. export default [
  26. {
  27. url: `${baseUrl}/tree/getDemoOptions`,
  28. timeout: 1000,
  29. method: 'get',
  30. response: ({ query }) => {
  31. const { keyword } = query;
  32. console.log("查询条件:", keyword);
  33. return resultSuccess(demoTreeList(keyword));
  34. },
  35. },
  36. ] as MockMethod[];