index.mock.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. import { faker } from '@faker-js/faker'
  2. const delay = 1000
  3. export default [
  4. // 列表接口
  5. {
  6. url: '/mock/menu/list',
  7. method: 'GET',
  8. delay,
  9. body: () => {
  10. return {
  11. code: 0,
  12. data: {
  13. list: [
  14. {
  15. path: '/dashboard',
  16. component: '#',
  17. redirect: '/dashboard/analysis',
  18. name: 'Dashboard',
  19. status: faker.number.int({ min: 0, max: 1 }),
  20. id: 1,
  21. type: 0,
  22. parentId: undefined,
  23. title: '首页',
  24. meta: {
  25. title: '首页',
  26. icon: 'ant-design:dashboard-filled',
  27. alwaysShow: true
  28. },
  29. children: [
  30. {
  31. path: 'analysis',
  32. component: 'views/Dashboard/Analysis',
  33. name: 'Analysis',
  34. status: faker.number.int({ min: 0, max: 1 }),
  35. id: 2,
  36. type: 1,
  37. parentId: 1,
  38. title: '分析页',
  39. permissionList: [
  40. {
  41. label: '新增',
  42. value: 'add'
  43. },
  44. {
  45. label: '编辑',
  46. value: 'edit'
  47. }
  48. ],
  49. meta: {
  50. title: '分析页',
  51. noCache: true,
  52. permission: ['add', 'edit']
  53. }
  54. },
  55. {
  56. path: 'workplace',
  57. component: 'views/Dashboard/Workplace',
  58. name: 'Workplace',
  59. status: faker.number.int({ min: 0, max: 1 }),
  60. id: 3,
  61. type: 1,
  62. parentId: 1,
  63. title: '工作台',
  64. permissionList: [
  65. {
  66. label: '新增',
  67. value: 'add'
  68. },
  69. {
  70. label: '编辑',
  71. value: 'edit'
  72. },
  73. {
  74. label: '删除',
  75. value: 'delete'
  76. }
  77. ],
  78. meta: {
  79. title: '工作台',
  80. noCache: true
  81. }
  82. }
  83. ]
  84. },
  85. {
  86. path: '/external-link',
  87. component: '#',
  88. meta: {
  89. title: '文档',
  90. icon: 'clarity:document-solid'
  91. },
  92. name: 'ExternalLink',
  93. status: faker.number.int({ min: 0, max: 1 }),
  94. id: 4,
  95. type: 0,
  96. parentId: undefined,
  97. title: '文档',
  98. children: [
  99. {
  100. path: 'https://element-plus-admin-doc.cn/',
  101. name: 'DocumentLink',
  102. status: faker.number.int({ min: 0, max: 1 }),
  103. id: 5,
  104. type: 1,
  105. parentId: 4,
  106. title: '文档',
  107. meta: {
  108. title: '文档'
  109. }
  110. }
  111. ]
  112. },
  113. {
  114. path: '/level',
  115. component: '#',
  116. redirect: '/level/menu1/menu1-1/menu1-1-1',
  117. name: 'Level',
  118. status: faker.number.int({ min: 0, max: 1 }),
  119. id: 6,
  120. type: 0,
  121. parentId: undefined,
  122. title: '菜单',
  123. meta: {
  124. title: '菜单',
  125. icon: 'carbon:skill-level-advanced'
  126. },
  127. children: [
  128. {
  129. path: 'menu1',
  130. name: 'Menu1',
  131. component: '##',
  132. status: faker.number.int({ min: 0, max: 1 }),
  133. id: 7,
  134. type: 0,
  135. parentId: 6,
  136. title: '菜单1',
  137. redirect: '/level/menu1/menu1-1/menu1-1-1',
  138. meta: {
  139. title: '菜单1'
  140. },
  141. children: [
  142. {
  143. path: 'menu1-1',
  144. name: 'Menu11',
  145. component: '##',
  146. status: faker.number.int({ min: 0, max: 1 }),
  147. id: 8,
  148. type: 0,
  149. parentId: 7,
  150. title: '菜单1-1',
  151. redirect: '/level/menu1/menu1-1/menu1-1-1',
  152. meta: {
  153. title: '菜单1-1',
  154. alwaysShow: true
  155. },
  156. children: [
  157. {
  158. path: 'menu1-1-1',
  159. name: 'Menu111',
  160. component: 'views/Level/Menu111',
  161. status: faker.number.int({ min: 0, max: 1 }),
  162. id: 9,
  163. type: 1,
  164. parentId: 8,
  165. title: '菜单1-1-1',
  166. meta: {
  167. title: '菜单1-1-1'
  168. }
  169. }
  170. ]
  171. },
  172. {
  173. path: 'menu1-2',
  174. name: 'Menu12',
  175. component: 'views/Level/Menu12',
  176. status: faker.number.int({ min: 0, max: 1 }),
  177. id: 10,
  178. type: 1,
  179. parentId: 7,
  180. title: '菜单1-2',
  181. meta: {
  182. title: '菜单1-2'
  183. }
  184. }
  185. ]
  186. },
  187. {
  188. path: 'menu2',
  189. name: 'Menu2Demo',
  190. component: 'views/Level/Menu2',
  191. status: faker.number.int({ min: 0, max: 1 }),
  192. id: 11,
  193. type: 1,
  194. parentId: 6,
  195. title: '菜单2',
  196. meta: {
  197. title: '菜单2'
  198. }
  199. }
  200. ]
  201. },
  202. {
  203. path: '/example',
  204. component: '#',
  205. redirect: '/example/example-dialog',
  206. name: 'Example',
  207. status: faker.number.int({ min: 0, max: 1 }),
  208. id: 12,
  209. type: 0,
  210. parentId: undefined,
  211. title: '综合示例',
  212. meta: {
  213. title: '综合示例',
  214. icon: 'ep:management',
  215. alwaysShow: true
  216. },
  217. children: [
  218. {
  219. path: 'example-dialog',
  220. component: 'views/Example/Dialog/ExampleDialog',
  221. name: 'ExampleDialog',
  222. status: faker.number.int({ min: 0, max: 1 }),
  223. id: 13,
  224. type: 1,
  225. parentId: 12,
  226. title: '综合示例-弹窗',
  227. permissionList: [
  228. {
  229. label: '新增',
  230. value: 'add'
  231. },
  232. {
  233. label: '编辑',
  234. value: 'edit'
  235. },
  236. {
  237. label: '删除',
  238. value: 'delete'
  239. },
  240. {
  241. label: '查看',
  242. value: 'view'
  243. }
  244. ],
  245. meta: {
  246. title: '综合示例-弹窗'
  247. }
  248. },
  249. {
  250. path: 'example-page',
  251. component: 'views/Example/Page/ExamplePage',
  252. name: 'ExamplePage',
  253. status: faker.number.int({ min: 0, max: 1 }),
  254. id: 14,
  255. type: 1,
  256. parentId: 12,
  257. title: '综合示例-页面',
  258. permissionList: [
  259. {
  260. label: '新增',
  261. value: 'edit'
  262. },
  263. {
  264. label: '编辑',
  265. value: 'edit'
  266. },
  267. {
  268. label: '删除',
  269. value: 'delete'
  270. },
  271. {
  272. label: '查看',
  273. value: 'view'
  274. }
  275. ],
  276. meta: {
  277. title: '综合示例-页面'
  278. }
  279. },
  280. {
  281. path: 'example-add',
  282. component: 'views/Example/Page/ExampleAdd',
  283. name: 'ExampleAdd',
  284. status: faker.number.int({ min: 0, max: 1 }),
  285. id: 15,
  286. type: 1,
  287. parentId: 12,
  288. title: '综合示例-新增',
  289. meta: {
  290. title: '综合示例-新增',
  291. noTagsView: true,
  292. noCache: true,
  293. hidden: true,
  294. showMainRoute: true,
  295. activeMenu: '/example/example-page'
  296. }
  297. },
  298. {
  299. path: 'example-edit',
  300. component: 'views/Example/Page/ExampleEdit',
  301. name: 'ExampleEdit',
  302. status: faker.number.int({ min: 0, max: 1 }),
  303. id: 16,
  304. type: 1,
  305. parentId: 12,
  306. title: '综合示例-编辑',
  307. meta: {
  308. title: '综合示例-编辑',
  309. noTagsView: true,
  310. noCache: true,
  311. hidden: true,
  312. showMainRoute: true,
  313. activeMenu: '/example/example-page'
  314. }
  315. },
  316. {
  317. path: 'example-detail',
  318. component: 'views/Example/Page/ExampleDetail',
  319. name: 'ExampleDetail',
  320. status: faker.number.int({ min: 0, max: 1 }),
  321. id: 17,
  322. type: 1,
  323. parentId: 12,
  324. title: '综合示例-详情',
  325. meta: {
  326. title: '综合示例-详情',
  327. noTagsView: true,
  328. noCache: true,
  329. hidden: true,
  330. showMainRoute: true,
  331. activeMenu: '/example/example-page'
  332. }
  333. }
  334. ]
  335. }
  336. ]
  337. }
  338. }
  339. }
  340. }
  341. ]