From 339db4be8ed5600dd073d18b9044baae970b6db9 Mon Sep 17 00:00:00 2001 From: hxr <1490493387@qq.com> Date: Tue, 25 Jun 2024 00:20:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=87=8D=E6=9E=84mock=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/dept.mock.ts | 6 + mock/dict.mock.ts | 197 +++++++-------------- mock/menu.mock.ts | 434 ++++++++++++++++++++++++++++++---------------- 3 files changed, 349 insertions(+), 288 deletions(-) diff --git a/mock/dept.mock.ts b/mock/dept.mock.ts index eac3aa83..e9b6d1bb 100644 --- a/mock/dept.mock.ts +++ b/mock/dept.mock.ts @@ -36,6 +36,7 @@ export default defineMock([ id: 1, parentId: 0, name: "有来技术", + code: "YOULAI", sort: 1, status: 1, children: [ @@ -43,6 +44,7 @@ export default defineMock([ id: 2, parentId: 1, name: "研发部门", + code: "RD001", sort: 1, status: 1, children: [], @@ -53,6 +55,7 @@ export default defineMock([ id: 3, parentId: 1, name: "测试部门", + code: "QA001", sort: 1, status: 1, children: [], @@ -126,6 +129,7 @@ const deptMap: Record = { 1: { id: 1, name: "有来技术", + code: "YOULAI", parentId: 0, status: 1, sort: 1, @@ -133,6 +137,7 @@ const deptMap: Record = { 2: { id: 2, name: "研发部门", + code: "RD001", parentId: 1, status: 1, sort: 1, @@ -140,6 +145,7 @@ const deptMap: Record = { 3: { id: 3, name: "测试部门", + code: "QA001", parentId: 1, status: 1, sort: 1, diff --git a/mock/dict.mock.ts b/mock/dict.mock.ts index ebaef2ec..63b4b2c1 100644 --- a/mock/dict.mock.ts +++ b/mock/dict.mock.ts @@ -5,11 +5,11 @@ export default defineMock([ url: "dict/:code/options", method: ["GET"], body: ({ params }) => { - const typeCode = params.code; + const code = params.code; let list = null; - if (typeCode == "gender") { + if (code == "gender") { list = [ { value: "1", @@ -21,7 +21,7 @@ export default defineMock([ }, { value: "0", - label: "未知", + label: "保密", }, ]; } @@ -35,7 +35,7 @@ export default defineMock([ }, { - url: "dict/types/page", + url: "dict/page", method: ["GET"], body: { code: "00000", @@ -46,104 +46,37 @@ export default defineMock([ name: "性别", code: "gender", status: 1, - }, - { - id: 2, - name: "状态", - code: "status", - status: 1, + dictItems: [ + { + id: 1, + name: "男", + value: "1", + sort: 1, + status: 1, + }, + { + id: 2, + name: "女", + value: "2", + sort: 2, + status: 1, + }, + { + id: 3, + name: "保密", + value: "0", + sort: 3, + status: 1, + }, + ], }, ], - total: 2, + total: 1, }, msg: "一切ok", }, }, - { - url: "dict/page", - method: ["GET"], - body: { - code: "00000", - data: { - list: [ - { - id: 1, - name: "男", - value: "1", - status: 1, - }, - { - id: 2, - name: "女", - value: "2", - status: 1, - }, - { - id: 3, - name: "未知", - value: "0", - status: 1, - }, - ], - total: 3, - }, - msg: "一切ok", - }, - }, - - // 新增字典 - { - url: "dict/types", - method: ["POST"], - body({ body }) { - return { - code: "00000", - data: null, - msg: "新增字典" + body.name + "成功", - }; - }, - }, - - // 获取字典表单数据 - { - url: "dict/types/:id/form", - method: ["GET"], - body: ({ params }) => { - return { - code: "00000", - data: dictTypeMap[params.id], - msg: "一切ok", - }; - }, - }, - - // 修改字典 - { - url: "dict/types/:id", - method: ["PUT"], - body({ body }) { - return { - code: "00000", - data: null, - msg: "修改字典" + body.name + "成功", - }; - }, - }, - - // 删除字典 - { - url: "dict/types/:id", - method: ["DELETE"], - body({ params }) { - return { - code: "00000", - data: null, - msg: "删除字典" + params.id + "成功", - }; - }, - }, - // 新增字典 { url: "dict", @@ -197,51 +130,39 @@ export default defineMock([ }, ]); -// 字典映射表数据 -const dictTypeMap: Record = { - 1: { - id: 1, - name: "性别", - code: "gender", - status: 1, - remark: null, - }, - 2: { - id: 2, - name: "状态", - code: "status", - status: 1, - remark: null, - }, -}; - // 字典映射表数据 const dictMap: Record = { 1: { - id: 1, - typeCode: "gender", - name: "男", - value: "1", - status: 1, - sort: 1, - remark: null, - }, - 2: { - id: 2, - typeCode: "gender", - name: "女", - value: "2", - status: 1, - sort: 2, - remark: null, - }, - 3: { - id: 3, - typeCode: "gender", - name: "未知", - value: "0", - status: 1, - sort: 1, - remark: null, + code: "00000", + data: { + id: 1, + name: "性别", + code: "gender", + status: 1, + dictItems: [ + { + id: 1, + name: "男", + value: "1", + sort: 1, + status: 1, + }, + { + id: 2, + name: "女", + value: "2", + sort: 2, + status: 1, + }, + { + id: 3, + name: "未知", + value: "0", + sort: 3, + status: 1, + }, + ], + }, + msg: "一切ok", }, }; diff --git a/mock/menu.mock.ts b/mock/menu.mock.ts index 59c3b918..993bc63d 100644 --- a/mock/menu.mock.ts +++ b/mock/menu.mock.ts @@ -454,7 +454,8 @@ export default defineMock([ parentId: 0, name: "系统管理", type: "CATALOG", - path: "/system", + routeName: "", + routePath: "/system", component: "Layout", sort: 1, visible: 1, @@ -467,7 +468,8 @@ export default defineMock([ parentId: 1, name: "用户管理", type: "MENU", - path: "user", + routeName: "User", + routePath: "user", component: "system/user/index", sort: 1, visible: 1, @@ -475,12 +477,28 @@ export default defineMock([ redirect: null, perm: null, children: [ + { + id: 105, + parentId: 2, + name: "用户查询", + type: "BUTTON", + routeName: null, + routePath: "", + component: null, + sort: 0, + visible: 1, + icon: "", + redirect: null, + perm: "sys:user:query", + children: [], + }, { id: 31, parentId: 2, name: "用户新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 1, visible: 1, @@ -494,7 +512,8 @@ export default defineMock([ parentId: 2, name: "用户编辑", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 2, visible: 1, @@ -508,7 +527,8 @@ export default defineMock([ parentId: 2, name: "用户删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 3, visible: 1, @@ -522,7 +542,8 @@ export default defineMock([ parentId: 2, name: "重置密码", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 4, visible: 1, @@ -531,6 +552,36 @@ export default defineMock([ perm: "sys:user:password:reset", children: [], }, + { + id: 106, + parentId: 2, + name: "用户导入", + type: "BUTTON", + routeName: null, + routePath: "", + component: null, + sort: 5, + visible: 1, + icon: "", + redirect: null, + perm: "sys:user:import", + children: [], + }, + { + id: 107, + parentId: 2, + name: "用户导出", + type: "BUTTON", + routeName: null, + routePath: "", + component: null, + sort: 6, + visible: 1, + icon: "", + redirect: null, + perm: "sys:user:export", + children: [], + }, ], }, { @@ -538,7 +589,8 @@ export default defineMock([ parentId: 1, name: "角色管理", type: "MENU", - path: "role", + routeName: "Role", + routePath: "role", component: "system/role/index", sort: 2, visible: 1, @@ -551,7 +603,8 @@ export default defineMock([ parentId: 3, name: "角色新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 1, visible: 1, @@ -565,7 +618,8 @@ export default defineMock([ parentId: 3, name: "角色编辑", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 2, visible: 1, @@ -579,7 +633,8 @@ export default defineMock([ parentId: 3, name: "角色删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 3, visible: 1, @@ -595,7 +650,8 @@ export default defineMock([ parentId: 1, name: "菜单管理", type: "MENU", - path: "menu", + routeName: "Menu", + routePath: "menu", component: "system/menu/index", sort: 3, visible: 1, @@ -608,7 +664,8 @@ export default defineMock([ parentId: 4, name: "菜单新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 1, visible: 1, @@ -617,26 +674,13 @@ export default defineMock([ perm: "sys:menu:add", children: [], }, - { - id: 74, - parentId: 4, - name: "菜单编辑", - type: "BUTTON", - path: "", - component: null, - sort: 3, - visible: 1, - icon: "", - redirect: null, - perm: "sys:menu:edit", - children: [], - }, { id: 75, parentId: 4, name: "菜单删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 3, visible: 1, @@ -645,6 +689,21 @@ export default defineMock([ perm: "sys:menu:delete", children: [], }, + { + id: 74, + parentId: 4, + name: "菜单编辑", + type: "BUTTON", + routeName: null, + routePath: "", + component: null, + sort: 3, + visible: 1, + icon: "", + redirect: null, + perm: "sys:menu:edit", + children: [], + }, ], }, { @@ -652,7 +711,8 @@ export default defineMock([ parentId: 1, name: "部门管理", type: "MENU", - path: "dept", + routeName: "Dept", + routePath: "dept", component: "system/dept/index", sort: 4, visible: 1, @@ -665,7 +725,8 @@ export default defineMock([ parentId: 5, name: "部门新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 1, visible: 1, @@ -679,7 +740,8 @@ export default defineMock([ parentId: 5, name: "部门编辑", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 2, visible: 1, @@ -693,7 +755,8 @@ export default defineMock([ parentId: 5, name: "部门删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 3, visible: 1, @@ -709,7 +772,8 @@ export default defineMock([ parentId: 1, name: "字典管理", type: "MENU", - path: "dict", + routeName: "Dict", + routePath: "dict", component: "system/dict/index", sort: 5, visible: 1, @@ -720,9 +784,10 @@ export default defineMock([ { id: 79, parentId: 6, - name: "字典新增", + name: "字典类型新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 1, visible: 1, @@ -734,9 +799,10 @@ export default defineMock([ { id: 81, parentId: 6, - name: "字典编辑", + name: "字典类型编辑", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 2, visible: 1, @@ -748,9 +814,10 @@ export default defineMock([ { id: 84, parentId: 6, - name: "字典删除", + name: "字典类型删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 3, visible: 1, @@ -764,7 +831,8 @@ export default defineMock([ parentId: 6, name: "字典数据新增", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 4, visible: 1, @@ -778,7 +846,8 @@ export default defineMock([ parentId: 6, name: "字典数据编辑", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 5, visible: 1, @@ -792,7 +861,8 @@ export default defineMock([ parentId: 6, name: "字典数据删除", type: "BUTTON", - path: "", + routeName: null, + routePath: "", component: null, sort: 6, visible: 1, @@ -810,7 +880,8 @@ export default defineMock([ parentId: 0, name: "接口文档", type: "CATALOG", - path: "/api", + routeName: null, + routePath: "/api", component: "Layout", sort: 7, visible: 1, @@ -823,7 +894,8 @@ export default defineMock([ parentId: 40, name: "Apifox", type: "MENU", - path: "apifox", + routeName: null, + routePath: "apifox", component: "demo/api/apifox", sort: 1, visible: 1, @@ -832,34 +904,6 @@ export default defineMock([ perm: null, children: [], }, - { - id: 103, - parentId: 40, - name: "Swagger", - type: "MENU", - path: "swagger", - component: "demo/api/swagger", - sort: 2, - visible: 0, - icon: "api", - redirect: "", - perm: null, - children: [], - }, - { - id: 104, - parentId: 40, - name: "Knife4j", - type: "MENU", - path: "knife4j", - component: "demo/api/knife4j", - sort: 3, - visible: 0, - icon: "api", - redirect: "", - perm: null, - children: [], - }, ], }, { @@ -867,12 +911,13 @@ export default defineMock([ parentId: 0, name: "平台文档", type: "CATALOG", - path: "/doc", + routeName: null, + routePath: "/doc", component: "Layout", sort: 8, visible: 1, icon: "document", - redirect: null, + redirect: "https://juejin.cn/post/7228990409909108793", perm: null, children: [ { @@ -880,7 +925,8 @@ export default defineMock([ parentId: 26, name: "平台文档(内嵌)", type: "EXTLINK", - path: "internal-doc", + routeName: null, + routePath: "internal-doc", component: "demo/internal-doc", sort: 1, visible: 1, @@ -894,7 +940,8 @@ export default defineMock([ parentId: 26, name: "平台文档(外链)", type: "EXTLINK", - path: "https://juejin.cn/post/7228990409909108793", + routeName: null, + routePath: "https://juejin.cn/post/7228990409909108793", component: "", sort: 2, visible: 1, @@ -910,12 +957,13 @@ export default defineMock([ parentId: 0, name: "多级菜单", type: "CATALOG", - path: "/multi-level", + routeName: null, + routePath: "/multi-level", component: "Layout", sort: 9, visible: 1, icon: "cascader", - redirect: "/multi-level/multi-level1", + redirect: "", perm: null, children: [ { @@ -923,12 +971,13 @@ export default defineMock([ parentId: 20, name: "菜单一级", type: "MENU", - path: "multi-level1", + routeName: null, + routePath: "multi-level1", component: "demo/multi-level/level1", sort: 1, visible: 1, icon: "", - redirect: "/multi-level/multi-level2", + redirect: "", perm: null, children: [ { @@ -936,12 +985,13 @@ export default defineMock([ parentId: 21, name: "菜单二级", type: "MENU", - path: "multi-level2", + routeName: null, + routePath: "multi-level2", component: "demo/multi-level/children/level2", sort: 1, visible: 1, icon: "", - redirect: "/multi-level/multi-level2/multi-level3-1", + redirect: null, perm: null, children: [ { @@ -949,7 +999,8 @@ export default defineMock([ parentId: 22, name: "菜单三级-1", type: "MENU", - path: "multi-level3-1", + routeName: null, + routePath: "multi-level3-1", component: "demo/multi-level/children/children/level3-1", sort: 1, visible: 1, @@ -963,7 +1014,8 @@ export default defineMock([ parentId: 22, name: "菜单三级-2", type: "MENU", - path: "multi-level3-2", + routeName: null, + routePath: "multi-level3-2", component: "demo/multi-level/children/children/level3-2", sort: 2, visible: 1, @@ -983,7 +1035,8 @@ export default defineMock([ parentId: 0, name: "组件封装", type: "CATALOG", - path: "/component", + routeName: null, + routePath: "/component", component: "Layout", sort: 10, visible: 1, @@ -991,14 +1044,45 @@ export default defineMock([ redirect: "", perm: null, children: [ + { + id: 108, + parentId: 36, + name: "增删改查", + type: "MENU", + routeName: null, + routePath: "curd", + component: "demo/curd/index", + sort: 0, + visible: 1, + icon: "", + redirect: "", + perm: null, + children: [], + }, + { + id: 109, + parentId: 36, + name: "列表选择器", + type: "MENU", + routeName: null, + routePath: "table-select", + component: "demo/table-select/index", + sort: 1, + visible: 1, + icon: "", + redirect: "", + perm: null, + children: [], + }, { id: 37, parentId: 36, name: "富文本编辑器", type: "MENU", - path: "wang-editor", + routeName: null, + routePath: "wang-editor", component: "demo/wang-editor", - sort: 1, + sort: 2, visible: 1, icon: "", redirect: "", @@ -1010,22 +1094,9 @@ export default defineMock([ parentId: 36, name: "图片上传", type: "MENU", - path: "upload", + routeName: null, + routePath: "upload", component: "demo/upload", - sort: 2, - visible: 1, - icon: "", - redirect: "", - perm: null, - children: [], - }, - { - id: 39, - parentId: 36, - name: "图标选择器", - type: "MENU", - path: "icon-selector", - component: "demo/icon-selector", sort: 3, visible: 1, icon: "", @@ -1038,7 +1109,8 @@ export default defineMock([ parentId: 36, name: "字典组件", type: "MENU", - path: "dict-demo", + routeName: null, + routePath: "dict-demo", component: "demo/dict", sort: 4, visible: 1, @@ -1048,30 +1120,63 @@ export default defineMock([ children: [], }, { - id: 93, + id: 39, parentId: 36, - name: "签名", + name: "图标选择器", type: "MENU", - path: "signature", - component: "demo/signature", - sort: 6, + routeName: null, + routePath: "icon-selector", + component: "demo/icon-selector", + sort: 4, visible: 1, icon: "", redirect: "", perm: null, children: [], }, + ], + }, + { + id: 110, + parentId: 0, + name: "路由参数", + type: "CATALOG", + routeName: null, + routePath: "/route-param", + component: "Layout", + sort: 11, + visible: 1, + icon: "el-icon-ElementPlus", + redirect: null, + perm: null, + children: [ { - id: 94, - parentId: 36, - name: "表格", + id: 111, + parentId: 110, + name: "参数(type=1)", type: "MENU", - path: "table", - component: "demo/table", - sort: 7, + routeName: null, + routePath: "route-param-type1", + component: "demo/route-param", + sort: 1, visible: 1, - icon: "", - redirect: "", + icon: "el-icon-Star", + redirect: null, + perm: null, + children: [], + }, + { + id: 112, + parentId: 110, + name: "参数(type=2)", + type: "MENU", + routeName: null, + routePath: "route-param-type2", + component: "demo/route-param", + sort: 2, + visible: 1, + icon: "el-icon-StarFilled", + redirect: null, perm: null, children: [], }, @@ -1082,9 +1187,10 @@ export default defineMock([ parentId: 0, name: "功能演示", type: "CATALOG", - path: "/function", + routeName: null, + routePath: "/function", component: "Layout", - sort: 11, + sort: 12, visible: 1, icon: "menu", redirect: "", @@ -1095,11 +1201,12 @@ export default defineMock([ parentId: 89, name: "Icons", type: "MENU", - path: "icon-demo", + routeName: null, + routePath: "icon-demo", component: "demo/icons", sort: 2, visible: 1, - icon: "el-icon-edit", + icon: "el-icon-Notification", redirect: "", perm: null, children: [], @@ -1109,7 +1216,8 @@ export default defineMock([ parentId: 89, name: "Websocket", type: "MENU", - path: "/function/websocket", + routeName: null, + routePath: "/function/websocket", component: "demo/websocket", sort: 3, visible: 1, @@ -1123,7 +1231,8 @@ export default defineMock([ parentId: 89, name: "敬请期待...", type: "CATALOG", - path: "other", + routeName: null, + routePath: "other/:id", component: "demo/other", sort: 4, visible: 1, @@ -1153,6 +1262,10 @@ export default defineMock([ value: 2, label: "用户管理", children: [ + { + value: 105, + label: "用户查询", + }, { value: 31, label: "用户新增", @@ -1169,6 +1282,14 @@ export default defineMock([ value: 88, label: "重置密码", }, + { + value: 106, + label: "用户导入", + }, + { + value: 107, + label: "用户导出", + }, ], }, { @@ -1197,14 +1318,14 @@ export default defineMock([ value: 73, label: "菜单新增", }, - { - value: 74, - label: "菜单编辑", - }, { value: 75, label: "菜单删除", }, + { + value: 74, + label: "菜单编辑", + }, ], }, { @@ -1231,15 +1352,15 @@ export default defineMock([ children: [ { value: 79, - label: "字典新增", + label: "字典类型新增", }, { value: 81, - label: "字典编辑", + label: "字典类型编辑", }, { value: 84, - label: "字典删除", + label: "字典类型删除", }, { value: 85, @@ -1265,14 +1386,6 @@ export default defineMock([ value: 41, label: "Apifox", }, - { - value: 103, - label: "Swagger", - }, - { - value: 104, - label: "Knife4j", - }, ], }, { @@ -1319,6 +1432,14 @@ export default defineMock([ value: 36, label: "组件封装", children: [ + { + value: 108, + label: "增删改查", + }, + { + value: 109, + label: "列表选择器", + }, { value: 37, label: "富文本编辑器", @@ -1327,21 +1448,27 @@ export default defineMock([ value: 38, label: "图片上传", }, - { - value: 39, - label: "图标选择器", - }, { value: 95, label: "字典组件", }, { - value: 93, - label: "签名", + value: 39, + label: "图标选择器", + }, + ], + }, + { + value: 110, + label: "路由参数", + children: [ + { + value: 111, + label: "参数(type=1)", }, { - value: 94, - label: "表格", + value: 112, + label: "参数(type=2)", }, ], }, @@ -1428,7 +1555,8 @@ const menuMap: Record = { parentId: 0, name: "系统管理", type: "CATALOG", - path: "/system", + routeName: "", + routePath: "/system", component: "Layout", perm: null, visible: 1, @@ -1437,13 +1565,15 @@ const menuMap: Record = { redirect: "/system/user", keepAlive: null, alwaysShow: null, + params: null, }, 2: { id: 2, parentId: 1, name: "用户管理", type: "MENU", - path: "user", + routeName: "User", + routePath: "user", component: "system/user/index", perm: null, visible: 1, @@ -1458,7 +1588,8 @@ const menuMap: Record = { parentId: 1, name: "角色管理", type: "MENU", - path: "role", + routeName: "Role", + routePath: "role", component: "system/role/index", perm: null, visible: 1, @@ -1473,7 +1604,8 @@ const menuMap: Record = { parentId: 1, name: "菜单管理", type: "MENU", - path: "menu", + routeName: "Menu", + routePath: "menu", component: "system/menu/index", perm: null, visible: 1, @@ -1488,7 +1620,8 @@ const menuMap: Record = { parentId: 1, name: "部门管理", type: "MENU", - path: "dept", + routeName: "Dept", + routePath: "dept", component: "system/dept/index", perm: null, visible: 1, @@ -1503,7 +1636,8 @@ const menuMap: Record = { parentId: 1, name: "字典管理", type: "MENU", - path: "dict", + routeName: "Dict", + routePath: "dict", component: "system/dict/index", perm: null, visible: 1,