index.ts 12 KB

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