index.ts 27 KB

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