index.ts 12 KB

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