index.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. data: {
  1068. code: code,
  1069. data: adminList
  1070. }
  1071. }
  1072. }
  1073. },
  1074. {
  1075. url: '/role/table',
  1076. method: 'get',
  1077. timeout,
  1078. response: () => {
  1079. return {
  1080. data: {
  1081. code: code,
  1082. data: {
  1083. list: List,
  1084. total: 4
  1085. }
  1086. }
  1087. }
  1088. }
  1089. },
  1090. // 列表接口
  1091. {
  1092. url: '/role/list2',
  1093. method: 'get',
  1094. timeout,
  1095. response: () => {
  1096. return {
  1097. data: {
  1098. code: code,
  1099. data: testList
  1100. }
  1101. }
  1102. }
  1103. },
  1104. {
  1105. url: '/role/table',
  1106. method: 'get',
  1107. timeout,
  1108. response: () => {
  1109. return {
  1110. data: {
  1111. code: code,
  1112. data: {
  1113. list: List,
  1114. total: 4
  1115. }
  1116. }
  1117. }
  1118. }
  1119. }
  1120. ] as MockMethod[]