menu.mock.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. import { defineMock } from "./base";
  2. export default defineMock([
  3. {
  4. url: "menus/routes",
  5. method: ["GET"],
  6. body: {
  7. code: "00000",
  8. data: [
  9. {
  10. path: "/system",
  11. component: "Layout",
  12. redirect: "/system/user",
  13. name: "/system",
  14. meta: {
  15. title: "系统管理",
  16. icon: "system",
  17. hidden: false,
  18. alwaysShow: false,
  19. params: null,
  20. },
  21. children: [
  22. {
  23. path: "user",
  24. component: "system/user/index",
  25. name: "User",
  26. meta: {
  27. title: "用户管理",
  28. icon: "el-icon-User",
  29. hidden: false,
  30. keepAlive: true,
  31. alwaysShow: false,
  32. params: null,
  33. },
  34. },
  35. {
  36. path: "role",
  37. component: "system/role/index",
  38. name: "Role",
  39. meta: {
  40. title: "角色管理",
  41. icon: "role",
  42. hidden: false,
  43. keepAlive: true,
  44. alwaysShow: false,
  45. params: null,
  46. },
  47. },
  48. {
  49. path: "menu",
  50. component: "system/menu/index",
  51. name: "Menu",
  52. meta: {
  53. title: "菜单管理",
  54. icon: "menu",
  55. hidden: false,
  56. keepAlive: true,
  57. alwaysShow: false,
  58. params: null,
  59. },
  60. },
  61. {
  62. path: "dept",
  63. component: "system/dept/index",
  64. name: "Dept",
  65. meta: {
  66. title: "部门管理",
  67. icon: "tree",
  68. hidden: false,
  69. keepAlive: true,
  70. alwaysShow: false,
  71. params: null,
  72. },
  73. },
  74. {
  75. path: "dict",
  76. component: "system/dict/index",
  77. name: "Dict",
  78. meta: {
  79. title: "字典管理",
  80. icon: "dict",
  81. hidden: false,
  82. keepAlive: true,
  83. alwaysShow: false,
  84. params: null,
  85. },
  86. },
  87. ],
  88. },
  89. {
  90. path: "/api",
  91. component: "Layout",
  92. name: "/api",
  93. meta: {
  94. title: "接口文档",
  95. icon: "api",
  96. hidden: false,
  97. alwaysShow: true,
  98. params: null,
  99. },
  100. children: [
  101. {
  102. path: "apifox",
  103. component: "demo/api/apifox",
  104. name: "Apifox",
  105. meta: {
  106. title: "Apifox",
  107. icon: "api",
  108. hidden: false,
  109. keepAlive: true,
  110. alwaysShow: false,
  111. params: null,
  112. },
  113. },
  114. ],
  115. },
  116. {
  117. path: "/doc",
  118. component: "Layout",
  119. redirect: "https://juejin.cn/post/7228990409909108793",
  120. name: "/doc",
  121. meta: {
  122. title: "平台文档",
  123. icon: "document",
  124. hidden: false,
  125. alwaysShow: false,
  126. params: null,
  127. },
  128. children: [
  129. {
  130. path: "internal-doc",
  131. component: "demo/internal-doc",
  132. name: "InternalDoc",
  133. meta: {
  134. title: "平台文档(内嵌)",
  135. icon: "document",
  136. hidden: false,
  137. alwaysShow: false,
  138. params: null,
  139. },
  140. },
  141. {
  142. path: "https://juejin.cn/post/7228990409909108793",
  143. name: "Https://juejin.cn/post/7228990409909108793",
  144. meta: {
  145. title: "平台文档(外链)",
  146. icon: "el-icon-Link",
  147. hidden: false,
  148. alwaysShow: false,
  149. params: null,
  150. },
  151. },
  152. ],
  153. },
  154. {
  155. path: "/multi-level",
  156. component: "Layout",
  157. name: "/multiLevel",
  158. meta: {
  159. title: "多级菜单",
  160. icon: "cascader",
  161. hidden: false,
  162. alwaysShow: true,
  163. params: null,
  164. },
  165. children: [
  166. {
  167. path: "multi-level1",
  168. component: "demo/multi-level/level1",
  169. name: "MultiLevel1",
  170. meta: {
  171. title: "菜单一级",
  172. icon: "",
  173. hidden: false,
  174. alwaysShow: true,
  175. params: null,
  176. },
  177. children: [
  178. {
  179. path: "multi-level2",
  180. component: "demo/multi-level/children/level2",
  181. name: "MultiLevel2",
  182. meta: {
  183. title: "菜单二级",
  184. icon: "",
  185. hidden: false,
  186. alwaysShow: false,
  187. params: null,
  188. },
  189. children: [
  190. {
  191. path: "multi-level3-1",
  192. component: "demo/multi-level/children/children/level3-1",
  193. name: "MultiLevel31",
  194. meta: {
  195. title: "菜单三级-1",
  196. icon: "",
  197. hidden: false,
  198. keepAlive: true,
  199. alwaysShow: false,
  200. params: null,
  201. },
  202. },
  203. {
  204. path: "multi-level3-2",
  205. component: "demo/multi-level/children/children/level3-2",
  206. name: "MultiLevel32",
  207. meta: {
  208. title: "菜单三级-2",
  209. icon: "",
  210. hidden: false,
  211. keepAlive: true,
  212. alwaysShow: false,
  213. params: null,
  214. },
  215. },
  216. ],
  217. },
  218. ],
  219. },
  220. ],
  221. },
  222. {
  223. path: "/component",
  224. component: "Layout",
  225. name: "/component",
  226. meta: {
  227. title: "组件封装",
  228. icon: "menu",
  229. hidden: false,
  230. alwaysShow: false,
  231. params: null,
  232. },
  233. children: [
  234. {
  235. path: "curd",
  236. component: "demo/curd/index",
  237. name: "Curd",
  238. meta: {
  239. title: "增删改查",
  240. icon: "",
  241. hidden: false,
  242. keepAlive: true,
  243. alwaysShow: false,
  244. params: null,
  245. },
  246. },
  247. {
  248. path: "table-select",
  249. component: "demo/table-select/index",
  250. name: "TableSelect",
  251. meta: {
  252. title: "列表选择器",
  253. icon: "",
  254. hidden: false,
  255. keepAlive: true,
  256. alwaysShow: false,
  257. params: null,
  258. },
  259. },
  260. {
  261. path: "wang-editor",
  262. component: "demo/wang-editor",
  263. name: "WangEditor",
  264. meta: {
  265. title: "富文本编辑器",
  266. icon: "",
  267. hidden: false,
  268. keepAlive: true,
  269. alwaysShow: false,
  270. params: null,
  271. },
  272. },
  273. {
  274. path: "upload",
  275. component: "demo/upload",
  276. name: "Upload",
  277. meta: {
  278. title: "图片上传",
  279. icon: "",
  280. hidden: false,
  281. keepAlive: true,
  282. alwaysShow: false,
  283. params: null,
  284. },
  285. },
  286. {
  287. path: "icon-selector",
  288. component: "demo/icon-selector",
  289. name: "IconSelector",
  290. meta: {
  291. title: "图标选择器",
  292. icon: "",
  293. hidden: false,
  294. keepAlive: true,
  295. alwaysShow: false,
  296. params: null,
  297. },
  298. },
  299. {
  300. path: "dict-demo",
  301. component: "demo/dict",
  302. name: "DictDemo",
  303. meta: {
  304. title: "字典组件",
  305. icon: "",
  306. hidden: false,
  307. keepAlive: true,
  308. alwaysShow: false,
  309. params: null,
  310. },
  311. },
  312. ],
  313. },
  314. {
  315. path: "/route-param",
  316. component: "Layout",
  317. name: "/routeParam",
  318. meta: {
  319. title: "路由参数",
  320. icon: "el-icon-ElementPlus",
  321. hidden: false,
  322. alwaysShow: true,
  323. params: null,
  324. },
  325. children: [
  326. {
  327. path: "route-param-type1",
  328. component: "demo/route-param",
  329. name: "RouteParamType1",
  330. meta: {
  331. title: "参数(type=1)",
  332. icon: "el-icon-Star",
  333. hidden: false,
  334. keepAlive: true,
  335. alwaysShow: false,
  336. params: {
  337. type: "1",
  338. },
  339. },
  340. },
  341. {
  342. path: "route-param-type2",
  343. component: "demo/route-param",
  344. name: "RouteParamType2",
  345. meta: {
  346. title: "参数(type=2)",
  347. icon: "el-icon-StarFilled",
  348. hidden: false,
  349. keepAlive: true,
  350. alwaysShow: false,
  351. params: {
  352. type: "2",
  353. },
  354. },
  355. },
  356. ],
  357. },
  358. {
  359. path: "/function",
  360. component: "Layout",
  361. name: "/function",
  362. meta: {
  363. title: "功能演示",
  364. icon: "menu",
  365. hidden: false,
  366. alwaysShow: false,
  367. params: null,
  368. },
  369. children: [
  370. {
  371. path: "icon-demo",
  372. component: "demo/icons",
  373. name: "IconDemo",
  374. meta: {
  375. title: "Icons",
  376. icon: "el-icon-Notification",
  377. hidden: false,
  378. keepAlive: true,
  379. alwaysShow: false,
  380. params: null,
  381. },
  382. },
  383. {
  384. path: "/function/websocket",
  385. component: "demo/websocket",
  386. name: "/function/websocket",
  387. meta: {
  388. title: "Websocket",
  389. icon: "",
  390. hidden: false,
  391. keepAlive: true,
  392. alwaysShow: false,
  393. params: null,
  394. },
  395. },
  396. {
  397. path: "other/:id",
  398. component: "demo/other",
  399. name: "Other/:id",
  400. meta: {
  401. title: "敬请期待...",
  402. icon: "",
  403. hidden: false,
  404. alwaysShow: false,
  405. params: null,
  406. },
  407. },
  408. ],
  409. },
  410. ],
  411. msg: "一切ok",
  412. },
  413. },
  414. // 新增菜单
  415. {
  416. url: "menus",
  417. method: ["POST"],
  418. body({ body }) {
  419. return {
  420. code: "00000",
  421. data: null,
  422. msg: "新增菜单" + body.name + "成功",
  423. };
  424. },
  425. },
  426. // 获取菜单表单数据
  427. {
  428. url: "menus/:id/form",
  429. method: ["GET"],
  430. body: ({ params }) => {
  431. return {
  432. code: "00000",
  433. data: menuMap[params.id],
  434. msg: "一切ok",
  435. };
  436. },
  437. },
  438. // 修改菜单
  439. {
  440. url: "menus/:id",
  441. method: ["PUT"],
  442. body({ body }) {
  443. return {
  444. code: "00000",
  445. data: null,
  446. msg: "修改菜单" + body.name + "成功",
  447. };
  448. },
  449. },
  450. // 删除菜单
  451. {
  452. url: "menus/:id",
  453. method: ["DELETE"],
  454. body({ params }) {
  455. return {
  456. code: "00000",
  457. data: null,
  458. msg: "删除菜单" + params.id + "成功",
  459. };
  460. },
  461. },
  462. ]);
  463. // 菜单映射表数据
  464. const menuMap: Record<string, any> = {
  465. 1: {
  466. id: 1,
  467. parentId: 0,
  468. name: "系统管理",
  469. type: "CATALOG",
  470. routeName: "",
  471. routePath: "/system",
  472. component: "Layout",
  473. perm: null,
  474. visible: 1,
  475. sort: 1,
  476. icon: "system",
  477. redirect: "/system/user",
  478. keepAlive: null,
  479. alwaysShow: null,
  480. params: null,
  481. },
  482. 2: {
  483. id: 2,
  484. parentId: 1,
  485. name: "用户管理",
  486. type: "MENU",
  487. routeName: "User",
  488. routePath: "user",
  489. component: "system/user/index",
  490. perm: null,
  491. visible: 1,
  492. sort: 1,
  493. icon: "user",
  494. redirect: null,
  495. keepAlive: 1,
  496. alwaysShow: null,
  497. },
  498. 3: {
  499. id: 3,
  500. parentId: 1,
  501. name: "角色管理",
  502. type: "MENU",
  503. routeName: "Role",
  504. routePath: "role",
  505. component: "system/role/index",
  506. perm: null,
  507. visible: 1,
  508. sort: 2,
  509. icon: "role",
  510. redirect: null,
  511. keepAlive: 1,
  512. alwaysShow: null,
  513. },
  514. 4: {
  515. id: 4,
  516. parentId: 1,
  517. name: "菜单管理",
  518. type: "MENU",
  519. routeName: "Menu",
  520. routePath: "menu",
  521. component: "system/menu/index",
  522. perm: null,
  523. visible: 1,
  524. sort: 3,
  525. icon: "menu",
  526. redirect: null,
  527. keepAlive: 1,
  528. alwaysShow: null,
  529. },
  530. 5: {
  531. id: 5,
  532. parentId: 1,
  533. name: "部门管理",
  534. type: "MENU",
  535. routeName: "Dept",
  536. routePath: "dept",
  537. component: "system/dept/index",
  538. perm: null,
  539. visible: 1,
  540. sort: 4,
  541. icon: "tree",
  542. redirect: null,
  543. keepAlive: 1,
  544. alwaysShow: null,
  545. },
  546. 6: {
  547. id: 6,
  548. parentId: 1,
  549. name: "字典管理",
  550. type: "MENU",
  551. routeName: "Dict",
  552. routePath: "dict",
  553. component: "system/dict/index",
  554. perm: null,
  555. visible: 1,
  556. sort: 5,
  557. icon: "dict",
  558. redirect: null,
  559. keepAlive: 1,
  560. alwaysShow: null,
  561. },
  562. };