index.ts 11 KB

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