index.ts 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  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. path: 'json-editor',
  182. component: 'views/Components/Editor/JsonEditor',
  183. name: 'JsonEditor',
  184. meta: {
  185. title: 'router.jsonEditor'
  186. }
  187. }
  188. ]
  189. },
  190. {
  191. path: 'search',
  192. component: 'views/Components/Search',
  193. name: 'Search',
  194. meta: {
  195. title: 'router.search'
  196. }
  197. },
  198. {
  199. path: 'descriptions',
  200. component: 'views/Components/Descriptions',
  201. name: 'Descriptions',
  202. meta: {
  203. title: 'router.descriptions'
  204. }
  205. },
  206. {
  207. path: 'image-viewer',
  208. component: 'views/Components/ImageViewer',
  209. name: 'ImageViewer',
  210. meta: {
  211. title: 'router.imageViewer'
  212. }
  213. },
  214. {
  215. path: 'dialog',
  216. component: 'views/Components/Dialog',
  217. name: 'Dialog',
  218. meta: {
  219. title: 'router.dialog'
  220. }
  221. },
  222. {
  223. path: 'icon',
  224. component: 'views/Components/Icon',
  225. name: 'Icon',
  226. meta: {
  227. title: 'router.icon'
  228. }
  229. },
  230. {
  231. path: 'icon-picker',
  232. component: 'views/Components/IconPicker',
  233. name: 'IconPicker',
  234. meta: {
  235. title: 'router.iconPicker'
  236. }
  237. },
  238. {
  239. path: 'echart',
  240. component: 'views/Components/Echart',
  241. name: 'Echart',
  242. meta: {
  243. title: 'router.echart'
  244. }
  245. },
  246. {
  247. path: 'count-to',
  248. component: 'views/Components/CountTo',
  249. name: 'CountTo',
  250. meta: {
  251. title: 'router.countTo'
  252. }
  253. },
  254. {
  255. path: 'qrcode',
  256. component: 'views/Components/Qrcode',
  257. name: 'Qrcode',
  258. meta: {
  259. title: 'router.qrcode'
  260. }
  261. },
  262. {
  263. path: 'highlight',
  264. component: 'views/Components/Highlight',
  265. name: 'Highlight',
  266. meta: {
  267. title: 'router.highlight'
  268. }
  269. },
  270. {
  271. path: 'infotip',
  272. component: 'views/Components/Infotip',
  273. name: 'Infotip',
  274. meta: {
  275. title: 'router.infotip'
  276. }
  277. },
  278. {
  279. path: 'input-password',
  280. component: 'views/Components/InputPassword',
  281. name: 'InputPassword',
  282. meta: {
  283. title: 'router.inputPassword'
  284. }
  285. },
  286. {
  287. path: 'waterfall',
  288. component: 'views/Components/Waterfall',
  289. name: 'Waterfall',
  290. meta: {
  291. title: 'router.waterfall'
  292. }
  293. },
  294. {
  295. path: 'image-cropping',
  296. component: 'views/Components/ImageCropping',
  297. name: 'ImageCropping',
  298. meta: {
  299. title: 'router.imageCropping'
  300. }
  301. },
  302. {
  303. path: 'video-player',
  304. component: 'views/Components/VideoPlayer',
  305. name: 'VideoPlayer',
  306. meta: {
  307. title: 'router.videoPlayer'
  308. }
  309. }
  310. ]
  311. },
  312. {
  313. path: '/function',
  314. component: '#',
  315. redirect: '/function/multipleTabs',
  316. name: 'Function',
  317. meta: {
  318. title: 'router.function',
  319. icon: 'ri:function-fill',
  320. alwaysShow: true
  321. },
  322. children: [
  323. {
  324. path: 'multipleTabs',
  325. component: 'views/Function/MultipleTabs',
  326. name: 'MultipleTabs',
  327. meta: {
  328. title: 'router.multipleTabs'
  329. }
  330. },
  331. {
  332. path: 'multipleTabs-demo/:id',
  333. component: 'views/Function/MultipleTabsDemo',
  334. name: 'MultipleTabsDemo',
  335. meta: {
  336. hidden: true,
  337. title: 'router.details',
  338. canTo: true
  339. }
  340. },
  341. {
  342. path: 'request',
  343. component: 'views/Function/Request',
  344. name: 'Request',
  345. meta: {
  346. title: 'router.request'
  347. }
  348. },
  349. {
  350. path: 'test',
  351. component: () => 'views/Function/Test',
  352. name: 'Test',
  353. meta: {
  354. title: 'router.permission',
  355. permission: ['add', 'edit', 'delete']
  356. }
  357. }
  358. ]
  359. },
  360. {
  361. path: '/hooks',
  362. component: '#',
  363. redirect: '/hooks/useWatermark',
  364. name: 'Hooks',
  365. meta: {
  366. title: 'hooks',
  367. icon: 'ic:outline-webhook',
  368. alwaysShow: true
  369. },
  370. children: [
  371. {
  372. path: 'useWatermark',
  373. component: 'views/hooks/useWatermark',
  374. name: 'UseWatermark',
  375. meta: {
  376. title: 'useWatermark'
  377. }
  378. },
  379. {
  380. path: 'useTagsView',
  381. component: 'views/hooks/useTagsView',
  382. name: 'UseTagsView',
  383. meta: {
  384. title: 'useTagsView'
  385. }
  386. },
  387. {
  388. path: 'useValidator',
  389. component: 'views/hooks/useValidator',
  390. name: 'UseValidator',
  391. meta: {
  392. title: 'useValidator'
  393. }
  394. },
  395. {
  396. path: 'useCrudSchemas',
  397. component: 'views/hooks/useCrudSchemas',
  398. name: 'UseCrudSchemas',
  399. meta: {
  400. title: 'useCrudSchemas'
  401. }
  402. },
  403. {
  404. path: 'useClipboard',
  405. component: 'views/hooks/useClipboard',
  406. name: 'UseClipboard',
  407. meta: {
  408. title: 'useClipboard'
  409. }
  410. },
  411. {
  412. path: 'useNetwork',
  413. component: 'views/hooks/useNetwork',
  414. name: 'UseNetwork',
  415. meta: {
  416. title: 'useNetwork'
  417. }
  418. }
  419. ]
  420. },
  421. {
  422. path: '/level',
  423. component: '#',
  424. redirect: '/level/menu1/menu1-1/menu1-1-1',
  425. name: 'Level',
  426. meta: {
  427. title: 'router.level',
  428. icon: 'carbon:skill-level-advanced'
  429. },
  430. children: [
  431. {
  432. path: 'menu1',
  433. name: 'Menu1',
  434. component: '##',
  435. redirect: '/level/menu1/menu1-1/menu1-1-1',
  436. meta: {
  437. title: 'router.menu1'
  438. },
  439. children: [
  440. {
  441. path: 'menu1-1',
  442. name: 'Menu11',
  443. component: '##',
  444. redirect: '/level/menu1/menu1-1/menu1-1-1',
  445. meta: {
  446. title: 'router.menu11',
  447. alwaysShow: true
  448. },
  449. children: [
  450. {
  451. path: 'menu1-1-1',
  452. name: 'Menu111',
  453. component: 'views/Level/Menu111',
  454. meta: {
  455. title: 'router.menu111'
  456. }
  457. }
  458. ]
  459. },
  460. {
  461. path: 'menu1-2',
  462. name: 'Menu12',
  463. component: 'views/Level/Menu12',
  464. meta: {
  465. title: 'router.menu12'
  466. }
  467. }
  468. ]
  469. },
  470. {
  471. path: 'menu2',
  472. name: 'Menu2Demo',
  473. component: 'views/Level/Menu2',
  474. meta: {
  475. title: 'router.menu2'
  476. }
  477. }
  478. ]
  479. },
  480. {
  481. path: '/example',
  482. component: '#',
  483. redirect: '/example/example-dialog',
  484. name: 'Example',
  485. meta: {
  486. title: 'router.example',
  487. icon: 'ep:management',
  488. alwaysShow: true
  489. },
  490. children: [
  491. {
  492. path: 'example-dialog',
  493. component: 'views/Example/Dialog/ExampleDialog',
  494. name: 'ExampleDialog',
  495. meta: {
  496. title: 'router.exampleDialog'
  497. }
  498. },
  499. {
  500. path: 'example-page',
  501. component: 'views/Example/Page/ExamplePage',
  502. name: 'ExamplePage',
  503. meta: {
  504. title: 'router.examplePage'
  505. }
  506. },
  507. {
  508. path: 'example-add',
  509. component: 'views/Example/Page/ExampleAdd',
  510. name: 'ExampleAdd',
  511. meta: {
  512. title: 'router.exampleAdd',
  513. noTagsView: true,
  514. noCache: true,
  515. hidden: true,
  516. showMainRoute: true,
  517. activeMenu: '/example/example-page'
  518. }
  519. },
  520. {
  521. path: 'example-edit',
  522. component: 'views/Example/Page/ExampleEdit',
  523. name: 'ExampleEdit',
  524. meta: {
  525. title: 'router.exampleEdit',
  526. noTagsView: true,
  527. noCache: true,
  528. hidden: true,
  529. showMainRoute: true,
  530. activeMenu: '/example/example-page'
  531. }
  532. },
  533. {
  534. path: 'example-detail',
  535. component: 'views/Example/Page/ExampleDetail',
  536. name: 'ExampleDetail',
  537. meta: {
  538. title: 'router.exampleDetail',
  539. noTagsView: true,
  540. noCache: true,
  541. hidden: true,
  542. showMainRoute: true,
  543. activeMenu: '/example/example-page'
  544. }
  545. }
  546. ]
  547. },
  548. {
  549. path: '/error',
  550. component: '#',
  551. redirect: '/error/404',
  552. name: 'Error',
  553. meta: {
  554. title: 'router.errorPage',
  555. icon: 'ci:error',
  556. alwaysShow: true
  557. },
  558. children: [
  559. {
  560. path: '404-demo',
  561. component: 'views/Error/404',
  562. name: '404Demo',
  563. meta: {
  564. title: '404'
  565. }
  566. },
  567. {
  568. path: '403-demo',
  569. component: 'views/Error/403',
  570. name: '403Demo',
  571. meta: {
  572. title: '403'
  573. }
  574. },
  575. {
  576. path: '500-demo',
  577. component: 'views/Error/500',
  578. name: '500Demo',
  579. meta: {
  580. title: '500'
  581. }
  582. }
  583. ]
  584. },
  585. {
  586. path: '/authorization',
  587. component: '#',
  588. redirect: '/authorization/user',
  589. name: 'Authorization',
  590. meta: {
  591. title: 'router.authorization',
  592. icon: 'eos-icons:role-binding',
  593. alwaysShow: true
  594. },
  595. children: [
  596. {
  597. path: 'department',
  598. component: 'views/Authorization/Department/Department',
  599. name: 'Department',
  600. meta: {
  601. title: 'router.department'
  602. }
  603. },
  604. {
  605. path: 'user',
  606. component: 'views/Authorization/User/User',
  607. name: 'User',
  608. meta: {
  609. title: 'router.user'
  610. }
  611. },
  612. {
  613. path: 'menu',
  614. component: 'views/Authorization/Menu/Menu',
  615. name: 'Menu',
  616. meta: {
  617. title: 'router.menuManagement'
  618. }
  619. },
  620. {
  621. path: 'role',
  622. component: 'views/Authorization/Role/Role',
  623. name: 'Role',
  624. meta: {
  625. title: 'router.role'
  626. }
  627. }
  628. ]
  629. }
  630. ]
  631. const testList: string[] = [
  632. '/dashboard',
  633. '/dashboard/analysis',
  634. '/dashboard/workplace',
  635. 'external-link',
  636. 'https://element-plus-admin-doc.cn/',
  637. '/guide',
  638. '/guide/index',
  639. '/components',
  640. '/components/form',
  641. '/components/form/default-form',
  642. '/components/form/use-form',
  643. '/components/form/ref-form',
  644. '/components/table',
  645. '/components/table/default-table',
  646. '/components/table/use-table',
  647. '/components/table/tree-table',
  648. '/components/table/table-image-preview',
  649. '/components/table/ref-table',
  650. '/components/editor-demo',
  651. '/components/editor-demo/editor',
  652. '/components/editor-demo/json-editor',
  653. '/components/search',
  654. '/components/descriptions',
  655. '/components/image-viewer',
  656. '/components/dialog',
  657. '/components/icon',
  658. '/components/iconPicker',
  659. '/components/echart',
  660. '/components/count-to',
  661. '/components/qrcode',
  662. '/components/highlight',
  663. '/components/infotip',
  664. '/components/input-password',
  665. '/components/waterfall',
  666. '/components/image-cropping',
  667. '/components/video-player',
  668. 'function',
  669. '/function/multiple-tabs',
  670. '/function/multiple-tabs-demo/:id',
  671. '/function/request',
  672. '/function/test',
  673. '/hooks',
  674. '/hooks/useWatermark',
  675. '/hooks/useTagsView',
  676. '/hooks/useValidator',
  677. '/hooks/useCrudSchemas',
  678. '/hooks/useClipboard',
  679. '/hooks/useNetwork',
  680. '/level',
  681. '/level/menu1',
  682. '/level/menu1/menu1-1',
  683. '/level/menu1/menu1-1/menu1-1-1',
  684. '/level/menu1/menu1-2',
  685. '/level/menu2',
  686. '/example',
  687. '/example/example-dialog',
  688. '/example/example-page',
  689. '/example/example-add',
  690. '/example/example-edit',
  691. '/example/example-detail',
  692. '/authorization',
  693. '/authorization/department',
  694. '/authorization/user',
  695. '/authorization/role',
  696. '/authorization/menu',
  697. '/error',
  698. '/error/404-demo',
  699. '/error/403-demo',
  700. '/error/500-demo'
  701. ]
  702. const List: any[] = []
  703. const roleNames = ['超级管理员', '管理员', '普通用户', '游客']
  704. const menus = [
  705. [
  706. {
  707. path: '/dashboard',
  708. component: '#',
  709. redirect: '/dashboard/analysis',
  710. name: 'Dashboard',
  711. status: Mock.Random.integer(0, 1),
  712. id: 1,
  713. meta: {
  714. title: '首页',
  715. icon: 'ant-design:dashboard-filled',
  716. alwaysShow: true
  717. },
  718. children: [
  719. {
  720. path: 'analysis',
  721. component: 'views/Dashboard/Analysis',
  722. name: 'Analysis',
  723. status: Mock.Random.integer(0, 1),
  724. id: 2,
  725. meta: {
  726. title: '分析页',
  727. noCache: true
  728. }
  729. },
  730. {
  731. path: 'workplace',
  732. component: 'views/Dashboard/Workplace',
  733. name: 'Workplace',
  734. status: Mock.Random.integer(0, 1),
  735. id: 3,
  736. meta: {
  737. title: '工作台',
  738. noCache: true
  739. }
  740. }
  741. ]
  742. },
  743. {
  744. path: '/external-link',
  745. component: '#',
  746. meta: {
  747. title: '文档',
  748. icon: 'clarity:document-solid'
  749. },
  750. name: 'ExternalLink',
  751. status: Mock.Random.integer(0, 1),
  752. id: 4,
  753. children: [
  754. {
  755. path: 'https://element-plus-admin-doc.cn/',
  756. name: 'DocumentLink',
  757. status: Mock.Random.integer(0, 1),
  758. id: 5,
  759. meta: {
  760. title: '文档'
  761. }
  762. }
  763. ]
  764. },
  765. {
  766. path: '/level',
  767. component: '#',
  768. redirect: '/level/menu1/menu1-1/menu1-1-1',
  769. name: 'Level',
  770. status: Mock.Random.integer(0, 1),
  771. id: 6,
  772. meta: {
  773. title: '菜单',
  774. icon: 'carbon:skill-level-advanced'
  775. },
  776. children: [
  777. {
  778. path: 'menu1',
  779. name: 'Menu1',
  780. component: '##',
  781. status: Mock.Random.integer(0, 1),
  782. id: 7,
  783. redirect: '/level/menu1/menu1-1/menu1-1-1',
  784. meta: {
  785. title: '菜单1'
  786. },
  787. children: [
  788. {
  789. path: 'menu1-1',
  790. name: 'Menu11',
  791. component: '##',
  792. status: Mock.Random.integer(0, 1),
  793. id: 8,
  794. redirect: '/level/menu1/menu1-1/menu1-1-1',
  795. meta: {
  796. title: '菜单1-1',
  797. alwaysShow: true
  798. },
  799. children: [
  800. {
  801. path: 'menu1-1-1',
  802. name: 'Menu111',
  803. component: 'views/Level/Menu111',
  804. status: Mock.Random.integer(0, 1),
  805. id: 9,
  806. permission: ['edit', 'add', 'delete'],
  807. meta: {
  808. title: '菜单1-1-1',
  809. permission: ['edit', 'add', 'delete']
  810. }
  811. }
  812. ]
  813. },
  814. {
  815. path: 'menu1-2',
  816. name: 'Menu12',
  817. component: 'views/Level/Menu12',
  818. status: Mock.Random.integer(0, 1),
  819. id: 10,
  820. permission: ['edit', 'add', 'delete'],
  821. meta: {
  822. title: '菜单1-2',
  823. permission: ['edit', 'add', 'delete']
  824. }
  825. }
  826. ]
  827. },
  828. {
  829. path: 'menu2',
  830. name: 'Menu2Demo',
  831. component: 'views/Level/Menu2',
  832. status: Mock.Random.integer(0, 1),
  833. id: 11,
  834. permission: ['edit', 'add', 'delete'],
  835. meta: {
  836. title: '菜单2',
  837. permission: ['edit', 'add', 'delete']
  838. }
  839. }
  840. ]
  841. },
  842. {
  843. path: '/example',
  844. component: '#',
  845. redirect: '/example/example-dialog',
  846. name: 'Example',
  847. status: Mock.Random.integer(0, 1),
  848. id: 12,
  849. meta: {
  850. title: '综合示例',
  851. icon: 'ep:management',
  852. alwaysShow: true
  853. },
  854. children: [
  855. {
  856. path: 'example-dialog',
  857. component: 'views/Example/Dialog/ExampleDialog',
  858. name: 'ExampleDialog',
  859. status: Mock.Random.integer(0, 1),
  860. id: 13,
  861. permission: ['edit', 'add', 'delete'],
  862. meta: {
  863. title: '综合示例-弹窗',
  864. permission: ['edit', 'add', 'delete']
  865. }
  866. },
  867. {
  868. path: 'example-page',
  869. component: 'views/Example/Page/ExamplePage',
  870. name: 'ExamplePage',
  871. status: Mock.Random.integer(0, 1),
  872. id: 14,
  873. permission: ['edit', 'add', 'delete'],
  874. meta: {
  875. title: '综合示例-页面',
  876. permission: ['edit', 'add', 'delete']
  877. }
  878. },
  879. {
  880. path: 'example-add',
  881. component: 'views/Example/Page/ExampleAdd',
  882. name: 'ExampleAdd',
  883. status: Mock.Random.integer(0, 1),
  884. id: 15,
  885. permission: ['edit', 'add', 'delete'],
  886. meta: {
  887. title: '综合示例-新增',
  888. noTagsView: true,
  889. noCache: true,
  890. hidden: true,
  891. showMainRoute: true,
  892. activeMenu: '/example/example-page',
  893. permission: ['edit', 'add', 'delete']
  894. }
  895. },
  896. {
  897. path: 'example-edit',
  898. component: 'views/Example/Page/ExampleEdit',
  899. name: 'ExampleEdit',
  900. status: Mock.Random.integer(0, 1),
  901. id: 16,
  902. permission: ['edit', 'add', 'delete'],
  903. meta: {
  904. title: '综合示例-编辑',
  905. noTagsView: true,
  906. noCache: true,
  907. hidden: true,
  908. showMainRoute: true,
  909. activeMenu: '/example/example-page',
  910. permission: ['edit', 'add', 'delete']
  911. }
  912. },
  913. {
  914. path: 'example-detail',
  915. component: 'views/Example/Page/ExampleDetail',
  916. name: 'ExampleDetail',
  917. status: Mock.Random.integer(0, 1),
  918. id: 17,
  919. permission: ['edit', 'add', 'delete'],
  920. meta: {
  921. title: '综合示例-详情',
  922. noTagsView: true,
  923. noCache: true,
  924. hidden: true,
  925. showMainRoute: true,
  926. activeMenu: '/example/example-page',
  927. permission: ['edit', 'add', 'delete']
  928. }
  929. }
  930. ]
  931. }
  932. ],
  933. [
  934. {
  935. path: '/dashboard',
  936. component: '#',
  937. redirect: '/dashboard/analysis',
  938. name: 'Dashboard',
  939. status: Mock.Random.integer(0, 1),
  940. id: 1,
  941. meta: {
  942. title: '首页',
  943. icon: 'ant-design:dashboard-filled',
  944. alwaysShow: true
  945. },
  946. children: [
  947. {
  948. path: 'analysis',
  949. component: 'views/Dashboard/Analysis',
  950. name: 'Analysis',
  951. status: Mock.Random.integer(0, 1),
  952. id: 2,
  953. meta: {
  954. title: '分析页',
  955. noCache: true
  956. }
  957. },
  958. {
  959. path: 'workplace',
  960. component: 'views/Dashboard/Workplace',
  961. name: 'Workplace',
  962. status: Mock.Random.integer(0, 1),
  963. id: 3,
  964. meta: {
  965. title: '工作台',
  966. noCache: true
  967. }
  968. }
  969. ]
  970. }
  971. ],
  972. [
  973. {
  974. path: '/external-link',
  975. component: '#',
  976. meta: {
  977. title: '文档',
  978. icon: 'clarity:document-solid'
  979. },
  980. name: 'ExternalLink',
  981. status: Mock.Random.integer(0, 1),
  982. id: 4,
  983. children: [
  984. {
  985. path: 'https://element-plus-admin-doc.cn/',
  986. name: 'DocumentLink',
  987. status: Mock.Random.integer(0, 1),
  988. id: 5,
  989. meta: {
  990. title: '文档'
  991. }
  992. }
  993. ]
  994. },
  995. {
  996. path: '/level',
  997. component: '#',
  998. redirect: '/level/menu1/menu1-1/menu1-1-1',
  999. name: 'Level',
  1000. status: Mock.Random.integer(0, 1),
  1001. id: 6,
  1002. meta: {
  1003. title: '菜单',
  1004. icon: 'carbon:skill-level-advanced'
  1005. },
  1006. children: [
  1007. {
  1008. path: 'menu1',
  1009. name: 'Menu1',
  1010. component: '##',
  1011. status: Mock.Random.integer(0, 1),
  1012. id: 7,
  1013. redirect: '/level/menu1/menu1-1/menu1-1-1',
  1014. meta: {
  1015. title: '菜单1'
  1016. },
  1017. children: [
  1018. {
  1019. path: 'menu1-1',
  1020. name: 'Menu11',
  1021. component: '##',
  1022. status: Mock.Random.integer(0, 1),
  1023. id: 8,
  1024. redirect: '/level/menu1/menu1-1/menu1-1-1',
  1025. meta: {
  1026. title: '菜单1-1',
  1027. alwaysShow: true
  1028. },
  1029. children: [
  1030. {
  1031. path: 'menu1-1-1',
  1032. name: 'Menu111',
  1033. component: 'views/Level/Menu111',
  1034. status: Mock.Random.integer(0, 1),
  1035. id: 9,
  1036. permission: ['edit', 'add', 'delete'],
  1037. meta: {
  1038. title: '菜单1-1-1',
  1039. permission: ['edit', 'add', 'delete']
  1040. }
  1041. }
  1042. ]
  1043. },
  1044. {
  1045. path: 'menu1-2',
  1046. name: 'Menu12',
  1047. component: 'views/Level/Menu12',
  1048. status: Mock.Random.integer(0, 1),
  1049. id: 10,
  1050. permission: ['edit', 'add', 'delete'],
  1051. meta: {
  1052. title: '菜单1-2',
  1053. permission: ['edit', 'add', 'delete']
  1054. }
  1055. }
  1056. ]
  1057. },
  1058. {
  1059. path: 'menu2',
  1060. name: 'Menu2Demo',
  1061. component: 'views/Level/Menu2',
  1062. status: Mock.Random.integer(0, 1),
  1063. id: 11,
  1064. permission: ['edit', 'add', 'delete'],
  1065. meta: {
  1066. title: '菜单2',
  1067. permission: ['edit', 'add', 'delete']
  1068. }
  1069. }
  1070. ]
  1071. }
  1072. ],
  1073. [
  1074. {
  1075. path: '/example',
  1076. component: '#',
  1077. redirect: '/example/example-dialog',
  1078. name: 'Example',
  1079. status: Mock.Random.integer(0, 1),
  1080. id: 12,
  1081. meta: {
  1082. title: '综合示例',
  1083. icon: 'ep:management',
  1084. alwaysShow: true
  1085. },
  1086. children: [
  1087. {
  1088. path: 'example-detail',
  1089. component: 'views/Example/Page/ExampleDetail',
  1090. name: 'ExampleDetail',
  1091. status: Mock.Random.integer(0, 1),
  1092. id: 17,
  1093. permission: ['edit', 'add', 'delete'],
  1094. meta: {
  1095. title: '综合示例-详情',
  1096. noTagsView: true,
  1097. noCache: true,
  1098. hidden: true,
  1099. showMainRoute: true,
  1100. activeMenu: '/example/example-page',
  1101. permission: ['edit', 'add', 'delete']
  1102. }
  1103. }
  1104. ]
  1105. }
  1106. ]
  1107. ]
  1108. for (let i = 0; i < 4; i++) {
  1109. List.push(
  1110. Mock.mock({
  1111. id: toAnyString(),
  1112. // timestamp: +Mock.Random.date('T'),
  1113. roleName: roleNames[i],
  1114. role: '@first',
  1115. status: Mock.Random.integer(0, 1),
  1116. createTime: '@datetime',
  1117. remark: '@cword(10, 15)',
  1118. menu: menus[i]
  1119. })
  1120. )
  1121. }
  1122. export default [
  1123. // 列表接口
  1124. {
  1125. url: '/role/list',
  1126. method: 'get',
  1127. timeout,
  1128. response: () => {
  1129. return {
  1130. code: code,
  1131. data: adminList
  1132. }
  1133. }
  1134. },
  1135. {
  1136. url: '/role/table',
  1137. method: 'get',
  1138. timeout,
  1139. response: () => {
  1140. return {
  1141. code: code,
  1142. data: {
  1143. list: List,
  1144. total: 4
  1145. }
  1146. }
  1147. }
  1148. },
  1149. // 列表接口
  1150. {
  1151. url: '/role/list2',
  1152. method: 'get',
  1153. timeout,
  1154. response: () => {
  1155. return {
  1156. code: code,
  1157. data: testList
  1158. }
  1159. }
  1160. },
  1161. {
  1162. url: '/role/table',
  1163. method: 'get',
  1164. timeout,
  1165. response: () => {
  1166. return {
  1167. code: code,
  1168. data: {
  1169. list: List,
  1170. total: 4
  1171. }
  1172. }
  1173. }
  1174. }
  1175. ] as MockMethod[]