index.ts 24 KB

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