index.ts 27 KB

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