index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. import Mock from 'mockjs'
  11. import { deepClone } from '../../src/utils/index.js'
  12. import { asyncRoutes, constantRoutes } from './routes.js'
  13. const routes = deepClone([...constantRoutes, ...asyncRoutes])
  14. const roles = [
  15. {
  16. key: 'admin',
  17. name: 'admin',
  18. description: 'Super Administrator. Have access to view all pages.',
  19. routes: routes
  20. },
  21. {
  22. key: 'editor',
  23. name: 'editor',
  24. description: 'Normal Editor. Can see all pages except permission page',
  25. routes: routes.filter(i => i.path !== '/permission')// just a mock
  26. },
  27. {
  28. key: 'visitor',
  29. name: 'visitor',
  30. description: 'Just a visitor. Can only see the home page and the document page',
  31. routes: [{
  32. path: '',
  33. redirect: 'dashboard',
  34. children: [
  35. {
  36. path: 'dashboard',
  37. name: 'Dashboard',
  38. meta: { title: 'dashboard', icon: 'dashboard' }
  39. }
  40. ]
  41. }]
  42. }
  43. ]
  44. export default [
  45. // mock get all routes form server
  46. {
  47. url: '/vue-element-admin/routes',
  48. type: 'get',
  49. response: _ => {
  50. return {
  51. code: 20000,
  52. data: routes
  53. }
  54. }
  55. },
  56. // mock get all roles form server
  57. {
  58. url: '/vue-element-admin/roles',
  59. type: 'get',
  60. response: _ => {
  61. return {
  62. code: 20000,
  63. data: roles
  64. }
  65. }
  66. },
  67. // add role
  68. {
  69. url: '/vue-element-admin/role',
  70. type: 'post',
  71. response: {
  72. code: 20000,
  73. data: {
  74. key: Mock.mock('@integer(300, 5000)')
  75. }
  76. }
  77. },
  78. // update role
  79. {
  80. url: '/vue-element-admin/role/[A-Za-z0-9]',
  81. type: 'put',
  82. response: {
  83. code: 20000,
  84. data: {
  85. status: 'success'
  86. }
  87. }
  88. },
  89. // delete role
  90. {
  91. url: '/vue-element-admin/role/[A-Za-z0-9]',
  92. type: 'delete',
  93. response: {
  94. code: 20000,
  95. data: {
  96. status: 'success'
  97. }
  98. }
  99. }
  100. ]