index.ts 23 KB

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