zmdms-webui 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ var MainMenu = function (props) {
|
|
|
9
9
|
var userMenus = props.userMenus, onMouseEnter = props.onMouseEnter, onMainLinkClick = props.onMainLinkClick, addTab = props.addTab;
|
|
10
10
|
// 创建主菜单标签
|
|
11
11
|
var getLabel = useCallback(function (menuItem) {
|
|
12
|
+
// 根据type的类型做出不同的处理 这里只是留个入口 暂时没有特别的处理
|
|
12
13
|
if (menuItem.type === "index") {
|
|
13
14
|
return (jsx(Link, __assign({ to: menuItem.path, onClick: function () {
|
|
14
15
|
addTab &&
|
|
@@ -32,16 +33,40 @@ var MainMenu = function (props) {
|
|
|
32
33
|
} }, { children: menuItem.name })));
|
|
33
34
|
}, [addTab]);
|
|
34
35
|
var items = useMemo(function () {
|
|
36
|
+
var _a;
|
|
35
37
|
if (!Array.isArray(userMenus)) {
|
|
36
38
|
console.error("用户主菜单没有按预期传入对应数据!");
|
|
37
39
|
return [];
|
|
38
40
|
}
|
|
41
|
+
// 如果菜单列表只有一项的话 那么认为当前只有一个系统
|
|
42
|
+
// 不需要展示多个系统
|
|
43
|
+
if (userMenus.length === 1) {
|
|
44
|
+
return (((_a = userMenus[0]) === null || _a === void 0 ? void 0 : _a.children) || []).map(function (userMenu) {
|
|
45
|
+
return {
|
|
46
|
+
label: getLabel(userMenu),
|
|
47
|
+
title: userMenu.name,
|
|
48
|
+
key: userMenu.id,
|
|
49
|
+
icon: userMenu.source ? (jsx(IconFont, { type: userMenu.source, style: { fontSize: "18px" } })) : null,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
39
53
|
return userMenus.map(function (userMenu) {
|
|
54
|
+
var children = userMenu.children;
|
|
40
55
|
return {
|
|
41
|
-
label:
|
|
56
|
+
label: jsx("span", __assign({ title: userMenu.name }, { children: userMenu.name })),
|
|
42
57
|
title: userMenu.name,
|
|
43
58
|
key: userMenu.id,
|
|
44
59
|
icon: userMenu.source ? (jsx(IconFont, { type: userMenu.source, style: { fontSize: "18px" } })) : null,
|
|
60
|
+
children: children
|
|
61
|
+
? children.map(function (item) {
|
|
62
|
+
return {
|
|
63
|
+
label: getLabel(item),
|
|
64
|
+
title: item.name,
|
|
65
|
+
key: item.id,
|
|
66
|
+
icon: item.source ? (jsx(IconFont, { type: item.source, style: { fontSize: "18px" } })) : null,
|
|
67
|
+
};
|
|
68
|
+
})
|
|
69
|
+
: null,
|
|
45
70
|
};
|
|
46
71
|
});
|
|
47
72
|
}, [userMenus, getLabel]);
|