menu.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. import { resultSuccess } from '../_util';
  2. import { MockMethod } from 'vite-plugin-mock';
  3. // single
  4. const homeRoute = {
  5. path: '/home',
  6. name: 'Home',
  7. component: '/dashboard/welcome/index',
  8. meta: {
  9. title: 'routes.dashboard.welcome',
  10. affix: true,
  11. icon: 'bx:bx-home',
  12. },
  13. };
  14. const dashboardRoute = {
  15. path: '/dashboard',
  16. name: 'Dashboard',
  17. component: 'LAYOUT',
  18. redirect: '/dashboard/workbench',
  19. meta: {
  20. icon: 'bx:bx-home',
  21. title: 'routes.dashboard.dashboard',
  22. },
  23. children: [
  24. {
  25. path: 'workbench',
  26. name: 'Workbench',
  27. component: '/dashboard/workbench/index.vue',
  28. meta: {
  29. title: 'routes.dashboard.workbench',
  30. },
  31. },
  32. {
  33. path: 'analysis',
  34. name: 'Analysis',
  35. component: '/dashboard/analysis/index.vue',
  36. meta: {
  37. title: 'routes.dashboard.analysis',
  38. },
  39. },
  40. ],
  41. };
  42. const tableRoute = {
  43. path: '/table',
  44. name: 'Table',
  45. component: 'LAYOUT',
  46. redirect: '/table/index',
  47. meta: {
  48. icon: 'bx:bx-table',
  49. title: 'routes.table.table',
  50. },
  51. children: [
  52. {
  53. path: 'table',
  54. name: 'Table',
  55. component: '/table/table/index.vue',
  56. meta: {
  57. title: 'routes.table.table',
  58. icon: 'ant-design:table-outlined',
  59. },
  60. },
  61. {
  62. path: 'edit',
  63. name: 'Edit',
  64. component: '/table/editTable/index.vue',
  65. meta: {
  66. title: 'routes.table.edit',
  67. icon: 'ant-design:table-outlined',
  68. },
  69. },
  70. ],
  71. };
  72. const testRoute = {
  73. path: '/test',
  74. name: 'TestDemo',
  75. component: 'LAYOUT',
  76. redirect: '/table/basic',
  77. meta: {
  78. icon: 'ant-design:table-outlined',
  79. title: '前台测试',
  80. },
  81. children: [
  82. {
  83. path: 'basic',
  84. name: 'testBasic',
  85. component: '/test/index',
  86. meta: {
  87. title: '测试功能',
  88. icon: 'bx:bx-home',
  89. },
  90. },
  91. ],
  92. };
  93. const permissionRoute = {
  94. path: '/permission',
  95. name: 'Permission',
  96. component: 'LAYOUT',
  97. redirect: '/permission/role',
  98. meta: {
  99. icon: 'ant-design:lock-outlined',
  100. title: 'routes.permission.management',
  101. },
  102. children: [
  103. {
  104. path: 'role',
  105. name: 'Role',
  106. component: '/permission/role/index',
  107. meta: {
  108. title: 'routes.permission.role',
  109. icon: 'bx:bx-lock',
  110. },
  111. },
  112. ],
  113. };
  114. const frontRoute = {
  115. path: 'front',
  116. name: 'PermissionFrontDemo',
  117. meta: {
  118. title: 'routes.demo.permission.front',
  119. },
  120. children: [
  121. {
  122. path: 'page',
  123. name: 'FrontPageAuth',
  124. component: '/demo/permission/front/index',
  125. meta: {
  126. title: 'routes.demo.permission.frontPage',
  127. },
  128. },
  129. {
  130. path: 'btn',
  131. name: 'FrontBtnAuth',
  132. component: '/demo/permission/front/Btn',
  133. meta: {
  134. title: 'routes.demo.permission.frontBtn',
  135. },
  136. },
  137. {
  138. path: 'auth-pageA',
  139. name: 'FrontAuthPageA',
  140. component: '/demo/permission/front/AuthPageA',
  141. meta: {
  142. title: 'routes.demo.permission.frontTestA',
  143. },
  144. },
  145. {
  146. path: 'auth-pageB',
  147. name: 'FrontAuthPageB',
  148. component: '/demo/permission/front/AuthPageB',
  149. meta: {
  150. title: 'routes.demo.permission.frontTestB',
  151. },
  152. },
  153. ],
  154. };
  155. const backRoute = {
  156. path: 'back',
  157. name: 'PermissionBackDemo',
  158. meta: {
  159. title: 'routes.demo.permission.back',
  160. },
  161. children: [
  162. {
  163. path: 'page',
  164. name: 'BackAuthPage',
  165. component: '/demo/permission/back/index',
  166. meta: {
  167. title: 'routes.demo.permission.backPage',
  168. },
  169. },
  170. {
  171. path: 'btn',
  172. name: 'BackAuthBtn',
  173. component: '/demo/permission/back/Btn',
  174. meta: {
  175. title: 'routes.demo.permission.backBtn',
  176. },
  177. },
  178. ],
  179. };
  180. const authRoute = {
  181. path: '/permission',
  182. name: 'Permission',
  183. component: 'LAYOUT',
  184. redirect: '/permission/front/page',
  185. meta: {
  186. icon: 'carbon:user-role',
  187. title: 'routes.demo.permission.permission',
  188. },
  189. children: [frontRoute, backRoute],
  190. };
  191. const authRoute1 = {
  192. path: '/permission',
  193. name: 'Permission',
  194. component: 'LAYOUT',
  195. redirect: '/permission/front/page',
  196. meta: {
  197. icon: 'carbon:user-role',
  198. title: 'routes.demo.permission.permission',
  199. },
  200. children: [backRoute],
  201. };
  202. const levelRoute = {
  203. path: '/level',
  204. name: 'Level',
  205. component: 'LAYOUT',
  206. redirect: '/level/menu1/menu1-1',
  207. meta: {
  208. icon: 'carbon:user-role',
  209. title: 'routes.demo.level.level',
  210. },
  211. children: [
  212. {
  213. path: 'menu1',
  214. name: 'Menu1Demo',
  215. meta: {
  216. title: 'Menu1',
  217. },
  218. children: [
  219. {
  220. path: 'menu1-1',
  221. name: 'Menu11Demo',
  222. meta: {
  223. title: 'Menu1-1',
  224. },
  225. children: [
  226. {
  227. path: 'menu1-1-1',
  228. name: 'Menu111Demo',
  229. component: '/demo/level/Menu111',
  230. meta: {
  231. title: 'Menu111',
  232. },
  233. },
  234. ],
  235. },
  236. {
  237. path: 'menu1-2',
  238. name: 'Menu12Demo',
  239. component: '/demo/level/Menu12',
  240. meta: {
  241. title: 'Menu1-2',
  242. },
  243. },
  244. ],
  245. },
  246. {
  247. path: 'menu2',
  248. name: 'Menu2Demo',
  249. component: '/demo/level/Menu2',
  250. meta: {
  251. title: 'Menu2',
  252. },
  253. },
  254. ],
  255. };
  256. export default [
  257. {
  258. url: '/api/getMenuListById',
  259. timeout: 1000,
  260. method: 'get',
  261. response: ({ query }) => {
  262. const { id } = query;
  263. if (!id || id === '1') {
  264. return resultSuccess([homeRoute, dashboardRoute, tableRoute, permissionRoute, testRoute]);
  265. }
  266. if (id === '2') {
  267. return resultSuccess([dashboardRoute, authRoute1, levelRoute]);
  268. }
  269. },
  270. },
  271. ] as MockMethod[];