_mock.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // eslint-disable-next-line import/no-extraneous-dependencies
  2. import { Request, Response } from 'express';
  3. import city from './geographic/city.json';
  4. import province from './geographic/province.json';
  5. function getProvince(_: Request, res: Response) {
  6. return res.json(province);
  7. }
  8. function getCity(req: Request, res: Response) {
  9. return res.json(city[req.params.province]);
  10. }
  11. // 代码中会兼容本地 service mock 以及部署站点的静态数据
  12. export default {
  13. // 支持值为 Object 和 Array
  14. 'GET /api/currentUser': {
  15. name: 'Serati Ma',
  16. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
  17. userid: '00000001',
  18. email: 'antdesign@alipay.com',
  19. signature: '海纳百川,有容乃大',
  20. title: '交互专家',
  21. group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
  22. tags: [
  23. {
  24. key: '0',
  25. label: '很有想法的',
  26. },
  27. {
  28. key: '1',
  29. label: '专注设计',
  30. },
  31. {
  32. key: '2',
  33. label: '辣~',
  34. },
  35. {
  36. key: '3',
  37. label: '大长腿',
  38. },
  39. {
  40. key: '4',
  41. label: '川妹子',
  42. },
  43. {
  44. key: '5',
  45. label: '海纳百川',
  46. },
  47. ],
  48. notifyCount: 12,
  49. unreadCount: 11,
  50. country: 'China',
  51. geographic: {
  52. province: {
  53. label: '浙江省',
  54. key: '330000',
  55. },
  56. city: {
  57. label: '杭州市',
  58. key: '330100',
  59. },
  60. },
  61. address: '西湖区工专路 77 号',
  62. phone: '0752-268888888',
  63. },
  64. 'GET /api/geographic/province': getProvince,
  65. 'GET /api/geographic/city/:province': getCity,
  66. };