index.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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: 'router.TreeTable'
  148. }
  149. },
  150. {
  151. path: 'table-image-preview',
  152. component: 'views/Components/Table/TableImagePreview',
  153. name: 'TableImagePreview',
  154. meta: {
  155. title: 'router.PicturePreview'
  156. }
  157. },
  158. {
  159. path: 'ref-table',
  160. component: 'views/Components/Table/RefTable',
  161. name: 'RefTable',
  162. meta: {
  163. title: 'RefTable'
  164. }
  165. }
  166. ]
  167. },
  168. {
  169. path: 'editor-demo',
  170. component: '##',
  171. redirect: '/components/editor-demo/editor',
  172. name: 'EditorDemo',
  173. meta: {
  174. title: 'router.editor',
  175. alwaysShow: true
  176. },
  177. children: [
  178. {
  179. path: 'editor',
  180. component: 'views/Components/Editor/Editor',
  181. name: 'Editor',
  182. meta: {
  183. title: 'router.richText'
  184. }
  185. }
  186. ]
  187. },
  188. {
  189. path: 'search',
  190. component: 'views/Components/Search',
  191. name: 'Search',
  192. meta: {
  193. title: 'router.search'
  194. }
  195. },
  196. {
  197. path: 'descriptions',
  198. component: 'views/Components/Descriptions',
  199. name: 'Descriptions',
  200. meta: {
  201. title: 'router.descriptions'
  202. }
  203. },
  204. {
  205. path: 'image-viewer',
  206. component: 'views/Components/ImageViewer',
  207. name: 'ImageViewer',
  208. meta: {
  209. title: 'router.imageViewer'
  210. }
  211. },
  212. {
  213. path: 'dialog',
  214. component: 'views/Components/Dialog',
  215. name: 'Dialog',
  216. meta: {
  217. title: 'router.dialog'
  218. }
  219. },
  220. {
  221. path: 'icon',
  222. component: 'views/Components/Icon',
  223. name: 'Icon',
  224. meta: {
  225. title: 'router.icon'
  226. }
  227. },
  228. {
  229. path: 'echart',
  230. component: 'views/Components/Echart',
  231. name: 'Echart',
  232. meta: {
  233. title: 'router.echart'
  234. }
  235. },
  236. {
  237. path: 'count-to',
  238. component: 'views/Components/CountTo',
  239. name: 'CountTo',
  240. meta: {
  241. title: 'router.countTo'
  242. }
  243. },
  244. {
  245. path: 'qrcode',
  246. component: 'views/Components/Qrcode',
  247. name: 'Qrcode',
  248. meta: {
  249. title: 'router.qrcode'
  250. }
  251. },
  252. {
  253. path: 'highlight',
  254. component: 'views/Components/Highlight',
  255. name: 'Highlight',
  256. meta: {
  257. title: 'router.highlight'
  258. }
  259. },
  260. {
  261. path: 'infotip',
  262. component: 'views/Components/Infotip',
  263. name: 'Infotip',
  264. meta: {
  265. title: 'router.infotip'
  266. }
  267. },
  268. {
  269. path: 'input-password',
  270. component: 'views/Components/InputPassword',
  271. name: 'InputPassword',
  272. meta: {
  273. title: 'router.inputPassword'
  274. }
  275. },
  276. {
  277. path: 'sticky',
  278. component: 'views/Components/Sticky',
  279. name: 'Sticky',
  280. meta: {
  281. title: 'router.sticky'
  282. }
  283. }
  284. ]
  285. },
  286. {
  287. path: '/hooks',
  288. component: '#',
  289. redirect: '/hooks/useWatermark',
  290. name: 'Hooks',
  291. meta: {
  292. title: 'hooks',
  293. icon: 'ic:outline-webhook',
  294. alwaysShow: true
  295. },
  296. children: [
  297. {
  298. path: 'useWatermark',
  299. component: 'views/hooks/useWatermark',
  300. name: 'UseWatermark',
  301. meta: {
  302. title: 'useWatermark'
  303. }
  304. },
  305. {
  306. path: 'useCrudSchemas',
  307. component: 'views/hooks/useCrudSchemas',
  308. name: 'UseCrudSchemas',
  309. meta: {
  310. title: 'useCrudSchemas'
  311. }
  312. }
  313. ]
  314. },
  315. {
  316. path: '/level',
  317. component: '#',
  318. redirect: '/level/menu1/menu1-1/menu1-1-1',
  319. name: 'Level',
  320. meta: {
  321. title: 'router.level',
  322. icon: 'carbon:skill-level-advanced'
  323. },
  324. children: [
  325. {
  326. path: 'menu1',
  327. name: 'Menu1',
  328. component: '##',
  329. redirect: '/level/menu1/menu1-1/menu1-1-1',
  330. meta: {
  331. title: 'router.menu1'
  332. },
  333. children: [
  334. {
  335. path: 'menu1-1',
  336. name: 'Menu11',
  337. component: '##',
  338. redirect: '/level/menu1/menu1-1/menu1-1-1',
  339. meta: {
  340. title: 'router.menu11',
  341. alwaysShow: true
  342. },
  343. children: [
  344. {
  345. path: 'menu1-1-1',
  346. name: 'Menu111',
  347. component: 'views/Level/Menu111',
  348. meta: {
  349. title: 'router.menu111'
  350. }
  351. }
  352. ]
  353. },
  354. {
  355. path: 'menu1-2',
  356. name: 'Menu12',
  357. component: 'views/Level/Menu12',
  358. meta: {
  359. title: 'router.menu12'
  360. }
  361. }
  362. ]
  363. },
  364. {
  365. path: 'menu2',
  366. name: 'Menu2Demo',
  367. component: 'views/Level/Menu2',
  368. meta: {
  369. title: 'router.menu2'
  370. }
  371. }
  372. ]
  373. },
  374. {
  375. path: '/example',
  376. component: '#',
  377. redirect: '/example/example-dialog',
  378. name: 'Example',
  379. meta: {
  380. title: 'router.example',
  381. icon: 'ep:management',
  382. alwaysShow: true
  383. },
  384. children: [
  385. {
  386. path: 'example-dialog',
  387. component: 'views/Example/Dialog/ExampleDialog',
  388. name: 'ExampleDialog',
  389. meta: {
  390. title: 'router.exampleDialog'
  391. }
  392. },
  393. {
  394. path: 'example-page',
  395. component: 'views/Example/Page/ExamplePage',
  396. name: 'ExamplePage',
  397. meta: {
  398. title: 'router.examplePage'
  399. }
  400. },
  401. {
  402. path: 'example-add',
  403. component: 'views/Example/Page/ExampleAdd',
  404. name: 'ExampleAdd',
  405. meta: {
  406. title: 'router.exampleAdd',
  407. noTagsView: true,
  408. noCache: true,
  409. hidden: true,
  410. showMainRoute: true,
  411. activeMenu: '/example/example-page'
  412. }
  413. },
  414. {
  415. path: 'example-edit',
  416. component: 'views/Example/Page/ExampleEdit',
  417. name: 'ExampleEdit',
  418. meta: {
  419. title: 'router.exampleEdit',
  420. noTagsView: true,
  421. noCache: true,
  422. hidden: true,
  423. showMainRoute: true,
  424. activeMenu: '/example/example-page'
  425. }
  426. },
  427. {
  428. path: 'example-detail',
  429. component: 'views/Example/Page/ExampleDetail',
  430. name: 'ExampleDetail',
  431. meta: {
  432. title: 'router.exampleDetail',
  433. noTagsView: true,
  434. noCache: true,
  435. hidden: true,
  436. showMainRoute: true,
  437. activeMenu: '/example/example-page'
  438. }
  439. }
  440. ]
  441. },
  442. {
  443. path: '/error',
  444. component: '#',
  445. redirect: '/error/404',
  446. name: 'Error',
  447. meta: {
  448. title: 'router.errorPage',
  449. icon: 'ci:error',
  450. alwaysShow: true
  451. },
  452. children: [
  453. {
  454. path: '404-demo',
  455. component: 'views/Error/404',
  456. name: '404Demo',
  457. meta: {
  458. title: '404'
  459. }
  460. },
  461. {
  462. path: '403-demo',
  463. component: 'views/Error/403',
  464. name: '403Demo',
  465. meta: {
  466. title: '403'
  467. }
  468. },
  469. {
  470. path: '500-demo',
  471. component: 'views/Error/500',
  472. name: '500Demo',
  473. meta: {
  474. title: '500'
  475. }
  476. }
  477. ]
  478. }
  479. ]
  480. const testList: string[] = [
  481. '/dashboard',
  482. '/dashboard/analysis',
  483. '/dashboard/workplace',
  484. 'external-link',
  485. 'https://element-plus-admin-doc.cn/',
  486. '/guide',
  487. '/guide/index',
  488. '/components',
  489. '/components/form',
  490. '/components/form/default-form',
  491. '/components/form/use-form',
  492. '/components/form/ref-form',
  493. '/components/table',
  494. '/components/table/default-table',
  495. '/components/table/use-table',
  496. '/components/table/tree-table',
  497. '/components/table/table-image-preview',
  498. '/components/table/ref-table',
  499. '/components/editor-demo',
  500. '/components/editor-demo/editor',
  501. '/components/search',
  502. '/components/descriptions',
  503. '/components/image-viewer',
  504. '/components/dialog',
  505. '/components/icon',
  506. '/components/echart',
  507. '/components/count-to',
  508. '/components/qrcode',
  509. '/components/highlight',
  510. '/components/infotip',
  511. '/Components/InputPassword',
  512. '/Components/Sticky',
  513. '/hooks',
  514. '/hooks/useWatermark',
  515. '/hooks/useCrudSchemas',
  516. '/level',
  517. '/level/menu1',
  518. '/level/menu1/menu1-1',
  519. '/level/menu1/menu1-1/menu1-1-1',
  520. '/level/menu1/menu1-2',
  521. '/level/menu2',
  522. '/example',
  523. '/example/example-dialog',
  524. '/example/example-page',
  525. '/example/example-add',
  526. '/example/example-edit',
  527. '/example/example-detail',
  528. '/error',
  529. '/error/404-demo',
  530. '/error/403-demo',
  531. '/error/500-demo'
  532. ]
  533. export default [
  534. // 列表接口
  535. {
  536. url: '/role/list',
  537. method: 'get',
  538. timeout,
  539. response: ({ query }) => {
  540. const { roleName } = query
  541. return {
  542. data: {
  543. code: code,
  544. data: roleName === 'admin' ? adminList : testList
  545. }
  546. }
  547. }
  548. }
  549. ] as MockMethod[]