index.ts 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. import config from '@/config/axios/config'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. import Mock from 'mockjs'
  4. import { toAnyString } from '@/utils'
  5. const { code } = config
  6. const timeout = 1000
  7. const adminList = [
  8. {
  9. path: '/dashboard',
  10. component: '#',
  11. redirect: '/dashboard/analysis',
  12. name: 'Dashboard',
  13. meta: {
  14. title: 'router.dashboard',
  15. icon: 'ant-design:dashboard-filled',
  16. alwaysShow: true
  17. },
  18. children: [
  19. {
  20. path: 'analysis',
  21. component: 'views/Dashboard/Analysis',
  22. name: 'Analysis',
  23. meta: {
  24. title: 'router.analysis',
  25. noCache: true
  26. }
  27. },
  28. {
  29. path: 'workplace',
  30. component: 'views/Dashboard/Workplace',
  31. name: 'Workplace',
  32. meta: {
  33. title: 'router.workplace',
  34. noCache: true
  35. }
  36. }
  37. ]
  38. },
  39. {
  40. path: '/external-link',
  41. component: '#',
  42. meta: {},
  43. name: 'ExternalLink',
  44. children: [
  45. {
  46. path: 'https://element-plus-admin-doc.cn/',
  47. name: 'DocumentLink',
  48. meta: {
  49. title: 'router.document',
  50. icon: 'clarity:document-solid'
  51. }
  52. }
  53. ]
  54. },
  55. {
  56. path: '/guide',
  57. component: '#',
  58. name: 'Guide',
  59. meta: {},
  60. children: [
  61. {
  62. path: 'index',
  63. component: 'views/Guide/Guide',
  64. name: 'GuideDemo',
  65. meta: {
  66. title: 'router.guide',
  67. icon: 'cib:telegram-plane'
  68. }
  69. }
  70. ]
  71. },
  72. {
  73. path: '/components',
  74. component: '#',
  75. redirect: '/components/form/default-form',
  76. name: 'ComponentsDemo',
  77. meta: {
  78. title: 'router.component',
  79. icon: 'bx:bxs-component',
  80. alwaysShow: true
  81. },
  82. children: [
  83. {
  84. path: 'form',
  85. component: '##',
  86. name: 'Form',
  87. meta: {
  88. title: 'router.form',
  89. alwaysShow: true
  90. },
  91. children: [
  92. {
  93. path: 'default-form',
  94. component: 'views/Components/Form/DefaultForm',
  95. name: 'DefaultForm',
  96. meta: {
  97. title: 'router.defaultForm'
  98. }
  99. },
  100. {
  101. path: 'use-form',
  102. component: 'views/Components/Form/UseFormDemo',
  103. name: 'UseForm',
  104. meta: {
  105. title: 'UseForm'
  106. }
  107. }
  108. ]
  109. },
  110. {
  111. path: 'table',
  112. component: '##',
  113. redirect: '/components/table/default-table',
  114. name: 'TableDemo',
  115. meta: {
  116. title: 'router.table',
  117. alwaysShow: true
  118. },
  119. children: [
  120. {
  121. path: 'default-table',
  122. component: 'views/Components/Table/DefaultTable',
  123. name: 'DefaultTable',
  124. meta: {
  125. title: 'router.defaultTable'
  126. }
  127. },
  128. {
  129. path: 'use-table',
  130. component: 'views/Components/Table/UseTableDemo',
  131. name: 'UseTable',
  132. meta: {
  133. title: 'UseTable'
  134. }
  135. },
  136. {
  137. path: 'tree-table',
  138. component: 'views/Components/Table/TreeTable',
  139. name: 'TreeTable',
  140. meta: {
  141. title: 'TreeTable'
  142. }
  143. },
  144. {
  145. path: 'table-image-preview',
  146. component: 'views/Components/Table/TableImagePreview',
  147. name: 'TableImagePreview',
  148. meta: {
  149. title: 'router.PicturePreview'
  150. }
  151. }
  152. // {
  153. // path: 'ref-table',
  154. // component: 'views/Components/Table/RefTable',
  155. // name: 'RefTable',
  156. // meta: {
  157. // title: 'RefTable'
  158. // }
  159. // }
  160. ]
  161. },
  162. {
  163. path: 'editor-demo',
  164. component: '##',
  165. redirect: '/components/editor-demo/editor',
  166. name: 'EditorDemo',
  167. meta: {
  168. title: 'router.editor',
  169. alwaysShow: true
  170. },
  171. children: [
  172. {
  173. path: 'editor',
  174. component: 'views/Components/Editor/Editor',
  175. name: 'Editor',
  176. meta: {
  177. title: 'router.richText'
  178. }
  179. }
  180. ]
  181. },
  182. {
  183. path: 'search',
  184. component: 'views/Components/Search',
  185. name: 'Search',
  186. meta: {
  187. title: 'router.search'
  188. }
  189. },
  190. {
  191. path: 'descriptions',
  192. component: 'views/Components/Descriptions',
  193. name: 'Descriptions',
  194. meta: {
  195. title: 'router.descriptions'
  196. }
  197. },
  198. {
  199. path: 'image-viewer',
  200. component: 'views/Components/ImageViewer',
  201. name: 'ImageViewer',
  202. meta: {
  203. title: 'router.imageViewer'
  204. }
  205. },
  206. {
  207. path: 'dialog',
  208. component: 'views/Components/Dialog',
  209. name: 'Dialog',
  210. meta: {
  211. title: 'router.dialog'
  212. }
  213. },
  214. {
  215. path: 'icon',
  216. component: 'views/Components/Icon',
  217. name: 'Icon',
  218. meta: {
  219. title: 'router.icon'
  220. }
  221. },
  222. {
  223. path: 'echart',
  224. component: 'views/Components/Echart',
  225. name: 'Echart',
  226. meta: {
  227. title: 'router.echart'
  228. }
  229. },
  230. {
  231. path: 'count-to',
  232. component: 'views/Components/CountTo',
  233. name: 'CountTo',
  234. meta: {
  235. title: 'router.countTo'
  236. }
  237. },
  238. {
  239. path: 'qrcode',
  240. component: 'views/Components/Qrcode',
  241. name: 'Qrcode',
  242. meta: {
  243. title: 'router.qrcode'
  244. }
  245. },
  246. {
  247. path: 'highlight',
  248. component: 'views/Components/Highlight',
  249. name: 'Highlight',
  250. meta: {
  251. title: 'router.highlight'
  252. }
  253. },
  254. {
  255. path: 'infotip',
  256. component: 'views/Components/Infotip',
  257. name: 'Infotip',
  258. meta: {
  259. title: 'router.infotip'
  260. }
  261. },
  262. {
  263. path: 'input-password',
  264. component: 'views/Components/InputPassword',
  265. name: 'InputPassword',
  266. meta: {
  267. title: 'router.inputPassword'
  268. }
  269. }
  270. ]
  271. },
  272. {
  273. path: '/function',
  274. component: '#',
  275. redirect: '/function/multipleTabs',
  276. name: 'Function',
  277. meta: {
  278. title: 'router.function',
  279. icon: 'ri:function-fill',
  280. alwaysShow: true
  281. },
  282. children: [
  283. {
  284. path: 'multipleTabs',
  285. component: 'views/Function/MultipleTabs',
  286. name: 'MultipleTabs',
  287. meta: {
  288. title: 'router.multipleTabs'
  289. }
  290. },
  291. {
  292. path: 'multipleTabs-demo/:id',
  293. component: 'views/Function/MultipleTabsDemo',
  294. name: 'MultipleTabsDemo',
  295. meta: {
  296. hidden: true,
  297. title: 'router.details',
  298. canTo: true
  299. }
  300. }
  301. ]
  302. },
  303. {
  304. path: '/hooks',
  305. component: '#',
  306. redirect: '/hooks/useWatermark',
  307. name: 'Hooks',
  308. meta: {
  309. title: 'hooks',
  310. icon: 'ic:outline-webhook',
  311. alwaysShow: true
  312. },
  313. children: [
  314. {
  315. path: 'useWatermark',
  316. component: 'views/hooks/useWatermark',
  317. name: 'UseWatermark',
  318. meta: {
  319. title: 'useWatermark'
  320. }
  321. },
  322. {
  323. path: 'useTagsView',
  324. component: 'views/hooks/useTagsView',
  325. name: 'UseTagsView',
  326. meta: {
  327. title: 'useTagsView'
  328. }
  329. }
  330. // {
  331. // path: 'useCrudSchemas',
  332. // component: 'views/hooks/useCrudSchemas',
  333. // name: 'UseCrudSchemas',
  334. // meta: {
  335. // title: 'useCrudSchemas'
  336. // }
  337. // }
  338. ]
  339. },
  340. {
  341. path: '/level',
  342. component: '#',
  343. redirect: '/level/menu1/menu1-1/menu1-1-1',
  344. name: 'Level',
  345. meta: {
  346. title: 'router.level',
  347. icon: 'carbon:skill-level-advanced'
  348. },
  349. children: [
  350. {
  351. path: 'menu1',
  352. name: 'Menu1',
  353. component: '##',
  354. redirect: '/level/menu1/menu1-1/menu1-1-1',
  355. meta: {
  356. title: 'router.menu1'
  357. },
  358. children: [
  359. {
  360. path: 'menu1-1',
  361. name: 'Menu11',
  362. component: '##',
  363. redirect: '/level/menu1/menu1-1/menu1-1-1',
  364. meta: {
  365. title: 'router.menu11',
  366. alwaysShow: true
  367. },
  368. children: [
  369. {
  370. path: 'menu1-1-1',
  371. name: 'Menu111',
  372. component: 'views/Level/Menu111',
  373. meta: {
  374. title: 'router.menu111'
  375. }
  376. }
  377. ]
  378. },
  379. {
  380. path: 'menu1-2',
  381. name: 'Menu12',
  382. component: 'views/Level/Menu12',
  383. meta: {
  384. title: 'router.menu12'
  385. }
  386. }
  387. ]
  388. },
  389. {
  390. path: 'menu2',
  391. name: 'Menu2Demo',
  392. component: 'views/Level/Menu2',
  393. meta: {
  394. title: 'router.menu2'
  395. }
  396. }
  397. ]
  398. },
  399. {
  400. path: '/example',
  401. component: '#',
  402. redirect: '/example/example-dialog',
  403. name: 'Example',
  404. meta: {
  405. title: 'router.example',
  406. icon: 'ep:management',
  407. alwaysShow: true
  408. },
  409. children: [
  410. {
  411. path: 'example-dialog',
  412. component: 'views/Example/Dialog/ExampleDialog',
  413. name: 'ExampleDialog',
  414. meta: {
  415. title: 'router.exampleDialog'
  416. }
  417. },
  418. {
  419. path: 'example-page',
  420. component: 'views/Example/Page/ExamplePage',
  421. name: 'ExamplePage',
  422. meta: {
  423. title: 'router.examplePage'
  424. }
  425. },
  426. {
  427. path: 'example-add',
  428. component: 'views/Example/Page/ExampleAdd',
  429. name: 'ExampleAdd',
  430. meta: {
  431. title: 'router.exampleAdd',
  432. noTagsView: true,
  433. noCache: true,
  434. hidden: true,
  435. showMainRoute: true,
  436. activeMenu: '/example/example-page'
  437. }
  438. },
  439. {
  440. path: 'example-edit',
  441. component: 'views/Example/Page/ExampleEdit',
  442. name: 'ExampleEdit',
  443. meta: {
  444. title: 'router.exampleEdit',
  445. noTagsView: true,
  446. noCache: true,
  447. hidden: true,
  448. showMainRoute: true,
  449. activeMenu: '/example/example-page'
  450. }
  451. },
  452. {
  453. path: 'example-detail',
  454. component: 'views/Example/Page/ExampleDetail',
  455. name: 'ExampleDetail',
  456. meta: {
  457. title: 'router.exampleDetail',
  458. noTagsView: true,
  459. noCache: true,
  460. hidden: true,
  461. showMainRoute: true,
  462. activeMenu: '/example/example-page'
  463. }
  464. }
  465. ]
  466. },
  467. {
  468. path: '/error',
  469. component: '#',
  470. redirect: '/error/404',
  471. name: 'Error',
  472. meta: {
  473. title: 'router.errorPage',
  474. icon: 'ci:error',
  475. alwaysShow: true
  476. },
  477. children: [
  478. {
  479. path: '404-demo',
  480. component: 'views/Error/404',
  481. name: '404Demo',
  482. meta: {
  483. title: '404'
  484. }
  485. },
  486. {
  487. path: '403-demo',
  488. component: 'views/Error/403',
  489. name: '403Demo',
  490. meta: {
  491. title: '403'
  492. }
  493. },
  494. {
  495. path: '500-demo',
  496. component: 'views/Error/500',
  497. name: '500Demo',
  498. meta: {
  499. title: '500'
  500. }
  501. }
  502. ]
  503. },
  504. {
  505. path: '/authorization',
  506. component: '#',
  507. redirect: '/authorization/user',
  508. name: 'Authorization',
  509. meta: {
  510. title: 'router.authorization',
  511. icon: 'eos-icons:role-binding',
  512. alwaysShow: true
  513. },
  514. children: [
  515. {
  516. path: 'department',
  517. component: 'views/Authorization/Department/Department',
  518. name: 'Department',
  519. meta: {
  520. title: 'router.department'
  521. }
  522. },
  523. {
  524. path: 'user',
  525. component: 'views/Authorization/User/User',
  526. name: 'User',
  527. meta: {
  528. title: 'router.user'
  529. }
  530. },
  531. {
  532. path: 'menu',
  533. component: 'views/Authorization/Menu/Menu',
  534. name: 'Menu',
  535. meta: {
  536. title: 'router.menuManagement'
  537. }
  538. },
  539. {
  540. path: 'role',
  541. component: 'views/Authorization/Role/Role',
  542. name: 'Role',
  543. meta: {
  544. title: 'router.role'
  545. }
  546. },
  547. {
  548. path: 'test',
  549. component: 'views/Authorization/Test/Test',
  550. name: 'Test',
  551. meta: {
  552. title: 'router.permission'
  553. }
  554. }
  555. ]
  556. }
  557. ]
  558. const testList: string[] = [
  559. '/dashboard',
  560. '/dashboard/analysis',
  561. '/dashboard/workplace',
  562. 'external-link',
  563. 'https://element-plus-admin-doc.cn/',
  564. '/guide',
  565. '/guide/index',
  566. '/components',
  567. '/components/form',
  568. '/components/form/default-form',
  569. '/components/form/use-form',
  570. '/components/form/ref-form',
  571. '/components/table',
  572. '/components/table/default-table',
  573. '/components/table/use-table',
  574. '/components/table/tree-table',
  575. '/components/table/table-image-preview',
  576. '/components/table/ref-table',
  577. '/components/editor-demo',
  578. '/components/editor-demo/editor',
  579. '/components/search',
  580. '/components/descriptions',
  581. '/components/image-viewer',
  582. '/components/dialog',
  583. '/components/icon',
  584. '/components/echart',
  585. '/components/count-to',
  586. '/components/qrcode',
  587. '/components/highlight',
  588. '/components/infotip',
  589. '/Components/InputPassword',
  590. '/Components/Sticky',
  591. 'function',
  592. '/function/multiple-tabs',
  593. '/function/multiple-tabs-demo/:id',
  594. '/hooks',
  595. '/hooks/useWatermark',
  596. '/hooks/useTagsView',
  597. // '/hooks/useCrudSchemas',
  598. '/level',
  599. '/level/menu1',
  600. '/level/menu1/menu1-1',
  601. '/level/menu1/menu1-1/menu1-1-1',
  602. '/level/menu1/menu1-2',
  603. '/level/menu2',
  604. '/example',
  605. '/example/example-dialog',
  606. '/example/example-page',
  607. '/example/example-add',
  608. '/example/example-edit',
  609. '/example/example-detail',
  610. '/authorization',
  611. '/authorization/department',
  612. '/authorization/user',
  613. '/authorization/role',
  614. '/authorization/menu',
  615. '/authorization/test',
  616. '/error',
  617. '/error/404-demo',
  618. '/error/403-demo',
  619. '/error/500-demo'
  620. ]
  621. const List: any[] = []
  622. const roleNames = ['超级管理员', '管理员', '普通用户', '游客']
  623. const menus = [
  624. [
  625. {
  626. path: '/dashboard',
  627. component: '#',
  628. redirect: '/dashboard/analysis',
  629. name: 'Dashboard',
  630. status: Mock.Random.integer(0, 1),
  631. id: 1,
  632. meta: {
  633. title: '首页',
  634. icon: 'ant-design:dashboard-filled',
  635. alwaysShow: true
  636. },
  637. children: [
  638. {
  639. path: 'analysis',
  640. component: 'views/Dashboard/Analysis',
  641. name: 'Analysis',
  642. status: Mock.Random.integer(0, 1),
  643. id: 2,
  644. meta: {
  645. title: '分析页',
  646. noCache: true
  647. }
  648. },
  649. {
  650. path: 'workplace',
  651. component: 'views/Dashboard/Workplace',
  652. name: 'Workplace',
  653. status: Mock.Random.integer(0, 1),
  654. id: 3,
  655. meta: {
  656. title: '工作台',
  657. noCache: true
  658. }
  659. }
  660. ]
  661. },
  662. {
  663. path: '/external-link',
  664. component: '#',
  665. meta: {
  666. title: '文档',
  667. icon: 'clarity:document-solid'
  668. },
  669. name: 'ExternalLink',
  670. status: Mock.Random.integer(0, 1),
  671. id: 4,
  672. children: [
  673. {
  674. path: 'https://element-plus-admin-doc.cn/',
  675. name: 'DocumentLink',
  676. status: Mock.Random.integer(0, 1),
  677. id: 5,
  678. meta: {
  679. title: '文档'
  680. }
  681. }
  682. ]
  683. },
  684. {
  685. path: '/level',
  686. component: '#',
  687. redirect: '/level/menu1/menu1-1/menu1-1-1',
  688. name: 'Level',
  689. status: Mock.Random.integer(0, 1),
  690. id: 6,
  691. meta: {
  692. title: '菜单',
  693. icon: 'carbon:skill-level-advanced'
  694. },
  695. children: [
  696. {
  697. path: 'menu1',
  698. name: 'Menu1',
  699. component: '##',
  700. status: Mock.Random.integer(0, 1),
  701. id: 7,
  702. redirect: '/level/menu1/menu1-1/menu1-1-1',
  703. meta: {
  704. title: '菜单1'
  705. },
  706. children: [
  707. {
  708. path: 'menu1-1',
  709. name: 'Menu11',
  710. component: '##',
  711. status: Mock.Random.integer(0, 1),
  712. id: 8,
  713. redirect: '/level/menu1/menu1-1/menu1-1-1',
  714. meta: {
  715. title: '菜单1-1',
  716. alwaysShow: true
  717. },
  718. children: [
  719. {
  720. path: 'menu1-1-1',
  721. name: 'Menu111',
  722. component: 'views/Level/Menu111',
  723. status: Mock.Random.integer(0, 1),
  724. id: 9,
  725. permission: ['edit', 'add', 'delete'],
  726. meta: {
  727. title: '菜单1-1-1',
  728. permission: ['edit', 'add', 'delete']
  729. }
  730. }
  731. ]
  732. },
  733. {
  734. path: 'menu1-2',
  735. name: 'Menu12',
  736. component: 'views/Level/Menu12',
  737. status: Mock.Random.integer(0, 1),
  738. id: 10,
  739. permission: ['edit', 'add', 'delete'],
  740. meta: {
  741. title: '菜单1-2',
  742. permission: ['edit', 'add', 'delete']
  743. }
  744. }
  745. ]
  746. },
  747. {
  748. path: 'menu2',
  749. name: 'Menu2Demo',
  750. component: 'views/Level/Menu2',
  751. status: Mock.Random.integer(0, 1),
  752. id: 11,
  753. permission: ['edit', 'add', 'delete'],
  754. meta: {
  755. title: '菜单2',
  756. permission: ['edit', 'add', 'delete']
  757. }
  758. }
  759. ]
  760. },
  761. {
  762. path: '/example',
  763. component: '#',
  764. redirect: '/example/example-dialog',
  765. name: 'Example',
  766. status: Mock.Random.integer(0, 1),
  767. id: 12,
  768. meta: {
  769. title: '综合示例',
  770. icon: 'ep:management',
  771. alwaysShow: true
  772. },
  773. children: [
  774. {
  775. path: 'example-dialog',
  776. component: 'views/Example/Dialog/ExampleDialog',
  777. name: 'ExampleDialog',
  778. status: Mock.Random.integer(0, 1),
  779. id: 13,
  780. permission: ['edit', 'add', 'delete'],
  781. meta: {
  782. title: '综合示例-弹窗',
  783. permission: ['edit', 'add', 'delete']
  784. }
  785. },
  786. {
  787. path: 'example-page',
  788. component: 'views/Example/Page/ExamplePage',
  789. name: 'ExamplePage',
  790. status: Mock.Random.integer(0, 1),
  791. id: 14,
  792. permission: ['edit', 'add', 'delete'],
  793. meta: {
  794. title: '综合示例-页面',
  795. permission: ['edit', 'add', 'delete']
  796. }
  797. },
  798. {
  799. path: 'example-add',
  800. component: 'views/Example/Page/ExampleAdd',
  801. name: 'ExampleAdd',
  802. status: Mock.Random.integer(0, 1),
  803. id: 15,
  804. permission: ['edit', 'add', 'delete'],
  805. meta: {
  806. title: '综合示例-新增',
  807. noTagsView: true,
  808. noCache: true,
  809. hidden: true,
  810. showMainRoute: true,
  811. activeMenu: '/example/example-page',
  812. permission: ['edit', 'add', 'delete']
  813. }
  814. },
  815. {
  816. path: 'example-edit',
  817. component: 'views/Example/Page/ExampleEdit',
  818. name: 'ExampleEdit',
  819. status: Mock.Random.integer(0, 1),
  820. id: 16,
  821. permission: ['edit', 'add', 'delete'],
  822. meta: {
  823. title: '综合示例-编辑',
  824. noTagsView: true,
  825. noCache: true,
  826. hidden: true,
  827. showMainRoute: true,
  828. activeMenu: '/example/example-page',
  829. permission: ['edit', 'add', 'delete']
  830. }
  831. },
  832. {
  833. path: 'example-detail',
  834. component: 'views/Example/Page/ExampleDetail',
  835. name: 'ExampleDetail',
  836. status: Mock.Random.integer(0, 1),
  837. id: 17,
  838. permission: ['edit', 'add', 'delete'],
  839. meta: {
  840. title: '综合示例-详情',
  841. noTagsView: true,
  842. noCache: true,
  843. hidden: true,
  844. showMainRoute: true,
  845. activeMenu: '/example/example-page',
  846. permission: ['edit', 'add', 'delete']
  847. }
  848. }
  849. ]
  850. }
  851. ],
  852. [
  853. {
  854. path: '/dashboard',
  855. component: '#',
  856. redirect: '/dashboard/analysis',
  857. name: 'Dashboard',
  858. status: Mock.Random.integer(0, 1),
  859. id: 1,
  860. meta: {
  861. title: '首页',
  862. icon: 'ant-design:dashboard-filled',
  863. alwaysShow: true
  864. },
  865. children: [
  866. {
  867. path: 'analysis',
  868. component: 'views/Dashboard/Analysis',
  869. name: 'Analysis',
  870. status: Mock.Random.integer(0, 1),
  871. id: 2,
  872. meta: {
  873. title: '分析页',
  874. noCache: true
  875. }
  876. },
  877. {
  878. path: 'workplace',
  879. component: 'views/Dashboard/Workplace',
  880. name: 'Workplace',
  881. status: Mock.Random.integer(0, 1),
  882. id: 3,
  883. meta: {
  884. title: '工作台',
  885. noCache: true
  886. }
  887. }
  888. ]
  889. }
  890. ],
  891. [
  892. {
  893. path: '/external-link',
  894. component: '#',
  895. meta: {
  896. title: '文档',
  897. icon: 'clarity:document-solid'
  898. },
  899. name: 'ExternalLink',
  900. status: Mock.Random.integer(0, 1),
  901. id: 4,
  902. children: [
  903. {
  904. path: 'https://element-plus-admin-doc.cn/',
  905. name: 'DocumentLink',
  906. status: Mock.Random.integer(0, 1),
  907. id: 5,
  908. meta: {
  909. title: '文档'
  910. }
  911. }
  912. ]
  913. },
  914. {
  915. path: '/level',
  916. component: '#',
  917. redirect: '/level/menu1/menu1-1/menu1-1-1',
  918. name: 'Level',
  919. status: Mock.Random.integer(0, 1),
  920. id: 6,
  921. meta: {
  922. title: '菜单',
  923. icon: 'carbon:skill-level-advanced'
  924. },
  925. children: [
  926. {
  927. path: 'menu1',
  928. name: 'Menu1',
  929. component: '##',
  930. status: Mock.Random.integer(0, 1),
  931. id: 7,
  932. redirect: '/level/menu1/menu1-1/menu1-1-1',
  933. meta: {
  934. title: '菜单1'
  935. },
  936. children: [
  937. {
  938. path: 'menu1-1',
  939. name: 'Menu11',
  940. component: '##',
  941. status: Mock.Random.integer(0, 1),
  942. id: 8,
  943. redirect: '/level/menu1/menu1-1/menu1-1-1',
  944. meta: {
  945. title: '菜单1-1',
  946. alwaysShow: true
  947. },
  948. children: [
  949. {
  950. path: 'menu1-1-1',
  951. name: 'Menu111',
  952. component: 'views/Level/Menu111',
  953. status: Mock.Random.integer(0, 1),
  954. id: 9,
  955. permission: ['edit', 'add', 'delete'],
  956. meta: {
  957. title: '菜单1-1-1',
  958. permission: ['edit', 'add', 'delete']
  959. }
  960. }
  961. ]
  962. },
  963. {
  964. path: 'menu1-2',
  965. name: 'Menu12',
  966. component: 'views/Level/Menu12',
  967. status: Mock.Random.integer(0, 1),
  968. id: 10,
  969. permission: ['edit', 'add', 'delete'],
  970. meta: {
  971. title: '菜单1-2',
  972. permission: ['edit', 'add', 'delete']
  973. }
  974. }
  975. ]
  976. },
  977. {
  978. path: 'menu2',
  979. name: 'Menu2Demo',
  980. component: 'views/Level/Menu2',
  981. status: Mock.Random.integer(0, 1),
  982. id: 11,
  983. permission: ['edit', 'add', 'delete'],
  984. meta: {
  985. title: '菜单2',
  986. permission: ['edit', 'add', 'delete']
  987. }
  988. }
  989. ]
  990. }
  991. ],
  992. [
  993. {
  994. path: '/example',
  995. component: '#',
  996. redirect: '/example/example-dialog',
  997. name: 'Example',
  998. status: Mock.Random.integer(0, 1),
  999. id: 12,
  1000. meta: {
  1001. title: '综合示例',
  1002. icon: 'ep:management',
  1003. alwaysShow: true
  1004. },
  1005. children: [
  1006. {
  1007. path: 'example-detail',
  1008. component: 'views/Example/Page/ExampleDetail',
  1009. name: 'ExampleDetail',
  1010. status: Mock.Random.integer(0, 1),
  1011. id: 17,
  1012. permission: ['edit', 'add', 'delete'],
  1013. meta: {
  1014. title: '综合示例-详情',
  1015. noTagsView: true,
  1016. noCache: true,
  1017. hidden: true,
  1018. showMainRoute: true,
  1019. activeMenu: '/example/example-page',
  1020. permission: ['edit', 'add', 'delete']
  1021. }
  1022. }
  1023. ]
  1024. }
  1025. ]
  1026. ]
  1027. for (let i = 0; i < 4; i++) {
  1028. List.push(
  1029. Mock.mock({
  1030. id: toAnyString(),
  1031. // timestamp: +Mock.Random.date('T'),
  1032. roleName: roleNames[i],
  1033. role: '@first',
  1034. status: Mock.Random.integer(0, 1),
  1035. createTime: '@datetime',
  1036. remark: '@cword(10, 15)',
  1037. menu: menus[i]
  1038. })
  1039. )
  1040. }
  1041. export default [
  1042. // 列表接口
  1043. {
  1044. url: '/role/list',
  1045. method: 'get',
  1046. timeout,
  1047. response: ({ query }) => {
  1048. const { roleName } = query
  1049. return {
  1050. data: {
  1051. code: code,
  1052. data: roleName === 'admin' ? adminList : testList
  1053. }
  1054. }
  1055. }
  1056. },
  1057. {
  1058. url: '/role/table',
  1059. method: 'get',
  1060. timeout,
  1061. response: () => {
  1062. return {
  1063. data: {
  1064. code: code,
  1065. data: {
  1066. list: List,
  1067. total: 4
  1068. }
  1069. }
  1070. }
  1071. }
  1072. }
  1073. ] as MockMethod[]