index.ts 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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: 'useValidator',
  332. component: 'views/hooks/useValidator',
  333. name: 'UseValidator',
  334. meta: {
  335. title: 'useValidator'
  336. }
  337. }
  338. // {
  339. // path: 'useCrudSchemas',
  340. // component: 'views/hooks/useCrudSchemas',
  341. // name: 'UseCrudSchemas',
  342. // meta: {
  343. // title: 'useCrudSchemas'
  344. // }
  345. // }
  346. ]
  347. },
  348. {
  349. path: '/level',
  350. component: '#',
  351. redirect: '/level/menu1/menu1-1/menu1-1-1',
  352. name: 'Level',
  353. meta: {
  354. title: 'router.level',
  355. icon: 'carbon:skill-level-advanced'
  356. },
  357. children: [
  358. {
  359. path: 'menu1',
  360. name: 'Menu1',
  361. component: '##',
  362. redirect: '/level/menu1/menu1-1/menu1-1-1',
  363. meta: {
  364. title: 'router.menu1'
  365. },
  366. children: [
  367. {
  368. path: 'menu1-1',
  369. name: 'Menu11',
  370. component: '##',
  371. redirect: '/level/menu1/menu1-1/menu1-1-1',
  372. meta: {
  373. title: 'router.menu11',
  374. alwaysShow: true
  375. },
  376. children: [
  377. {
  378. path: 'menu1-1-1',
  379. name: 'Menu111',
  380. component: 'views/Level/Menu111',
  381. meta: {
  382. title: 'router.menu111'
  383. }
  384. }
  385. ]
  386. },
  387. {
  388. path: 'menu1-2',
  389. name: 'Menu12',
  390. component: 'views/Level/Menu12',
  391. meta: {
  392. title: 'router.menu12'
  393. }
  394. }
  395. ]
  396. },
  397. {
  398. path: 'menu2',
  399. name: 'Menu2Demo',
  400. component: 'views/Level/Menu2',
  401. meta: {
  402. title: 'router.menu2'
  403. }
  404. }
  405. ]
  406. },
  407. {
  408. path: '/example',
  409. component: '#',
  410. redirect: '/example/example-dialog',
  411. name: 'Example',
  412. meta: {
  413. title: 'router.example',
  414. icon: 'ep:management',
  415. alwaysShow: true
  416. },
  417. children: [
  418. {
  419. path: 'example-dialog',
  420. component: 'views/Example/Dialog/ExampleDialog',
  421. name: 'ExampleDialog',
  422. meta: {
  423. title: 'router.exampleDialog'
  424. }
  425. },
  426. {
  427. path: 'example-page',
  428. component: 'views/Example/Page/ExamplePage',
  429. name: 'ExamplePage',
  430. meta: {
  431. title: 'router.examplePage'
  432. }
  433. },
  434. {
  435. path: 'example-add',
  436. component: 'views/Example/Page/ExampleAdd',
  437. name: 'ExampleAdd',
  438. meta: {
  439. title: 'router.exampleAdd',
  440. noTagsView: true,
  441. noCache: true,
  442. hidden: true,
  443. showMainRoute: true,
  444. activeMenu: '/example/example-page'
  445. }
  446. },
  447. {
  448. path: 'example-edit',
  449. component: 'views/Example/Page/ExampleEdit',
  450. name: 'ExampleEdit',
  451. meta: {
  452. title: 'router.exampleEdit',
  453. noTagsView: true,
  454. noCache: true,
  455. hidden: true,
  456. showMainRoute: true,
  457. activeMenu: '/example/example-page'
  458. }
  459. },
  460. {
  461. path: 'example-detail',
  462. component: 'views/Example/Page/ExampleDetail',
  463. name: 'ExampleDetail',
  464. meta: {
  465. title: 'router.exampleDetail',
  466. noTagsView: true,
  467. noCache: true,
  468. hidden: true,
  469. showMainRoute: true,
  470. activeMenu: '/example/example-page'
  471. }
  472. }
  473. ]
  474. },
  475. {
  476. path: '/error',
  477. component: '#',
  478. redirect: '/error/404',
  479. name: 'Error',
  480. meta: {
  481. title: 'router.errorPage',
  482. icon: 'ci:error',
  483. alwaysShow: true
  484. },
  485. children: [
  486. {
  487. path: '404-demo',
  488. component: 'views/Error/404',
  489. name: '404Demo',
  490. meta: {
  491. title: '404'
  492. }
  493. },
  494. {
  495. path: '403-demo',
  496. component: 'views/Error/403',
  497. name: '403Demo',
  498. meta: {
  499. title: '403'
  500. }
  501. },
  502. {
  503. path: '500-demo',
  504. component: 'views/Error/500',
  505. name: '500Demo',
  506. meta: {
  507. title: '500'
  508. }
  509. }
  510. ]
  511. },
  512. {
  513. path: '/authorization',
  514. component: '#',
  515. redirect: '/authorization/user',
  516. name: 'Authorization',
  517. meta: {
  518. title: 'router.authorization',
  519. icon: 'eos-icons:role-binding',
  520. alwaysShow: true
  521. },
  522. children: [
  523. {
  524. path: 'department',
  525. component: 'views/Authorization/Department/Department',
  526. name: 'Department',
  527. meta: {
  528. title: 'router.department'
  529. }
  530. },
  531. {
  532. path: 'user',
  533. component: 'views/Authorization/User/User',
  534. name: 'User',
  535. meta: {
  536. title: 'router.user'
  537. }
  538. },
  539. {
  540. path: 'menu',
  541. component: 'views/Authorization/Menu/Menu',
  542. name: 'Menu',
  543. meta: {
  544. title: 'router.menuManagement'
  545. }
  546. },
  547. {
  548. path: 'role',
  549. component: 'views/Authorization/Role/Role',
  550. name: 'Role',
  551. meta: {
  552. title: 'router.role'
  553. }
  554. },
  555. {
  556. path: 'test',
  557. component: 'views/Authorization/Test/Test',
  558. name: 'Test',
  559. meta: {
  560. title: 'router.permission'
  561. }
  562. }
  563. ]
  564. }
  565. ]
  566. const testList: string[] = [
  567. '/dashboard',
  568. '/dashboard/analysis',
  569. '/dashboard/workplace',
  570. 'external-link',
  571. 'https://element-plus-admin-doc.cn/',
  572. '/guide',
  573. '/guide/index',
  574. '/components',
  575. '/components/form',
  576. '/components/form/default-form',
  577. '/components/form/use-form',
  578. '/components/form/ref-form',
  579. '/components/table',
  580. '/components/table/default-table',
  581. '/components/table/use-table',
  582. '/components/table/tree-table',
  583. '/components/table/table-image-preview',
  584. '/components/table/ref-table',
  585. '/components/editor-demo',
  586. '/components/editor-demo/editor',
  587. '/components/search',
  588. '/components/descriptions',
  589. '/components/image-viewer',
  590. '/components/dialog',
  591. '/components/icon',
  592. '/components/echart',
  593. '/components/count-to',
  594. '/components/qrcode',
  595. '/components/highlight',
  596. '/components/infotip',
  597. '/Components/InputPassword',
  598. '/Components/Sticky',
  599. 'function',
  600. '/function/multiple-tabs',
  601. '/function/multiple-tabs-demo/:id',
  602. '/hooks',
  603. '/hooks/useWatermark',
  604. '/hooks/useTagsView',
  605. '/hooks/useValidator',
  606. // '/hooks/useCrudSchemas',
  607. '/level',
  608. '/level/menu1',
  609. '/level/menu1/menu1-1',
  610. '/level/menu1/menu1-1/menu1-1-1',
  611. '/level/menu1/menu1-2',
  612. '/level/menu2',
  613. '/example',
  614. '/example/example-dialog',
  615. '/example/example-page',
  616. '/example/example-add',
  617. '/example/example-edit',
  618. '/example/example-detail',
  619. '/authorization',
  620. '/authorization/department',
  621. '/authorization/user',
  622. '/authorization/role',
  623. '/authorization/menu',
  624. '/authorization/test',
  625. '/error',
  626. '/error/404-demo',
  627. '/error/403-demo',
  628. '/error/500-demo'
  629. ]
  630. const List: any[] = []
  631. const roleNames = ['超级管理员', '管理员', '普通用户', '游客']
  632. const menus = [
  633. [
  634. {
  635. path: '/dashboard',
  636. component: '#',
  637. redirect: '/dashboard/analysis',
  638. name: 'Dashboard',
  639. status: Mock.Random.integer(0, 1),
  640. id: 1,
  641. meta: {
  642. title: '首页',
  643. icon: 'ant-design:dashboard-filled',
  644. alwaysShow: true
  645. },
  646. children: [
  647. {
  648. path: 'analysis',
  649. component: 'views/Dashboard/Analysis',
  650. name: 'Analysis',
  651. status: Mock.Random.integer(0, 1),
  652. id: 2,
  653. meta: {
  654. title: '分析页',
  655. noCache: true
  656. }
  657. },
  658. {
  659. path: 'workplace',
  660. component: 'views/Dashboard/Workplace',
  661. name: 'Workplace',
  662. status: Mock.Random.integer(0, 1),
  663. id: 3,
  664. meta: {
  665. title: '工作台',
  666. noCache: true
  667. }
  668. }
  669. ]
  670. },
  671. {
  672. path: '/external-link',
  673. component: '#',
  674. meta: {
  675. title: '文档',
  676. icon: 'clarity:document-solid'
  677. },
  678. name: 'ExternalLink',
  679. status: Mock.Random.integer(0, 1),
  680. id: 4,
  681. children: [
  682. {
  683. path: 'https://element-plus-admin-doc.cn/',
  684. name: 'DocumentLink',
  685. status: Mock.Random.integer(0, 1),
  686. id: 5,
  687. meta: {
  688. title: '文档'
  689. }
  690. }
  691. ]
  692. },
  693. {
  694. path: '/level',
  695. component: '#',
  696. redirect: '/level/menu1/menu1-1/menu1-1-1',
  697. name: 'Level',
  698. status: Mock.Random.integer(0, 1),
  699. id: 6,
  700. meta: {
  701. title: '菜单',
  702. icon: 'carbon:skill-level-advanced'
  703. },
  704. children: [
  705. {
  706. path: 'menu1',
  707. name: 'Menu1',
  708. component: '##',
  709. status: Mock.Random.integer(0, 1),
  710. id: 7,
  711. redirect: '/level/menu1/menu1-1/menu1-1-1',
  712. meta: {
  713. title: '菜单1'
  714. },
  715. children: [
  716. {
  717. path: 'menu1-1',
  718. name: 'Menu11',
  719. component: '##',
  720. status: Mock.Random.integer(0, 1),
  721. id: 8,
  722. redirect: '/level/menu1/menu1-1/menu1-1-1',
  723. meta: {
  724. title: '菜单1-1',
  725. alwaysShow: true
  726. },
  727. children: [
  728. {
  729. path: 'menu1-1-1',
  730. name: 'Menu111',
  731. component: 'views/Level/Menu111',
  732. status: Mock.Random.integer(0, 1),
  733. id: 9,
  734. permission: ['edit', 'add', 'delete'],
  735. meta: {
  736. title: '菜单1-1-1',
  737. permission: ['edit', 'add', 'delete']
  738. }
  739. }
  740. ]
  741. },
  742. {
  743. path: 'menu1-2',
  744. name: 'Menu12',
  745. component: 'views/Level/Menu12',
  746. status: Mock.Random.integer(0, 1),
  747. id: 10,
  748. permission: ['edit', 'add', 'delete'],
  749. meta: {
  750. title: '菜单1-2',
  751. permission: ['edit', 'add', 'delete']
  752. }
  753. }
  754. ]
  755. },
  756. {
  757. path: 'menu2',
  758. name: 'Menu2Demo',
  759. component: 'views/Level/Menu2',
  760. status: Mock.Random.integer(0, 1),
  761. id: 11,
  762. permission: ['edit', 'add', 'delete'],
  763. meta: {
  764. title: '菜单2',
  765. permission: ['edit', 'add', 'delete']
  766. }
  767. }
  768. ]
  769. },
  770. {
  771. path: '/example',
  772. component: '#',
  773. redirect: '/example/example-dialog',
  774. name: 'Example',
  775. status: Mock.Random.integer(0, 1),
  776. id: 12,
  777. meta: {
  778. title: '综合示例',
  779. icon: 'ep:management',
  780. alwaysShow: true
  781. },
  782. children: [
  783. {
  784. path: 'example-dialog',
  785. component: 'views/Example/Dialog/ExampleDialog',
  786. name: 'ExampleDialog',
  787. status: Mock.Random.integer(0, 1),
  788. id: 13,
  789. permission: ['edit', 'add', 'delete'],
  790. meta: {
  791. title: '综合示例-弹窗',
  792. permission: ['edit', 'add', 'delete']
  793. }
  794. },
  795. {
  796. path: 'example-page',
  797. component: 'views/Example/Page/ExamplePage',
  798. name: 'ExamplePage',
  799. status: Mock.Random.integer(0, 1),
  800. id: 14,
  801. permission: ['edit', 'add', 'delete'],
  802. meta: {
  803. title: '综合示例-页面',
  804. permission: ['edit', 'add', 'delete']
  805. }
  806. },
  807. {
  808. path: 'example-add',
  809. component: 'views/Example/Page/ExampleAdd',
  810. name: 'ExampleAdd',
  811. status: Mock.Random.integer(0, 1),
  812. id: 15,
  813. permission: ['edit', 'add', 'delete'],
  814. meta: {
  815. title: '综合示例-新增',
  816. noTagsView: true,
  817. noCache: true,
  818. hidden: true,
  819. showMainRoute: true,
  820. activeMenu: '/example/example-page',
  821. permission: ['edit', 'add', 'delete']
  822. }
  823. },
  824. {
  825. path: 'example-edit',
  826. component: 'views/Example/Page/ExampleEdit',
  827. name: 'ExampleEdit',
  828. status: Mock.Random.integer(0, 1),
  829. id: 16,
  830. permission: ['edit', 'add', 'delete'],
  831. meta: {
  832. title: '综合示例-编辑',
  833. noTagsView: true,
  834. noCache: true,
  835. hidden: true,
  836. showMainRoute: true,
  837. activeMenu: '/example/example-page',
  838. permission: ['edit', 'add', 'delete']
  839. }
  840. },
  841. {
  842. path: 'example-detail',
  843. component: 'views/Example/Page/ExampleDetail',
  844. name: 'ExampleDetail',
  845. status: Mock.Random.integer(0, 1),
  846. id: 17,
  847. permission: ['edit', 'add', 'delete'],
  848. meta: {
  849. title: '综合示例-详情',
  850. noTagsView: true,
  851. noCache: true,
  852. hidden: true,
  853. showMainRoute: true,
  854. activeMenu: '/example/example-page',
  855. permission: ['edit', 'add', 'delete']
  856. }
  857. }
  858. ]
  859. }
  860. ],
  861. [
  862. {
  863. path: '/dashboard',
  864. component: '#',
  865. redirect: '/dashboard/analysis',
  866. name: 'Dashboard',
  867. status: Mock.Random.integer(0, 1),
  868. id: 1,
  869. meta: {
  870. title: '首页',
  871. icon: 'ant-design:dashboard-filled',
  872. alwaysShow: true
  873. },
  874. children: [
  875. {
  876. path: 'analysis',
  877. component: 'views/Dashboard/Analysis',
  878. name: 'Analysis',
  879. status: Mock.Random.integer(0, 1),
  880. id: 2,
  881. meta: {
  882. title: '分析页',
  883. noCache: true
  884. }
  885. },
  886. {
  887. path: 'workplace',
  888. component: 'views/Dashboard/Workplace',
  889. name: 'Workplace',
  890. status: Mock.Random.integer(0, 1),
  891. id: 3,
  892. meta: {
  893. title: '工作台',
  894. noCache: true
  895. }
  896. }
  897. ]
  898. }
  899. ],
  900. [
  901. {
  902. path: '/external-link',
  903. component: '#',
  904. meta: {
  905. title: '文档',
  906. icon: 'clarity:document-solid'
  907. },
  908. name: 'ExternalLink',
  909. status: Mock.Random.integer(0, 1),
  910. id: 4,
  911. children: [
  912. {
  913. path: 'https://element-plus-admin-doc.cn/',
  914. name: 'DocumentLink',
  915. status: Mock.Random.integer(0, 1),
  916. id: 5,
  917. meta: {
  918. title: '文档'
  919. }
  920. }
  921. ]
  922. },
  923. {
  924. path: '/level',
  925. component: '#',
  926. redirect: '/level/menu1/menu1-1/menu1-1-1',
  927. name: 'Level',
  928. status: Mock.Random.integer(0, 1),
  929. id: 6,
  930. meta: {
  931. title: '菜单',
  932. icon: 'carbon:skill-level-advanced'
  933. },
  934. children: [
  935. {
  936. path: 'menu1',
  937. name: 'Menu1',
  938. component: '##',
  939. status: Mock.Random.integer(0, 1),
  940. id: 7,
  941. redirect: '/level/menu1/menu1-1/menu1-1-1',
  942. meta: {
  943. title: '菜单1'
  944. },
  945. children: [
  946. {
  947. path: 'menu1-1',
  948. name: 'Menu11',
  949. component: '##',
  950. status: Mock.Random.integer(0, 1),
  951. id: 8,
  952. redirect: '/level/menu1/menu1-1/menu1-1-1',
  953. meta: {
  954. title: '菜单1-1',
  955. alwaysShow: true
  956. },
  957. children: [
  958. {
  959. path: 'menu1-1-1',
  960. name: 'Menu111',
  961. component: 'views/Level/Menu111',
  962. status: Mock.Random.integer(0, 1),
  963. id: 9,
  964. permission: ['edit', 'add', 'delete'],
  965. meta: {
  966. title: '菜单1-1-1',
  967. permission: ['edit', 'add', 'delete']
  968. }
  969. }
  970. ]
  971. },
  972. {
  973. path: 'menu1-2',
  974. name: 'Menu12',
  975. component: 'views/Level/Menu12',
  976. status: Mock.Random.integer(0, 1),
  977. id: 10,
  978. permission: ['edit', 'add', 'delete'],
  979. meta: {
  980. title: '菜单1-2',
  981. permission: ['edit', 'add', 'delete']
  982. }
  983. }
  984. ]
  985. },
  986. {
  987. path: 'menu2',
  988. name: 'Menu2Demo',
  989. component: 'views/Level/Menu2',
  990. status: Mock.Random.integer(0, 1),
  991. id: 11,
  992. permission: ['edit', 'add', 'delete'],
  993. meta: {
  994. title: '菜单2',
  995. permission: ['edit', 'add', 'delete']
  996. }
  997. }
  998. ]
  999. }
  1000. ],
  1001. [
  1002. {
  1003. path: '/example',
  1004. component: '#',
  1005. redirect: '/example/example-dialog',
  1006. name: 'Example',
  1007. status: Mock.Random.integer(0, 1),
  1008. id: 12,
  1009. meta: {
  1010. title: '综合示例',
  1011. icon: 'ep:management',
  1012. alwaysShow: true
  1013. },
  1014. children: [
  1015. {
  1016. path: 'example-detail',
  1017. component: 'views/Example/Page/ExampleDetail',
  1018. name: 'ExampleDetail',
  1019. status: Mock.Random.integer(0, 1),
  1020. id: 17,
  1021. permission: ['edit', 'add', 'delete'],
  1022. meta: {
  1023. title: '综合示例-详情',
  1024. noTagsView: true,
  1025. noCache: true,
  1026. hidden: true,
  1027. showMainRoute: true,
  1028. activeMenu: '/example/example-page',
  1029. permission: ['edit', 'add', 'delete']
  1030. }
  1031. }
  1032. ]
  1033. }
  1034. ]
  1035. ]
  1036. for (let i = 0; i < 4; i++) {
  1037. List.push(
  1038. Mock.mock({
  1039. id: toAnyString(),
  1040. // timestamp: +Mock.Random.date('T'),
  1041. roleName: roleNames[i],
  1042. role: '@first',
  1043. status: Mock.Random.integer(0, 1),
  1044. createTime: '@datetime',
  1045. remark: '@cword(10, 15)',
  1046. menu: menus[i]
  1047. })
  1048. )
  1049. }
  1050. export default [
  1051. // 列表接口
  1052. {
  1053. url: '/role/list',
  1054. method: 'get',
  1055. timeout,
  1056. response: ({ query }) => {
  1057. const { roleName } = query
  1058. return {
  1059. data: {
  1060. code: code,
  1061. data: roleName === 'admin' ? adminList : testList
  1062. }
  1063. }
  1064. }
  1065. },
  1066. {
  1067. url: '/role/table',
  1068. method: 'get',
  1069. timeout,
  1070. response: () => {
  1071. return {
  1072. data: {
  1073. code: code,
  1074. data: {
  1075. list: List,
  1076. total: 4
  1077. }
  1078. }
  1079. }
  1080. }
  1081. }
  1082. ] as MockMethod[]