fix(mock): menu form returns fallback data to avoid edit form crash

This commit is contained in:
Ray.Hao
2026-04-09 19:01:42 +08:00
parent 97cb62d6a7
commit 3d64ceb761

View File

@@ -542,7 +542,7 @@ export default defineMock([
id: 1,
parentId: 0,
name: "系统管理",
type: "CATALOG",
type: "C",
routeName: "",
routePath: "/system",
component: "Layout",
@@ -556,7 +556,7 @@ export default defineMock([
id: 2,
parentId: 1,
name: "用户管理",
type: "MENU",
type: "M",
routeName: "User",
routePath: "user",
component: "system/user/index",
@@ -570,7 +570,7 @@ export default defineMock([
id: 105,
parentId: 2,
name: "用户查询",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -585,7 +585,7 @@ export default defineMock([
id: 31,
parentId: 2,
name: "用户新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -600,7 +600,7 @@ export default defineMock([
id: 32,
parentId: 2,
name: "用户编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -615,7 +615,7 @@ export default defineMock([
id: 33,
parentId: 2,
name: "用户删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -630,7 +630,7 @@ export default defineMock([
id: 88,
parentId: 2,
name: "重置密码",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -645,7 +645,7 @@ export default defineMock([
id: 106,
parentId: 2,
name: "用户导入",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -660,7 +660,7 @@ export default defineMock([
id: 107,
parentId: 2,
name: "用户导出",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -677,7 +677,7 @@ export default defineMock([
id: 3,
parentId: 1,
name: "角色管理",
type: "MENU",
type: "M",
routeName: "Role",
routePath: "role",
component: "system/role/index",
@@ -691,7 +691,7 @@ export default defineMock([
id: 70,
parentId: 3,
name: "角色新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -706,7 +706,7 @@ export default defineMock([
id: 71,
parentId: 3,
name: "角色编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -721,7 +721,7 @@ export default defineMock([
id: 72,
parentId: 3,
name: "角色删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -738,7 +738,7 @@ export default defineMock([
id: 4,
parentId: 1,
name: "菜单管理",
type: "MENU",
type: "M",
routeName: "Menu",
routePath: "menu",
component: "system/menu/index",
@@ -752,7 +752,7 @@ export default defineMock([
id: 73,
parentId: 4,
name: "菜单新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -767,7 +767,7 @@ export default defineMock([
id: 74,
parentId: 4,
name: "菜单编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -782,7 +782,7 @@ export default defineMock([
id: 75,
parentId: 4,
name: "菜单删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -799,7 +799,7 @@ export default defineMock([
id: 5,
parentId: 1,
name: "部门管理",
type: "MENU",
type: "M",
routeName: "Dept",
routePath: "dept",
component: "system/dept/index",
@@ -813,7 +813,7 @@ export default defineMock([
id: 76,
parentId: 5,
name: "部门新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -828,7 +828,7 @@ export default defineMock([
id: 77,
parentId: 5,
name: "部门编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -843,7 +843,7 @@ export default defineMock([
id: 78,
parentId: 5,
name: "部门删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -860,7 +860,7 @@ export default defineMock([
id: 6,
parentId: 1,
name: "字典管理",
type: "MENU",
type: "M",
routeName: "Dict",
routePath: "dict",
component: "system/dict/index",
@@ -874,7 +874,7 @@ export default defineMock([
id: 79,
parentId: 6,
name: "字典新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -889,7 +889,7 @@ export default defineMock([
id: 81,
parentId: 6,
name: "字典编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -904,7 +904,7 @@ export default defineMock([
id: 84,
parentId: 6,
name: "字典删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -921,7 +921,7 @@ export default defineMock([
id: 135,
parentId: 1,
name: "字典项",
type: "MENU",
type: "M",
routeName: "DictData",
routePath: "dict-item",
component: "system/dict/dict-item",
@@ -935,7 +935,7 @@ export default defineMock([
id: 136,
parentId: 135,
name: "字典项新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -950,7 +950,7 @@ export default defineMock([
id: 137,
parentId: 135,
name: "字典项编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -965,7 +965,7 @@ export default defineMock([
id: 138,
parentId: 135,
name: "字典项删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -982,7 +982,7 @@ export default defineMock([
id: 117,
parentId: 1,
name: "系统日志",
type: "MENU",
type: "M",
routeName: "Log",
routePath: "log",
component: "system/log/index",
@@ -997,7 +997,7 @@ export default defineMock([
id: 120,
parentId: 1,
name: "系统配置",
type: "MENU",
type: "M",
routeName: "Config",
routePath: "config",
component: "system/config/index",
@@ -1011,7 +1011,7 @@ export default defineMock([
id: 121,
parentId: 120,
name: "查询系统配置",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1026,7 +1026,7 @@ export default defineMock([
id: 122,
parentId: 120,
name: "新增系统配置",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1041,7 +1041,7 @@ export default defineMock([
id: 123,
parentId: 120,
name: "修改系统配置",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1056,7 +1056,7 @@ export default defineMock([
id: 124,
parentId: 120,
name: "删除系统配置",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1071,7 +1071,7 @@ export default defineMock([
id: 125,
parentId: 120,
name: "刷新系统配置",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1088,7 +1088,7 @@ export default defineMock([
id: 126,
parentId: 1,
name: "通知公告",
type: "MENU",
type: "M",
routeName: "Notice",
routePath: "notice",
component: "system/notice/index",
@@ -1102,7 +1102,7 @@ export default defineMock([
id: 127,
parentId: 126,
name: "查询",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1117,7 +1117,7 @@ export default defineMock([
id: 128,
parentId: 126,
name: "新增",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1132,7 +1132,7 @@ export default defineMock([
id: 129,
parentId: 126,
name: "编辑",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1147,7 +1147,7 @@ export default defineMock([
id: 130,
parentId: 126,
name: "删除",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1162,7 +1162,7 @@ export default defineMock([
id: 133,
parentId: 126,
name: "发布",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1177,7 +1177,7 @@ export default defineMock([
id: 134,
parentId: 126,
name: "撤回",
type: "BUTTON",
type: "F",
routeName: null,
routePath: "",
component: null,
@@ -1196,7 +1196,7 @@ export default defineMock([
id: 118,
parentId: 0,
name: "系统工具",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/codegen",
component: "Layout",
@@ -1210,7 +1210,7 @@ export default defineMock([
id: 119,
parentId: 118,
name: "代码生成",
type: "MENU",
type: "M",
routeName: "Codegen",
routePath: "codegen",
component: "codegen/index",
@@ -1227,7 +1227,7 @@ export default defineMock([
id: 40,
parentId: 0,
name: "接口文档",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/api",
component: "Layout",
@@ -1241,7 +1241,7 @@ export default defineMock([
id: 41,
parentId: 40,
name: "Apifox",
type: "MENU",
type: "M",
routeName: null,
routePath: "apifox",
component: "demo/api/apifox",
@@ -1258,7 +1258,7 @@ export default defineMock([
id: 26,
parentId: 0,
name: "平台文档",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/doc",
component: "Layout",
@@ -1304,7 +1304,7 @@ export default defineMock([
id: 20,
parentId: 0,
name: "多级菜单",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/multi-level",
component: "Layout",
@@ -1318,7 +1318,7 @@ export default defineMock([
id: 21,
parentId: 20,
name: "菜单一级",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "multi-level1",
component: "Layout",
@@ -1332,7 +1332,7 @@ export default defineMock([
id: 22,
parentId: 21,
name: "菜单二级",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "multi-level2",
component: "Layout",
@@ -1346,7 +1346,7 @@ export default defineMock([
id: 23,
parentId: 22,
name: "菜单三级-1",
type: "MENU",
type: "M",
routeName: null,
routePath: "multi-level3-1",
component: "demo/multi-level/children/children/level3-1",
@@ -1361,7 +1361,7 @@ export default defineMock([
id: 24,
parentId: 22,
name: "菜单三级-2",
type: "MENU",
type: "M",
routeName: null,
routePath: "multi-level3-2",
component: "demo/multi-level/children/children/level3-2",
@@ -1382,7 +1382,7 @@ export default defineMock([
id: 36,
parentId: 0,
name: "组件封装",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/component",
component: "Layout",
@@ -1396,7 +1396,7 @@ export default defineMock([
id: 108,
parentId: 36,
name: "增删改查",
type: "MENU",
type: "M",
routeName: null,
routePath: "curd",
component: "demo/curd/index",
@@ -1411,7 +1411,7 @@ export default defineMock([
id: 109,
parentId: 36,
name: "列表选择器",
type: "MENU",
type: "M",
routeName: null,
routePath: "table-select",
component: "demo/table-select/index",
@@ -1426,7 +1426,7 @@ export default defineMock([
id: 37,
parentId: 36,
name: "富文本编辑器",
type: "MENU",
type: "M",
routeName: null,
routePath: "wang-editor",
component: "demo/wang-editor",
@@ -1441,7 +1441,7 @@ export default defineMock([
id: 38,
parentId: 36,
name: "图片上传",
type: "MENU",
type: "M",
routeName: null,
routePath: "upload",
component: "demo/upload",
@@ -1456,7 +1456,7 @@ export default defineMock([
id: 95,
parentId: 36,
name: "字典组件",
type: "MENU",
type: "M",
routeName: null,
routePath: "dict-demo",
component: "demo/dict",
@@ -1471,7 +1471,7 @@ export default defineMock([
id: 39,
parentId: 36,
name: "图标选择器",
type: "MENU",
type: "M",
routeName: null,
routePath: "icon-selector",
component: "demo/icon-selector",
@@ -1488,7 +1488,7 @@ export default defineMock([
id: 110,
parentId: 0,
name: "路由参数",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/route-param",
component: "Layout",
@@ -1502,7 +1502,7 @@ export default defineMock([
id: 111,
parentId: 110,
name: "参数(type=1)",
type: "MENU",
type: "M",
routeName: null,
routePath: "route-param-type1",
component: "demo/route-param",
@@ -1517,7 +1517,7 @@ export default defineMock([
id: 112,
parentId: 110,
name: "参数(type=2)",
type: "MENU",
type: "M",
routeName: null,
routePath: "route-param-type2",
component: "demo/route-param",
@@ -1534,7 +1534,7 @@ export default defineMock([
id: 7,
parentId: 0,
name: "功能演示",
type: "CATALOG",
type: "C",
routeName: null,
routePath: "/function",
component: "Layout",
@@ -1548,7 +1548,7 @@ export default defineMock([
id: 801,
parentId: 7,
name: "Icons",
type: "MENU",
type: "M",
routeName: null,
routePath: "icon-demo",
component: "demo/icons",
@@ -1563,7 +1563,7 @@ export default defineMock([
id: 802,
parentId: 7,
name: "字典实时同步",
type: "MENU",
type: "M",
routeName: null,
routePath: "dict-sync",
component: "demo/dict-sync",
@@ -1578,7 +1578,7 @@ export default defineMock([
id: 803,
parentId: 7,
name: "VxeTable",
type: "MENU",
type: "M",
routeName: null,
routePath: "vxe-table",
component: "demo/vxe-table/index",
@@ -1593,7 +1593,7 @@ export default defineMock([
id: 804,
parentId: 7,
name: "CURD单文件",
type: "MENU",
type: "M",
routeName: null,
routePath: "curd-single",
component: "demo/curd-single",
@@ -1978,9 +1978,29 @@ export default defineMock([
url: "menus/:id/form",
method: ["GET"],
body: ({ params }) => {
const menu = menuMap[params.id];
return {
code: "00000",
data: menuMap[params.id],
data:
menu ??
({
id: params.id,
parentId: "0",
name: "",
type: "M",
routeName: "",
routePath: "",
component: "",
icon: "",
redirect: "",
perm: null,
visible: 1,
scope: 2,
sort: 1,
alwaysShow: 0,
keepAlive: 1,
params: [],
} as any),
msg: "一切ok",
};
},
@@ -2019,7 +2039,7 @@ const menuMap: Record<string, any> = {
id: 1,
parentId: 0,
name: "系统管理",
type: "CATALOG",
type: "C",
routeName: "",
routePath: "/system",
component: "Layout",
@@ -2036,7 +2056,7 @@ const menuMap: Record<string, any> = {
id: 2,
parentId: 1,
name: "用户管理",
type: "MENU",
type: "M",
routeName: "User",
routePath: "user",
component: "system/user/index",
@@ -2052,7 +2072,7 @@ const menuMap: Record<string, any> = {
id: 3,
parentId: 1,
name: "角色管理",
type: "MENU",
type: "M",
routeName: "Role",
routePath: "role",
component: "system/role/index",
@@ -2068,7 +2088,7 @@ const menuMap: Record<string, any> = {
id: 4,
parentId: 1,
name: "菜单管理",
type: "MENU",
type: "M",
routeName: "Menu",
routePath: "menu",
component: "system/menu/index",
@@ -2084,7 +2104,7 @@ const menuMap: Record<string, any> = {
id: 5,
parentId: 1,
name: "部门管理",
type: "MENU",
type: "M",
routeName: "Dept",
routePath: "dept",
component: "system/dept/index",
@@ -2100,7 +2120,7 @@ const menuMap: Record<string, any> = {
id: 6,
parentId: 1,
name: "字典管理",
type: "MENU",
type: "M",
routeName: "Dict",
routePath: "dict",
component: "system/dict/index",
@@ -2116,7 +2136,7 @@ const menuMap: Record<string, any> = {
id: 7,
parentId: 0,
name: "功能演示",
type: "CATALOG",
type: "C",
routeName: "",
routePath: "/function",
component: "Layout",
@@ -2133,7 +2153,7 @@ const menuMap: Record<string, any> = {
id: 801,
parentId: 7,
name: "Icons",
type: "MENU",
type: "M",
routeName: "IconDemo",
routePath: "icon-demo",
component: "demo/icons",
@@ -2150,7 +2170,7 @@ const menuMap: Record<string, any> = {
id: 802,
parentId: 7,
name: "字典实时同步",
type: "MENU",
type: "M",
routeName: "DictSync",
routePath: "dict-sync",
component: "demo/dict-sync",
@@ -2167,7 +2187,7 @@ const menuMap: Record<string, any> = {
id: 803,
parentId: 7,
name: "VxeTable",
type: "MENU",
type: "M",
routeName: "VxeTable",
routePath: "vxe-table",
component: "demo/vxe-table/index",
@@ -2184,7 +2204,7 @@ const menuMap: Record<string, any> = {
id: 804,
parentId: 7,
name: "CURD单文件",
type: "MENU",
type: "M",
routeName: "CurdSingle",
routePath: "curd-single",
component: "demo/curd-single",