index.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import test from './test.mock'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. import { RequestHttpEnum } from '@/enums/httpEnum'
  4. // 单个X数据
  5. export const chartDataUrl = '/mock/chartData'
  6. export const chartSingleDataUrl = '/mock/chartSingleData'
  7. export const numberFloatUrl = '/mock/number/float'
  8. export const numberIntUrl = '/mock/number/int'
  9. export const textUrl = '/mock/text'
  10. export const imageUrl = '/mock/image'
  11. export const rankListUrl = '/mock/rankList'
  12. export const scrollBoardUrl = '/mock/scrollBoard'
  13. export const radarUrl = '/mock/radarData'
  14. export const heatMapUrl = '/mock/heatMapData'
  15. export const scatterBasicUrl = '/mock/scatterBasic'
  16. export const mapUrl = '/mock/map'
  17. export const wordCloudUrl = '/mock/wordCloud'
  18. const mockObject: MockMethod[] = [
  19. {
  20. // 正则
  21. // url: /\/mock\/mockData(|\?\S*)$/,
  22. url: chartDataUrl,
  23. method: RequestHttpEnum.GET,
  24. response: () => test.fetchMockData
  25. },
  26. {
  27. url: chartSingleDataUrl,
  28. method: RequestHttpEnum.GET,
  29. response: () => test.fetchMockSingleData
  30. },
  31. {
  32. url: numberFloatUrl,
  33. method: RequestHttpEnum.GET,
  34. response: () => test.fetchNumberFloat
  35. },
  36. {
  37. url: numberIntUrl,
  38. method: RequestHttpEnum.GET,
  39. response: () => test.fetchNumberInt
  40. },
  41. {
  42. url: textUrl,
  43. method: RequestHttpEnum.GET,
  44. response: () => test.fetchText
  45. },
  46. {
  47. url: imageUrl,
  48. method: RequestHttpEnum.GET,
  49. response: () => test.fetchImage(Math.round(Math.random() * 10))
  50. },
  51. {
  52. url: rankListUrl,
  53. method: RequestHttpEnum.GET,
  54. response: () => test.fetchRankList
  55. },
  56. {
  57. url: scrollBoardUrl,
  58. method: RequestHttpEnum.GET,
  59. response: () => test.fetchScrollBoard
  60. },
  61. {
  62. url: radarUrl,
  63. method: RequestHttpEnum.GET,
  64. response: () => test.fetchRadar
  65. },
  66. {
  67. url: heatMapUrl,
  68. method: RequestHttpEnum.GET,
  69. response: () => test.fetchHeatmap
  70. },
  71. {
  72. url: scatterBasicUrl,
  73. method: RequestHttpEnum.GET,
  74. response: () => test.fetchScatterBasic
  75. },
  76. {
  77. url: mapUrl,
  78. method: RequestHttpEnum.GET,
  79. response: () => test.fetchMap
  80. },
  81. {
  82. url: wordCloudUrl,
  83. method: RequestHttpEnum.GET,
  84. response: () => test.fetchWordCloud
  85. }
  86. ]
  87. export default mockObject