select-demo.ts 666 B

12345678910111213141516171819202122232425262728
  1. import { MockMethod } from 'vite-plugin-mock';
  2. import { resultSuccess, baseUrl } from '../_util';
  3. const demoList = (keyword, count = 20) => {
  4. const result = {
  5. list: [] as any[],
  6. };
  7. for (let index = 0; index < count; index++) {
  8. result.list.push({
  9. name: `${keyword ?? ''}选项${index}`,
  10. id: `${index}`,
  11. });
  12. }
  13. return result;
  14. };
  15. export default [
  16. {
  17. url: `${baseUrl}/select/getDemoOptions`,
  18. timeout: 1000,
  19. method: 'get',
  20. response: ({ query }) => {
  21. const { keyword,count} = query;
  22. console.log("查询条件:", keyword);
  23. return resultSuccess(demoList(keyword,count));
  24. },
  25. },
  26. ] as MockMethod[];