index.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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. },
  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. },
  272. {
  273. path: '/hooks',
  274. component: '#',
  275. redirect: '/hooks/useWatermark',
  276. name: 'Hooks',
  277. meta: {
  278. title: 'hooks',
  279. icon: 'ic:outline-webhook',
  280. alwaysShow: true
  281. },
  282. children: [
  283. {
  284. path: 'useWatermark',
  285. component: 'views/hooks/useWatermark',
  286. name: 'UseWatermark',
  287. meta: {
  288. title: 'useWatermark'
  289. }
  290. },
  291. {
  292. path: 'useOpenTab',
  293. component: 'views/hooks/useOpenTab',
  294. name: 'UseOpenTab',
  295. meta: {
  296. title: 'useOpenTab'
  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. path: '/authorization',
  475. component: '#',
  476. redirect: '/authorization/user',
  477. name: 'Authorization',
  478. meta: {
  479. title: 'router.authorization',
  480. icon: 'eos-icons:role-binding',
  481. alwaysShow: true
  482. },
  483. children: [
  484. {
  485. path: 'department',
  486. component: 'views/Authorization/Department/Department',
  487. name: 'Department',
  488. meta: {
  489. title: 'router.department'
  490. }
  491. },
  492. {
  493. path: 'user',
  494. component: 'views/Authorization/User/User',
  495. name: 'User',
  496. meta: {
  497. title: 'router.user'
  498. }
  499. },
  500. {
  501. path: 'menu',
  502. component: 'views/Authorization/Menu/Menu',
  503. name: 'Menu',
  504. meta: {
  505. title: 'router.menuManagement'
  506. }
  507. },
  508. {
  509. path: 'role',
  510. component: 'views/Authorization/Role/Role',
  511. name: 'Role',
  512. meta: {
  513. title: 'router.role'
  514. }
  515. },
  516. {
  517. path: 'test',
  518. component: 'views/Authorization/Test/Test',
  519. name: 'Test',
  520. meta: {
  521. title: 'router.permission'
  522. }
  523. }
  524. ]
  525. }
  526. ]
  527. const testList: string[] = [
  528. '/dashboard',
  529. '/dashboard/analysis',
  530. '/dashboard/workplace',
  531. 'external-link',
  532. 'https://element-plus-admin-doc.cn/',
  533. '/guide',
  534. '/guide/index',
  535. '/components',
  536. '/components/form',
  537. '/components/form/default-form',
  538. '/components/form/use-form',
  539. '/components/form/ref-form',
  540. '/components/table',
  541. '/components/table/default-table',
  542. '/components/table/use-table',
  543. '/components/table/tree-table',
  544. '/components/table/table-image-preview',
  545. '/components/table/ref-table',
  546. '/components/editor-demo',
  547. '/components/editor-demo/editor',
  548. '/components/search',
  549. '/components/descriptions',
  550. '/components/image-viewer',
  551. '/components/dialog',
  552. '/components/icon',
  553. '/components/echart',
  554. '/components/count-to',
  555. '/components/qrcode',
  556. '/components/highlight',
  557. '/components/infotip',
  558. '/Components/InputPassword',
  559. '/Components/Sticky',
  560. '/hooks',
  561. '/hooks/useWatermark',
  562. '/hooks/useOpenTab',
  563. // '/hooks/useCrudSchemas',
  564. '/level',
  565. '/level/menu1',
  566. '/level/menu1/menu1-1',
  567. '/level/menu1/menu1-1/menu1-1-1',
  568. '/level/menu1/menu1-2',
  569. '/level/menu2',
  570. '/example',
  571. '/example/example-dialog',
  572. '/example/example-page',
  573. '/example/example-add',
  574. '/example/example-edit',
  575. '/example/example-detail',
  576. '/authorization',
  577. '/authorization/department',
  578. '/authorization/user',
  579. '/authorization/role',
  580. '/authorization/menu',
  581. '/authorization/test',
  582. '/error',
  583. '/error/404-demo',
  584. '/error/403-demo',
  585. '/error/500-demo'
  586. ]
  587. const List: any[] = []
  588. const roleNames = ['超级管理员', '管理员', '普通用户', '游客']
  589. const menus = [
  590. [
  591. {
  592. path: '/dashboard',
  593. component: '#',
  594. redirect: '/dashboard/analysis',
  595. name: 'Dashboard',
  596. status: Mock.Random.integer(0, 1),
  597. id: 1,
  598. meta: {
  599. title: '首页',
  600. icon: 'ant-design:dashboard-filled',
  601. alwaysShow: true
  602. },
  603. children: [
  604. {
  605. path: 'analysis',
  606. component: 'views/Dashboard/Analysis',
  607. name: 'Analysis',
  608. status: Mock.Random.integer(0, 1),
  609. id: 2,
  610. meta: {
  611. title: '分析页',
  612. noCache: true
  613. }
  614. },
  615. {
  616. path: 'workplace',
  617. component: 'views/Dashboard/Workplace',
  618. name: 'Workplace',
  619. status: Mock.Random.integer(0, 1),
  620. id: 3,
  621. meta: {
  622. title: '工作台',
  623. noCache: true
  624. }
  625. }
  626. ]
  627. },
  628. {
  629. path: '/external-link',
  630. component: '#',
  631. meta: {
  632. title: '文档',
  633. icon: 'clarity:document-solid'
  634. },
  635. name: 'ExternalLink',
  636. status: Mock.Random.integer(0, 1),
  637. id: 4,
  638. children: [
  639. {
  640. path: 'https://element-plus-admin-doc.cn/',
  641. name: 'DocumentLink',
  642. status: Mock.Random.integer(0, 1),
  643. id: 5,
  644. meta: {
  645. title: '文档'
  646. }
  647. }
  648. ]
  649. },
  650. {
  651. path: '/level',
  652. component: '#',
  653. redirect: '/level/menu1/menu1-1/menu1-1-1',
  654. name: 'Level',
  655. status: Mock.Random.integer(0, 1),
  656. id: 6,
  657. meta: {
  658. title: '菜单',
  659. icon: 'carbon:skill-level-advanced'
  660. },
  661. children: [
  662. {
  663. path: 'menu1',
  664. name: 'Menu1',
  665. component: '##',
  666. status: Mock.Random.integer(0, 1),
  667. id: 7,
  668. redirect: '/level/menu1/menu1-1/menu1-1-1',
  669. meta: {
  670. title: '菜单1'
  671. },
  672. children: [
  673. {
  674. path: 'menu1-1',
  675. name: 'Menu11',
  676. component: '##',
  677. status: Mock.Random.integer(0, 1),
  678. id: 8,
  679. redirect: '/level/menu1/menu1-1/menu1-1-1',
  680. meta: {
  681. title: '菜单1-1',
  682. alwaysShow: true
  683. },
  684. children: [
  685. {
  686. path: 'menu1-1-1',
  687. name: 'Menu111',
  688. component: 'views/Level/Menu111',
  689. status: Mock.Random.integer(0, 1),
  690. id: 9,
  691. permission: ['edit', 'add', 'delete'],
  692. meta: {
  693. title: '菜单1-1-1',
  694. permission: ['edit', 'add', 'delete']
  695. }
  696. }
  697. ]
  698. },
  699. {
  700. path: 'menu1-2',
  701. name: 'Menu12',
  702. component: 'views/Level/Menu12',
  703. status: Mock.Random.integer(0, 1),
  704. id: 10,
  705. permission: ['edit', 'add', 'delete'],
  706. meta: {
  707. title: '菜单1-2',
  708. permission: ['edit', 'add', 'delete']
  709. }
  710. }
  711. ]
  712. },
  713. {
  714. path: 'menu2',
  715. name: 'Menu2Demo',
  716. component: 'views/Level/Menu2',
  717. status: Mock.Random.integer(0, 1),
  718. id: 11,
  719. permission: ['edit', 'add', 'delete'],
  720. meta: {
  721. title: '菜单2',
  722. permission: ['edit', 'add', 'delete']
  723. }
  724. }
  725. ]
  726. },
  727. {
  728. path: '/example',
  729. component: '#',
  730. redirect: '/example/example-dialog',
  731. name: 'Example',
  732. status: Mock.Random.integer(0, 1),
  733. id: 12,
  734. meta: {
  735. title: '综合示例',
  736. icon: 'ep:management',
  737. alwaysShow: true
  738. },
  739. children: [
  740. {
  741. path: 'example-dialog',
  742. component: 'views/Example/Dialog/ExampleDialog',
  743. name: 'ExampleDialog',
  744. status: Mock.Random.integer(0, 1),
  745. id: 13,
  746. permission: ['edit', 'add', 'delete'],
  747. meta: {
  748. title: '综合示例-弹窗',
  749. permission: ['edit', 'add', 'delete']
  750. }
  751. },
  752. {
  753. path: 'example-page',
  754. component: 'views/Example/Page/ExamplePage',
  755. name: 'ExamplePage',
  756. status: Mock.Random.integer(0, 1),
  757. id: 14,
  758. permission: ['edit', 'add', 'delete'],
  759. meta: {
  760. title: '综合示例-页面',
  761. permission: ['edit', 'add', 'delete']
  762. }
  763. },
  764. {
  765. path: 'example-add',
  766. component: 'views/Example/Page/ExampleAdd',
  767. name: 'ExampleAdd',
  768. status: Mock.Random.integer(0, 1),
  769. id: 15,
  770. permission: ['edit', 'add', 'delete'],
  771. meta: {
  772. title: '综合示例-新增',
  773. noTagsView: true,
  774. noCache: true,
  775. hidden: true,
  776. showMainRoute: true,
  777. activeMenu: '/example/example-page',
  778. permission: ['edit', 'add', 'delete']
  779. }
  780. },
  781. {
  782. path: 'example-edit',
  783. component: 'views/Example/Page/ExampleEdit',
  784. name: 'ExampleEdit',
  785. status: Mock.Random.integer(0, 1),
  786. id: 16,
  787. permission: ['edit', 'add', 'delete'],
  788. meta: {
  789. title: '综合示例-编辑',
  790. noTagsView: true,
  791. noCache: true,
  792. hidden: true,
  793. showMainRoute: true,
  794. activeMenu: '/example/example-page',
  795. permission: ['edit', 'add', 'delete']
  796. }
  797. },
  798. {
  799. path: 'example-detail',
  800. component: 'views/Example/Page/ExampleDetail',
  801. name: 'ExampleDetail',
  802. status: Mock.Random.integer(0, 1),
  803. id: 17,
  804. permission: ['edit', 'add', 'delete'],
  805. meta: {
  806. title: '综合示例-详情',
  807. noTagsView: true,
  808. noCache: true,
  809. hidden: true,
  810. showMainRoute: true,
  811. activeMenu: '/example/example-page',
  812. permission: ['edit', 'add', 'delete']
  813. }
  814. }
  815. ]
  816. }
  817. ],
  818. [
  819. {
  820. path: '/dashboard',
  821. component: '#',
  822. redirect: '/dashboard/analysis',
  823. name: 'Dashboard',
  824. status: Mock.Random.integer(0, 1),
  825. id: 1,
  826. meta: {
  827. title: '首页',
  828. icon: 'ant-design:dashboard-filled',
  829. alwaysShow: true
  830. },
  831. children: [
  832. {
  833. path: 'analysis',
  834. component: 'views/Dashboard/Analysis',
  835. name: 'Analysis',
  836. status: Mock.Random.integer(0, 1),
  837. id: 2,
  838. meta: {
  839. title: '分析页',
  840. noCache: true
  841. }
  842. },
  843. {
  844. path: 'workplace',
  845. component: 'views/Dashboard/Workplace',
  846. name: 'Workplace',
  847. status: Mock.Random.integer(0, 1),
  848. id: 3,
  849. meta: {
  850. title: '工作台',
  851. noCache: true
  852. }
  853. }
  854. ]
  855. }
  856. ],
  857. [
  858. {
  859. path: '/external-link',
  860. component: '#',
  861. meta: {
  862. title: '文档',
  863. icon: 'clarity:document-solid'
  864. },
  865. name: 'ExternalLink',
  866. status: Mock.Random.integer(0, 1),
  867. id: 4,
  868. children: [
  869. {
  870. path: 'https://element-plus-admin-doc.cn/',
  871. name: 'DocumentLink',
  872. status: Mock.Random.integer(0, 1),
  873. id: 5,
  874. meta: {
  875. title: '文档'
  876. }
  877. }
  878. ]
  879. },
  880. {
  881. path: '/level',
  882. component: '#',
  883. redirect: '/level/menu1/menu1-1/menu1-1-1',
  884. name: 'Level',
  885. status: Mock.Random.integer(0, 1),
  886. id: 6,
  887. meta: {
  888. title: '菜单',
  889. icon: 'carbon:skill-level-advanced'
  890. },
  891. children: [
  892. {
  893. path: 'menu1',
  894. name: 'Menu1',
  895. component: '##',
  896. status: Mock.Random.integer(0, 1),
  897. id: 7,
  898. redirect: '/level/menu1/menu1-1/menu1-1-1',
  899. meta: {
  900. title: '菜单1'
  901. },
  902. children: [
  903. {
  904. path: 'menu1-1',
  905. name: 'Menu11',
  906. component: '##',
  907. status: Mock.Random.integer(0, 1),
  908. id: 8,
  909. redirect: '/level/menu1/menu1-1/menu1-1-1',
  910. meta: {
  911. title: '菜单1-1',
  912. alwaysShow: true
  913. },
  914. children: [
  915. {
  916. path: 'menu1-1-1',
  917. name: 'Menu111',
  918. component: 'views/Level/Menu111',
  919. status: Mock.Random.integer(0, 1),
  920. id: 9,
  921. permission: ['edit', 'add', 'delete'],
  922. meta: {
  923. title: '菜单1-1-1',
  924. permission: ['edit', 'add', 'delete']
  925. }
  926. }
  927. ]
  928. },
  929. {
  930. path: 'menu1-2',
  931. name: 'Menu12',
  932. component: 'views/Level/Menu12',
  933. status: Mock.Random.integer(0, 1),
  934. id: 10,
  935. permission: ['edit', 'add', 'delete'],
  936. meta: {
  937. title: '菜单1-2',
  938. permission: ['edit', 'add', 'delete']
  939. }
  940. }
  941. ]
  942. },
  943. {
  944. path: 'menu2',
  945. name: 'Menu2Demo',
  946. component: 'views/Level/Menu2',
  947. status: Mock.Random.integer(0, 1),
  948. id: 11,
  949. permission: ['edit', 'add', 'delete'],
  950. meta: {
  951. title: '菜单2',
  952. permission: ['edit', 'add', 'delete']
  953. }
  954. }
  955. ]
  956. }
  957. ],
  958. [
  959. {
  960. path: '/example',
  961. component: '#',
  962. redirect: '/example/example-dialog',
  963. name: 'Example',
  964. status: Mock.Random.integer(0, 1),
  965. id: 12,
  966. meta: {
  967. title: '综合示例',
  968. icon: 'ep:management',
  969. alwaysShow: true
  970. },
  971. children: [
  972. {
  973. path: 'example-detail',
  974. component: 'views/Example/Page/ExampleDetail',
  975. name: 'ExampleDetail',
  976. status: Mock.Random.integer(0, 1),
  977. id: 17,
  978. permission: ['edit', 'add', 'delete'],
  979. meta: {
  980. title: '综合示例-详情',
  981. noTagsView: true,
  982. noCache: true,
  983. hidden: true,
  984. showMainRoute: true,
  985. activeMenu: '/example/example-page',
  986. permission: ['edit', 'add', 'delete']
  987. }
  988. }
  989. ]
  990. }
  991. ]
  992. ]
  993. for (let i = 0; i < 4; i++) {
  994. List.push(
  995. Mock.mock({
  996. id: toAnyString(),
  997. // timestamp: +Mock.Random.date('T'),
  998. roleName: roleNames[i],
  999. role: '@first',
  1000. status: Mock.Random.integer(0, 1),
  1001. createTime: '@datetime',
  1002. remark: '@cword(10, 15)',
  1003. menu: menus[i]
  1004. })
  1005. )
  1006. }
  1007. export default [
  1008. // 列表接口
  1009. {
  1010. url: '/role/list',
  1011. method: 'get',
  1012. timeout,
  1013. response: ({ query }) => {
  1014. const { roleName } = query
  1015. return {
  1016. data: {
  1017. code: code,
  1018. data: roleName === 'admin' ? adminList : testList
  1019. }
  1020. }
  1021. }
  1022. },
  1023. {
  1024. url: '/role/table',
  1025. method: 'get',
  1026. timeout,
  1027. response: () => {
  1028. return {
  1029. data: {
  1030. code: code,
  1031. data: {
  1032. list: List,
  1033. total: 4
  1034. }
  1035. }
  1036. }
  1037. }
  1038. }
  1039. ] as MockMethod[]