index.ts 27 KB

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