index.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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: '/guide',
  39. component: '#',
  40. name: 'Guide',
  41. meta: {},
  42. children: [
  43. {
  44. path: 'index',
  45. component: 'views/Guide/Guide',
  46. name: 'GuideDemo',
  47. meta: {
  48. title: 'router.guide',
  49. icon: 'cib:telegram-plane'
  50. }
  51. }
  52. ]
  53. },
  54. {
  55. path: '/components',
  56. component: '#',
  57. redirect: '/components/icon',
  58. name: 'ComponentsDemo',
  59. meta: {
  60. title: 'router.component',
  61. icon: 'bx:bxs-component',
  62. alwaysShow: true
  63. },
  64. children: [
  65. {
  66. path: 'form',
  67. component: '##',
  68. name: 'Form',
  69. meta: {
  70. title: 'router.form',
  71. alwaysShow: true
  72. },
  73. children: [
  74. {
  75. path: 'default-form',
  76. component: 'views/Components/Form/DefaultForm',
  77. name: 'DefaultForm',
  78. meta: {
  79. title: 'router.defaultForm'
  80. }
  81. },
  82. {
  83. path: 'use-form',
  84. component: 'views/Components/Form/UseFormDemo',
  85. name: 'UseForm',
  86. meta: {
  87. title: 'UseForm'
  88. }
  89. },
  90. {
  91. path: 'ref-form',
  92. component: 'views/Components/Form/RefForm',
  93. name: 'RefForm',
  94. meta: {
  95. title: 'RefForm'
  96. }
  97. }
  98. ]
  99. },
  100. {
  101. path: 'table',
  102. component: '##',
  103. name: 'TableDemo',
  104. meta: {
  105. title: 'router.table',
  106. alwaysShow: true
  107. },
  108. children: [
  109. {
  110. path: 'default-table',
  111. component: 'views/Components/Table/DefaultTable',
  112. name: 'DefaultTable',
  113. meta: {
  114. title: 'router.defaultTable'
  115. }
  116. },
  117. {
  118. path: 'use-table',
  119. component: 'views/Components/Table/UseTableDemo',
  120. name: 'UseTable',
  121. meta: {
  122. title: 'UseTable'
  123. }
  124. },
  125. {
  126. path: 'ref-table',
  127. component: 'views/Components/Table/RefTable',
  128. name: 'RefTable',
  129. meta: {
  130. title: 'RefTable'
  131. }
  132. }
  133. ]
  134. },
  135. {
  136. path: 'editor-demo',
  137. component: '##',
  138. name: 'EditorDemo',
  139. meta: {
  140. title: 'router.editor',
  141. alwaysShow: true
  142. },
  143. children: [
  144. {
  145. path: 'editor',
  146. component: 'views/Components/Editor/Editor',
  147. name: 'Editor',
  148. meta: {
  149. title: 'router.richText'
  150. }
  151. }
  152. ]
  153. },
  154. {
  155. path: 'search',
  156. component: 'views/Components/Search',
  157. name: 'Search',
  158. meta: {
  159. title: 'router.search'
  160. }
  161. },
  162. {
  163. path: 'descriptions',
  164. component: 'views/Components/Descriptions',
  165. name: 'Descriptions',
  166. meta: {
  167. title: 'router.descriptions'
  168. }
  169. },
  170. {
  171. path: 'image-viewer',
  172. component: 'views/Components/ImageViewer',
  173. name: 'ImageViewer',
  174. meta: {
  175. title: 'router.imageViewer'
  176. }
  177. },
  178. {
  179. path: 'dialog',
  180. component: 'views/Components/Dialog',
  181. name: 'Dialog',
  182. meta: {
  183. title: 'router.dialog'
  184. }
  185. },
  186. {
  187. path: 'icon',
  188. component: 'views/Components/Icon',
  189. name: 'Icon',
  190. meta: {
  191. title: 'router.icon'
  192. }
  193. },
  194. {
  195. path: 'echart',
  196. component: 'views/Components/Echart',
  197. name: 'Echart',
  198. meta: {
  199. title: 'router.echart'
  200. }
  201. },
  202. {
  203. path: 'count-to',
  204. component: 'views/Components/CountTo',
  205. name: 'CountTo',
  206. meta: {
  207. title: 'router.countTo'
  208. }
  209. },
  210. {
  211. path: 'watermark',
  212. component: 'views/Components/Watermark',
  213. name: 'Watermark',
  214. meta: {
  215. title: 'router.watermark'
  216. }
  217. },
  218. {
  219. path: 'qrcode',
  220. component: 'views/Components/Qrcode',
  221. name: 'Qrcode',
  222. meta: {
  223. title: 'router.qrcode'
  224. }
  225. },
  226. {
  227. path: 'highlight',
  228. component: 'views/Components/Highlight',
  229. name: 'Highlight',
  230. meta: {
  231. title: 'router.highlight'
  232. }
  233. },
  234. {
  235. path: 'infotip',
  236. component: 'views/Components/Infotip',
  237. name: 'Infotip',
  238. meta: {
  239. title: 'router.infotip'
  240. }
  241. }
  242. ]
  243. },
  244. {
  245. path: '/level',
  246. component: '#',
  247. redirect: '/level/menu1/menu1-1/menu1-1-1',
  248. name: 'Level',
  249. meta: {
  250. title: 'router.level',
  251. icon: 'carbon:skill-level-advanced'
  252. },
  253. children: [
  254. {
  255. path: 'menu1',
  256. name: 'Menu1',
  257. component: '##',
  258. redirect: '/level/menu1/menu1-1/menu1-1-1',
  259. meta: {
  260. title: 'router.menu1'
  261. },
  262. children: [
  263. {
  264. path: 'menu1-1',
  265. name: 'Menu11',
  266. component: '##',
  267. redirect: '/level/menu1/menu1-1/menu1-1-1',
  268. meta: {
  269. title: 'router.menu11',
  270. alwaysShow: true
  271. },
  272. children: [
  273. {
  274. path: 'menu1-1-1',
  275. name: 'Menu111',
  276. component: 'views/Level/Menu111',
  277. meta: {
  278. title: 'router.menu111'
  279. }
  280. }
  281. ]
  282. },
  283. {
  284. path: 'menu1-2',
  285. name: 'Menu12',
  286. component: 'views/Level/Menu12',
  287. meta: {
  288. title: 'router.menu12'
  289. }
  290. }
  291. ]
  292. },
  293. {
  294. path: 'menu2',
  295. name: 'Menu2Demo',
  296. component: 'views/Level/Menu2',
  297. meta: {
  298. title: 'router.menu2'
  299. }
  300. }
  301. ]
  302. },
  303. {
  304. path: '/example',
  305. component: '#',
  306. redirect: '/example/example-dialog',
  307. name: 'Example',
  308. meta: {
  309. title: 'router.example',
  310. icon: 'ep:management',
  311. alwaysShow: true
  312. },
  313. children: [
  314. {
  315. path: 'example-dialog',
  316. component: 'views/Example/Dialog/ExampleDialog',
  317. name: 'ExampleDialog',
  318. meta: {
  319. title: 'router.exampleDialog'
  320. }
  321. },
  322. {
  323. path: 'example-page',
  324. component: 'views/Example/Page/ExamplePage',
  325. name: 'ExamplePage',
  326. meta: {
  327. title: 'router.examplePage'
  328. }
  329. },
  330. {
  331. path: 'example-add',
  332. component: 'views/Example/Page/ExampleAdd',
  333. name: 'ExampleAdd',
  334. meta: {
  335. title: 'router.exampleAdd',
  336. noTagsView: true,
  337. noCache: true,
  338. hidden: true,
  339. showMainRoute: true,
  340. activeMenu: '/example/example-page'
  341. }
  342. },
  343. {
  344. path: 'example-edit',
  345. component: 'views/Example/Page/ExampleEdit',
  346. name: 'ExampleEdit',
  347. meta: {
  348. title: 'router.exampleEdit',
  349. noTagsView: true,
  350. noCache: true,
  351. hidden: true,
  352. showMainRoute: true,
  353. activeMenu: '/example/example-page'
  354. }
  355. },
  356. {
  357. path: 'example-detail',
  358. component: 'views/Example/Page/ExampleDetail',
  359. name: 'ExampleDetail',
  360. meta: {
  361. title: 'router.exampleDetail',
  362. noTagsView: true,
  363. noCache: true,
  364. hidden: true,
  365. showMainRoute: true,
  366. activeMenu: '/example/example-page'
  367. }
  368. }
  369. ]
  370. },
  371. {
  372. path: '/error',
  373. component: '#',
  374. redirect: '/error/404',
  375. name: 'Error',
  376. meta: {
  377. title: 'router.errorPage',
  378. icon: 'ci:error',
  379. alwaysShow: true
  380. },
  381. children: [
  382. {
  383. path: '404-demo',
  384. component: 'views/Error/404',
  385. name: '404Demo',
  386. meta: {
  387. title: '404'
  388. }
  389. },
  390. {
  391. path: '403-demo',
  392. component: 'views/Error/403',
  393. name: '403Demo',
  394. meta: {
  395. title: '403'
  396. }
  397. },
  398. {
  399. path: '500-demo',
  400. component: 'views/Error/500',
  401. name: '500Demo',
  402. meta: {
  403. title: '500'
  404. }
  405. }
  406. ]
  407. }
  408. ]
  409. const testList: string[] = [
  410. '/dashboard',
  411. '/dashboard/analysis',
  412. '/dashboard/workplace',
  413. '/guide',
  414. '/guide/index',
  415. '/components',
  416. '/components/form',
  417. '/components/form/default-form',
  418. '/components/form/use-form',
  419. '/components/form/ref-form',
  420. '/components/table',
  421. '/components/table/default-table',
  422. '/components/table/use-table',
  423. '/components/table/ref-table',
  424. '/components/editor-demo',
  425. '/components/editor-demo/editor',
  426. '/components/search',
  427. '/components/descriptions',
  428. '/components/image-viewer',
  429. '/components/dialog',
  430. '/components/icon',
  431. '/components/echart',
  432. '/components/count-to',
  433. '/components/watermark',
  434. '/components/qrcode',
  435. '/components/highlight',
  436. '/components/infotip',
  437. '/level',
  438. '/level/menu1',
  439. '/level/menu1/menu1-1',
  440. '/level/menu1/menu1-1/menu1-1-1',
  441. '/level/menu1/menu1-2',
  442. '/level/menu2',
  443. '/example',
  444. '/example/example-dialog',
  445. '/example/example-page',
  446. '/example/example-add',
  447. '/example/example-edit',
  448. '/example/example-detail',
  449. '/error',
  450. '/error/404-demo',
  451. '/error/403-demo',
  452. '/error/500-demo'
  453. ]
  454. export default [
  455. // 列表接口
  456. {
  457. url: '/role/list',
  458. method: 'get',
  459. timeout,
  460. response: ({ query }) => {
  461. const { roleName } = query
  462. return {
  463. code: result_code,
  464. data: {
  465. list: roleName === 'admin' ? adminList : testList
  466. }
  467. }
  468. }
  469. }
  470. ] as MockMethod[]