index.ts 26 KB

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