index.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. import config from '@/config/axios/config'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. const { code } = config
  4. const timeout = 1000
  5. const adminList = [
  6. {
  7. path: '/dashboard',
  8. component: '#',
  9. redirect: '/dashboard/analysis',
  10. name: 'Dashboard',
  11. meta: {
  12. title: 'router.dashboard',
  13. icon: 'ant-design:dashboard-filled',
  14. alwaysShow: true
  15. },
  16. children: [
  17. {
  18. path: 'analysis',
  19. component: 'views/Dashboard/Analysis',
  20. name: 'Analysis',
  21. meta: {
  22. title: 'router.analysis',
  23. noCache: true
  24. }
  25. },
  26. {
  27. path: 'workplace',
  28. component: 'views/Dashboard/Workplace',
  29. name: 'Workplace',
  30. meta: {
  31. title: 'router.workplace',
  32. noCache: true
  33. }
  34. }
  35. ]
  36. },
  37. {
  38. path: '/external-link',
  39. component: '#',
  40. meta: {},
  41. name: 'ExternalLink',
  42. children: [
  43. {
  44. path: 'https://element-plus-admin-doc.cn/',
  45. name: 'DocumentLink',
  46. meta: {
  47. title: 'router.document',
  48. icon: 'clarity:document-solid'
  49. }
  50. }
  51. ]
  52. },
  53. {
  54. path: '/guide',
  55. component: '#',
  56. name: 'Guide',
  57. meta: {},
  58. children: [
  59. {
  60. path: 'index',
  61. component: 'views/Guide/Guide',
  62. name: 'GuideDemo',
  63. meta: {
  64. title: 'router.guide',
  65. icon: 'cib:telegram-plane'
  66. }
  67. }
  68. ]
  69. },
  70. {
  71. path: '/components',
  72. component: '#',
  73. redirect: '/components/form/default-form',
  74. name: 'ComponentsDemo',
  75. meta: {
  76. title: 'router.component',
  77. icon: 'bx:bxs-component',
  78. alwaysShow: true
  79. },
  80. children: [
  81. {
  82. path: 'form',
  83. component: '##',
  84. name: 'Form',
  85. meta: {
  86. title: 'router.form',
  87. alwaysShow: true
  88. },
  89. children: [
  90. {
  91. path: 'default-form',
  92. component: 'views/Components/Form/DefaultForm',
  93. name: 'DefaultForm',
  94. meta: {
  95. title: 'router.defaultForm'
  96. }
  97. },
  98. {
  99. path: 'use-form',
  100. component: 'views/Components/Form/UseFormDemo',
  101. name: 'UseForm',
  102. meta: {
  103. title: 'UseForm'
  104. }
  105. },
  106. {
  107. path: 'ref-form',
  108. component: 'views/Components/Form/RefForm',
  109. name: 'RefForm',
  110. meta: {
  111. title: 'RefForm'
  112. }
  113. }
  114. ]
  115. },
  116. {
  117. path: 'table',
  118. component: '##',
  119. redirect: '/components/table/default-table',
  120. name: 'TableDemo',
  121. meta: {
  122. title: 'router.table',
  123. alwaysShow: true
  124. },
  125. children: [
  126. {
  127. path: 'default-table',
  128. component: 'views/Components/Table/DefaultTable',
  129. name: 'DefaultTable',
  130. meta: {
  131. title: 'router.defaultTable'
  132. }
  133. },
  134. {
  135. path: 'use-table',
  136. component: 'views/Components/Table/UseTableDemo',
  137. name: 'UseTable',
  138. meta: {
  139. title: 'UseTable'
  140. }
  141. },
  142. {
  143. path: 'tree-table',
  144. component: 'views/Components/Table/TreeTable',
  145. name: 'TreeTable',
  146. meta: {
  147. title: 'TreeTable'
  148. }
  149. },
  150. {
  151. path: 'ref-table',
  152. component: 'views/Components/Table/RefTable',
  153. name: 'RefTable',
  154. meta: {
  155. title: 'RefTable'
  156. }
  157. }
  158. ]
  159. },
  160. {
  161. path: 'editor-demo',
  162. component: '##',
  163. redirect: '/components/editor-demo/editor',
  164. name: 'EditorDemo',
  165. meta: {
  166. title: 'router.editor',
  167. alwaysShow: true
  168. },
  169. children: [
  170. {
  171. path: 'editor',
  172. component: 'views/Components/Editor/Editor',
  173. name: 'Editor',
  174. meta: {
  175. title: 'router.richText'
  176. }
  177. }
  178. ]
  179. },
  180. {
  181. path: 'search',
  182. component: 'views/Components/Search',
  183. name: 'Search',
  184. meta: {
  185. title: 'router.search'
  186. }
  187. },
  188. {
  189. path: 'descriptions',
  190. component: 'views/Components/Descriptions',
  191. name: 'Descriptions',
  192. meta: {
  193. title: 'router.descriptions'
  194. }
  195. },
  196. {
  197. path: 'image-viewer',
  198. component: 'views/Components/ImageViewer',
  199. name: 'ImageViewer',
  200. meta: {
  201. title: 'router.imageViewer'
  202. }
  203. },
  204. {
  205. path: 'dialog',
  206. component: 'views/Components/Dialog',
  207. name: 'Dialog',
  208. meta: {
  209. title: 'router.dialog'
  210. }
  211. },
  212. {
  213. path: 'icon',
  214. component: 'views/Components/Icon',
  215. name: 'Icon',
  216. meta: {
  217. title: 'router.icon'
  218. }
  219. },
  220. {
  221. path: 'echart',
  222. component: 'views/Components/Echart',
  223. name: 'Echart',
  224. meta: {
  225. title: 'router.echart'
  226. }
  227. },
  228. {
  229. path: 'count-to',
  230. component: 'views/Components/CountTo',
  231. name: 'CountTo',
  232. meta: {
  233. title: 'router.countTo'
  234. }
  235. },
  236. {
  237. path: 'qrcode',
  238. component: 'views/Components/Qrcode',
  239. name: 'Qrcode',
  240. meta: {
  241. title: 'router.qrcode'
  242. }
  243. },
  244. {
  245. path: 'highlight',
  246. component: 'views/Components/Highlight',
  247. name: 'Highlight',
  248. meta: {
  249. title: 'router.highlight'
  250. }
  251. },
  252. {
  253. path: 'infotip',
  254. component: 'views/Components/Infotip',
  255. name: 'Infotip',
  256. meta: {
  257. title: 'router.infotip'
  258. }
  259. },
  260. {
  261. path: 'input-password',
  262. component: 'views/Components/InputPassword',
  263. name: 'InputPassword',
  264. meta: {
  265. title: 'router.inputPassword'
  266. }
  267. },
  268. {
  269. path: 'sticky',
  270. component: 'views/Components/Sticky',
  271. name: 'Sticky',
  272. meta: {
  273. title: 'router.sticky'
  274. }
  275. }
  276. ]
  277. },
  278. {
  279. path: '/hooks',
  280. component: '#',
  281. redirect: '/hooks/useWatermark',
  282. name: 'Hooks',
  283. meta: {
  284. title: 'hooks',
  285. icon: 'ic:outline-webhook',
  286. alwaysShow: true
  287. },
  288. children: [
  289. {
  290. path: 'useWatermark',
  291. component: 'views/hooks/useWatermark',
  292. name: 'UseWatermark',
  293. meta: {
  294. title: 'useWatermark'
  295. }
  296. },
  297. {
  298. path: 'useCrudSchemas',
  299. component: 'views/hooks/useCrudSchemas',
  300. name: 'UseCrudSchemas',
  301. meta: {
  302. title: 'useCrudSchemas'
  303. }
  304. }
  305. ]
  306. },
  307. {
  308. path: '/level',
  309. component: '#',
  310. redirect: '/level/menu1/menu1-1/menu1-1-1',
  311. name: 'Level',
  312. meta: {
  313. title: 'router.level',
  314. icon: 'carbon:skill-level-advanced'
  315. },
  316. children: [
  317. {
  318. path: 'menu1',
  319. name: 'Menu1',
  320. component: '##',
  321. redirect: '/level/menu1/menu1-1/menu1-1-1',
  322. meta: {
  323. title: 'router.menu1'
  324. },
  325. children: [
  326. {
  327. path: 'menu1-1',
  328. name: 'Menu11',
  329. component: '##',
  330. redirect: '/level/menu1/menu1-1/menu1-1-1',
  331. meta: {
  332. title: 'router.menu11',
  333. alwaysShow: true
  334. },
  335. children: [
  336. {
  337. path: 'menu1-1-1',
  338. name: 'Menu111',
  339. component: 'views/Level/Menu111',
  340. meta: {
  341. title: 'router.menu111'
  342. }
  343. }
  344. ]
  345. },
  346. {
  347. path: 'menu1-2',
  348. name: 'Menu12',
  349. component: 'views/Level/Menu12',
  350. meta: {
  351. title: 'router.menu12'
  352. }
  353. }
  354. ]
  355. },
  356. {
  357. path: 'menu2',
  358. name: 'Menu2Demo',
  359. component: 'views/Level/Menu2',
  360. meta: {
  361. title: 'router.menu2'
  362. }
  363. }
  364. ]
  365. },
  366. {
  367. path: '/example',
  368. component: '#',
  369. redirect: '/example/example-dialog',
  370. name: 'Example',
  371. meta: {
  372. title: 'router.example',
  373. icon: 'ep:management',
  374. alwaysShow: true
  375. },
  376. children: [
  377. {
  378. path: 'example-dialog',
  379. component: 'views/Example/Dialog/ExampleDialog',
  380. name: 'ExampleDialog',
  381. meta: {
  382. title: 'router.exampleDialog'
  383. }
  384. },
  385. {
  386. path: 'example-page',
  387. component: 'views/Example/Page/ExamplePage',
  388. name: 'ExamplePage',
  389. meta: {
  390. title: 'router.examplePage'
  391. }
  392. },
  393. {
  394. path: 'example-add',
  395. component: 'views/Example/Page/ExampleAdd',
  396. name: 'ExampleAdd',
  397. meta: {
  398. title: 'router.exampleAdd',
  399. noTagsView: true,
  400. noCache: true,
  401. hidden: true,
  402. showMainRoute: true,
  403. activeMenu: '/example/example-page'
  404. }
  405. },
  406. {
  407. path: 'example-edit',
  408. component: 'views/Example/Page/ExampleEdit',
  409. name: 'ExampleEdit',
  410. meta: {
  411. title: 'router.exampleEdit',
  412. noTagsView: true,
  413. noCache: true,
  414. hidden: true,
  415. showMainRoute: true,
  416. activeMenu: '/example/example-page'
  417. }
  418. },
  419. {
  420. path: 'example-detail',
  421. component: 'views/Example/Page/ExampleDetail',
  422. name: 'ExampleDetail',
  423. meta: {
  424. title: 'router.exampleDetail',
  425. noTagsView: true,
  426. noCache: true,
  427. hidden: true,
  428. showMainRoute: true,
  429. activeMenu: '/example/example-page'
  430. }
  431. }
  432. ]
  433. },
  434. {
  435. path: '/error',
  436. component: '#',
  437. redirect: '/error/404',
  438. name: 'Error',
  439. meta: {
  440. title: 'router.errorPage',
  441. icon: 'ci:error',
  442. alwaysShow: true
  443. },
  444. children: [
  445. {
  446. path: '404-demo',
  447. component: 'views/Error/404',
  448. name: '404Demo',
  449. meta: {
  450. title: '404'
  451. }
  452. },
  453. {
  454. path: '403-demo',
  455. component: 'views/Error/403',
  456. name: '403Demo',
  457. meta: {
  458. title: '403'
  459. }
  460. },
  461. {
  462. path: '500-demo',
  463. component: 'views/Error/500',
  464. name: '500Demo',
  465. meta: {
  466. title: '500'
  467. }
  468. }
  469. ]
  470. }
  471. ]
  472. const testList: string[] = [
  473. '/dashboard',
  474. '/dashboard/analysis',
  475. '/dashboard/workplace',
  476. 'external-link',
  477. 'https://element-plus-admin-doc.cn/',
  478. '/guide',
  479. '/guide/index',
  480. '/components',
  481. '/components/form',
  482. '/components/form/default-form',
  483. '/components/form/use-form',
  484. '/components/form/ref-form',
  485. '/components/table',
  486. '/components/table/default-table',
  487. '/components/table/use-table',
  488. '/components/table/tree-table',
  489. '/components/table/ref-table',
  490. '/components/editor-demo',
  491. '/components/editor-demo/editor',
  492. '/components/search',
  493. '/components/descriptions',
  494. '/components/image-viewer',
  495. '/components/dialog',
  496. '/components/icon',
  497. '/components/echart',
  498. '/components/count-to',
  499. '/components/qrcode',
  500. '/components/highlight',
  501. '/components/infotip',
  502. '/Components/InputPassword',
  503. '/Components/Sticky',
  504. '/hooks',
  505. '/hooks/useWatermark',
  506. '/hooks/useCrudSchemas',
  507. '/level',
  508. '/level/menu1',
  509. '/level/menu1/menu1-1',
  510. '/level/menu1/menu1-1/menu1-1-1',
  511. '/level/menu1/menu1-2',
  512. '/level/menu2',
  513. '/example',
  514. '/example/example-dialog',
  515. '/example/example-page',
  516. '/example/example-add',
  517. '/example/example-edit',
  518. '/example/example-detail',
  519. '/error',
  520. '/error/404-demo',
  521. '/error/403-demo',
  522. '/error/500-demo'
  523. ]
  524. export default [
  525. // 列表接口
  526. {
  527. url: '/role/list',
  528. method: 'get',
  529. timeout,
  530. response: ({ query }) => {
  531. const { roleName } = query
  532. return {
  533. data: {
  534. code: code,
  535. data: roleName === 'admin' ? adminList : testList
  536. }
  537. }
  538. }
  539. }
  540. ] as MockMethod[]