index.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. },
  260. {
  261. path: '/hooks',
  262. component: '#',
  263. redirect: '/hooks/useWatermark',
  264. name: 'Hooks',
  265. meta: {
  266. title: 'hooks',
  267. icon: 'ic:outline-webhook',
  268. alwaysShow: true
  269. },
  270. children: [
  271. {
  272. path: 'useWatermark',
  273. component: 'views/hooks/useWatermark',
  274. name: 'UseWatermark',
  275. meta: {
  276. title: 'useWatermark'
  277. }
  278. }
  279. ]
  280. },
  281. {
  282. path: '/level',
  283. component: '#',
  284. redirect: '/level/menu1/menu1-1/menu1-1-1',
  285. name: 'Level',
  286. meta: {
  287. title: 'router.level',
  288. icon: 'carbon:skill-level-advanced'
  289. },
  290. children: [
  291. {
  292. path: 'menu1',
  293. name: 'Menu1',
  294. component: '##',
  295. redirect: '/level/menu1/menu1-1/menu1-1-1',
  296. meta: {
  297. title: 'router.menu1'
  298. },
  299. children: [
  300. {
  301. path: 'menu1-1',
  302. name: 'Menu11',
  303. component: '##',
  304. redirect: '/level/menu1/menu1-1/menu1-1-1',
  305. meta: {
  306. title: 'router.menu11',
  307. alwaysShow: true
  308. },
  309. children: [
  310. {
  311. path: 'menu1-1-1',
  312. name: 'Menu111',
  313. component: 'views/Level/Menu111',
  314. meta: {
  315. title: 'router.menu111'
  316. }
  317. }
  318. ]
  319. },
  320. {
  321. path: 'menu1-2',
  322. name: 'Menu12',
  323. component: 'views/Level/Menu12',
  324. meta: {
  325. title: 'router.menu12'
  326. }
  327. }
  328. ]
  329. },
  330. {
  331. path: 'menu2',
  332. name: 'Menu2Demo',
  333. component: 'views/Level/Menu2',
  334. meta: {
  335. title: 'router.menu2'
  336. }
  337. }
  338. ]
  339. },
  340. {
  341. path: '/example',
  342. component: '#',
  343. redirect: '/example/example-dialog',
  344. name: 'Example',
  345. meta: {
  346. title: 'router.example',
  347. icon: 'ep:management',
  348. alwaysShow: true
  349. },
  350. children: [
  351. {
  352. path: 'example-dialog',
  353. component: 'views/Example/Dialog/ExampleDialog',
  354. name: 'ExampleDialog',
  355. meta: {
  356. title: 'router.exampleDialog'
  357. }
  358. },
  359. {
  360. path: 'example-page',
  361. component: 'views/Example/Page/ExamplePage',
  362. name: 'ExamplePage',
  363. meta: {
  364. title: 'router.examplePage'
  365. }
  366. },
  367. {
  368. path: 'example-add',
  369. component: 'views/Example/Page/ExampleAdd',
  370. name: 'ExampleAdd',
  371. meta: {
  372. title: 'router.exampleAdd',
  373. noTagsView: true,
  374. noCache: true,
  375. hidden: true,
  376. showMainRoute: true,
  377. activeMenu: '/example/example-page'
  378. }
  379. },
  380. {
  381. path: 'example-edit',
  382. component: 'views/Example/Page/ExampleEdit',
  383. name: 'ExampleEdit',
  384. meta: {
  385. title: 'router.exampleEdit',
  386. noTagsView: true,
  387. noCache: true,
  388. hidden: true,
  389. showMainRoute: true,
  390. activeMenu: '/example/example-page'
  391. }
  392. },
  393. {
  394. path: 'example-detail',
  395. component: 'views/Example/Page/ExampleDetail',
  396. name: 'ExampleDetail',
  397. meta: {
  398. title: 'router.exampleDetail',
  399. noTagsView: true,
  400. noCache: true,
  401. hidden: true,
  402. showMainRoute: true,
  403. activeMenu: '/example/example-page'
  404. }
  405. }
  406. ]
  407. },
  408. {
  409. path: '/error',
  410. component: '#',
  411. redirect: '/error/404',
  412. name: 'Error',
  413. meta: {
  414. title: 'router.errorPage',
  415. icon: 'ci:error',
  416. alwaysShow: true
  417. },
  418. children: [
  419. {
  420. path: '404-demo',
  421. component: 'views/Error/404',
  422. name: '404Demo',
  423. meta: {
  424. title: '404'
  425. }
  426. },
  427. {
  428. path: '403-demo',
  429. component: 'views/Error/403',
  430. name: '403Demo',
  431. meta: {
  432. title: '403'
  433. }
  434. },
  435. {
  436. path: '500-demo',
  437. component: 'views/Error/500',
  438. name: '500Demo',
  439. meta: {
  440. title: '500'
  441. }
  442. }
  443. ]
  444. }
  445. ]
  446. const testList: string[] = [
  447. '/dashboard',
  448. '/dashboard/analysis',
  449. '/dashboard/workplace',
  450. 'external-link',
  451. 'https://element-plus-admin-doc.cn/',
  452. '/guide',
  453. '/guide/index',
  454. '/components',
  455. '/components/form',
  456. '/components/form/default-form',
  457. '/components/form/use-form',
  458. '/components/form/ref-form',
  459. '/components/table',
  460. '/components/table/default-table',
  461. '/components/table/use-table',
  462. '/components/table/ref-table',
  463. '/components/editor-demo',
  464. '/components/editor-demo/editor',
  465. '/components/search',
  466. '/components/descriptions',
  467. '/components/image-viewer',
  468. '/components/dialog',
  469. '/components/icon',
  470. '/components/echart',
  471. '/components/count-to',
  472. '/components/qrcode',
  473. '/components/highlight',
  474. '/components/infotip',
  475. '/Components/InputPassword',
  476. '/hooks',
  477. '/hooks/useWatermark',
  478. '/level',
  479. '/level/menu1',
  480. '/level/menu1/menu1-1',
  481. '/level/menu1/menu1-1/menu1-1-1',
  482. '/level/menu1/menu1-2',
  483. '/level/menu2',
  484. '/example',
  485. '/example/example-dialog',
  486. '/example/example-page',
  487. '/example/example-add',
  488. '/example/example-edit',
  489. '/example/example-detail',
  490. '/error',
  491. '/error/404-demo',
  492. '/error/403-demo',
  493. '/error/500-demo'
  494. ]
  495. export default [
  496. // 列表接口
  497. {
  498. url: '/role/list',
  499. method: 'get',
  500. timeout,
  501. response: ({ query }) => {
  502. const { roleName } = query
  503. return {
  504. code: result_code,
  505. data: {
  506. list: roleName === 'admin' ? adminList : testList
  507. }
  508. }
  509. }
  510. }
  511. ] as MockMethod[]