index.ts 27 KB

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