index.ts 26 KB

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