index.mock.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { SUCCESS_CODE } from '@/constants'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. const timeout = 1000
  4. export default [
  5. // 分析页统计接口
  6. {
  7. url: '/mock/analysis/total',
  8. method: 'get',
  9. timeout,
  10. response: () => {
  11. return {
  12. code: SUCCESS_CODE,
  13. data: {
  14. users: 102400,
  15. messages: 81212,
  16. moneys: 9280,
  17. shoppings: 13600
  18. }
  19. }
  20. }
  21. },
  22. // 用户来源
  23. {
  24. url: '/mock/analysis/userAccessSource',
  25. method: 'get',
  26. timeout,
  27. response: () => {
  28. return {
  29. code: SUCCESS_CODE,
  30. data: [
  31. { value: 1000, name: 'analysis.directAccess' },
  32. { value: 310, name: 'analysis.mailMarketing' },
  33. { value: 234, name: 'analysis.allianceAdvertising' },
  34. { value: 135, name: 'analysis.videoAdvertising' },
  35. { value: 1548, name: 'analysis.searchEngines' }
  36. ]
  37. }
  38. }
  39. },
  40. // 每周用户活跃量
  41. {
  42. url: '/mock/analysis/weeklyUserActivity',
  43. method: 'get',
  44. timeout,
  45. response: () => {
  46. return {
  47. code: SUCCESS_CODE,
  48. data: [
  49. { value: 13253, name: 'analysis.monday' },
  50. { value: 34235, name: 'analysis.tuesday' },
  51. { value: 26321, name: 'analysis.wednesday' },
  52. { value: 12340, name: 'analysis.thursday' },
  53. { value: 24643, name: 'analysis.friday' },
  54. { value: 1322, name: 'analysis.saturday' },
  55. { value: 1324, name: 'analysis.sunday' }
  56. ]
  57. }
  58. }
  59. },
  60. // 每月销售额
  61. {
  62. url: '/mock/analysis/monthlySales',
  63. method: 'get',
  64. timeout,
  65. response: () => {
  66. return {
  67. code: SUCCESS_CODE,
  68. data: [
  69. { estimate: 100, actual: 120, name: 'analysis.january' },
  70. { estimate: 120, actual: 82, name: 'analysis.february' },
  71. { estimate: 161, actual: 91, name: 'analysis.march' },
  72. { estimate: 134, actual: 154, name: 'analysis.april' },
  73. { estimate: 105, actual: 162, name: 'analysis.may' },
  74. { estimate: 160, actual: 140, name: 'analysis.june' },
  75. { estimate: 165, actual: 145, name: 'analysis.july' },
  76. { estimate: 114, actual: 250, name: 'analysis.august' },
  77. { estimate: 163, actual: 134, name: 'analysis.september' },
  78. { estimate: 185, actual: 56, name: 'analysis.october' },
  79. { estimate: 118, actual: 99, name: 'analysis.november' },
  80. { estimate: 123, actual: 123, name: 'analysis.december' }
  81. ]
  82. }
  83. }
  84. }
  85. ] as MockMethod[]