zmdms-webui 3.4.5 → 3.4.6

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.
@@ -65,6 +65,8 @@ interface ILayoutSiderProps {
65
65
  maxDeepIndex?: number;
66
66
  /** 是否持久化二级菜单固定状态,刷新后保持 */
67
67
  persist?: boolean;
68
+ /** 自定义渲染主菜单图标,传入则替代默认 Icon 组件 */
69
+ renderIcon?: (menuItem: any) => React__default.ReactNode;
68
70
  }
69
71
  declare const _default: React__default.NamedExoticComponent<ILayoutSiderProps>;
70
72
 
@@ -16,7 +16,7 @@ var AppLayoutSider = function (props) {
16
16
  // 118 宽度改成 134宽度
17
17
  _b = props.siderWidth,
18
18
  // 118 宽度改成 134宽度
19
- siderWidth = _b === void 0 ? 134 : _b, _c = props.subMenuWidth, subMenuWidth = _c === void 0 ? 162 : _c, addTab = props.addTab, siderBg = props.siderBg, logo = props.logo, logoStyle = props.logoStyle, subMenuLogo = props.subMenuLogo, _d = props.isShowSearchInput, isShowSearchInput = _d === void 0 ? true : _d, apps = props.apps, activeTab = props.activeTab, userMenus = props.userMenus, userSubMenus = props.userSubMenus, mergeSystemIds = props.mergeSystemIds, postMergeSystemIds = props.postMergeSystemIds, drawerTitle = props.drawerTitle, selectMainMenu = props.selectMainMenu, menuJoinRule = props.menuJoinRule, renderItem = props.renderItem, defaultVisible = props.defaultVisible, defaultFixed = props.defaultFixed, openOnlyHasSubmenus = props.openOnlyHasSubmenus, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine, subMenuItemLine = props.subMenuItemLine, bottomContainer = props.bottomContainer, onLogoClick = props.onLogoClick, filterMenuHandle = props.filterMenuHandle, logoTitle = props.logoTitle, maxDeepIndex = props.maxDeepIndex, persist = props.persist;
19
+ siderWidth = _b === void 0 ? 134 : _b, _c = props.subMenuWidth, subMenuWidth = _c === void 0 ? 162 : _c, addTab = props.addTab, siderBg = props.siderBg, logo = props.logo, logoStyle = props.logoStyle, subMenuLogo = props.subMenuLogo, _d = props.isShowSearchInput, isShowSearchInput = _d === void 0 ? true : _d, apps = props.apps, activeTab = props.activeTab, userMenus = props.userMenus, userSubMenus = props.userSubMenus, mergeSystemIds = props.mergeSystemIds, postMergeSystemIds = props.postMergeSystemIds, drawerTitle = props.drawerTitle, selectMainMenu = props.selectMainMenu, menuJoinRule = props.menuJoinRule, renderItem = props.renderItem, defaultVisible = props.defaultVisible, defaultFixed = props.defaultFixed, openOnlyHasSubmenus = props.openOnlyHasSubmenus, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine, subMenuItemLine = props.subMenuItemLine, bottomContainer = props.bottomContainer, onLogoClick = props.onLogoClick, filterMenuHandle = props.filterMenuHandle, logoTitle = props.logoTitle, maxDeepIndex = props.maxDeepIndex, persist = props.persist, renderIcon = props.renderIcon;
20
20
  // 当前选中的主菜单item
21
21
  var _e = useState([]), mainMenuSelectedKeys = _e[0], setMainMenuSelectedKeys = _e[1];
22
22
  // 内部二级菜单管理
@@ -75,7 +75,7 @@ var AppLayoutSider = function (props) {
75
75
  getNewPath: getNewPath,
76
76
  renderItem: renderItem,
77
77
  filterMenuHandle: filterMenuHandle,
78
- } }, { children: jsx(Menu, { width: siderWidth, subMenuWidth: subMenuWidth, layoutSiderRef: layoutSiderRef, addTab: addTab, logo: logo, logoStyle: logoStyle, subMenuLogo: subMenuLogo, getPrefixByAppId: getPrefixByAppId, defaultVisible: defaultVisible, openOnlyHasSubmenus: openOnlyHasSubmenus, defaultFixed: defaultFixed, isShowSearchInput: isShowSearchInput, hideSubMenuBg: hideSubMenuBg, menuItemLine: menuItemLine, subMenuItemLine: subMenuItemLine, bottomContainer: bottomContainer, onLogoClick: onLogoClick, logoTitle: logoTitle, maxDeepIndex: maxDeepIndex, persist: persist }) })) })));
78
+ } }, { children: jsx(Menu, { width: siderWidth, subMenuWidth: subMenuWidth, layoutSiderRef: layoutSiderRef, addTab: addTab, logo: logo, logoStyle: logoStyle, subMenuLogo: subMenuLogo, getPrefixByAppId: getPrefixByAppId, defaultVisible: defaultVisible, openOnlyHasSubmenus: openOnlyHasSubmenus, defaultFixed: defaultFixed, isShowSearchInput: isShowSearchInput, hideSubMenuBg: hideSubMenuBg, menuItemLine: menuItemLine, subMenuItemLine: subMenuItemLine, bottomContainer: bottomContainer, onLogoClick: onLogoClick, logoTitle: logoTitle, maxDeepIndex: maxDeepIndex, persist: persist, renderIcon: renderIcon }) })) })));
79
79
  };
80
80
  AppLayoutSider.displayName = "ZTXK_WEBUI_AppLayoutSider";
81
81
  var AppLayoutSider$1 = memo(AppLayoutSider);
@@ -10,7 +10,7 @@ import { Menu } from 'antd';
10
10
 
11
11
  // 是否隐藏菜单 isHiddenMenu 1 是 2 否
12
12
  var MainMenu = function (props) {
13
- var onMouseEnter = props.onMouseEnter, addTab = props.addTab, getPrefixByAppId = props.getPrefixByAppId, subMenu = props.subMenu, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine;
13
+ var onMouseEnter = props.onMouseEnter, addTab = props.addTab, getPrefixByAppId = props.getPrefixByAppId, subMenu = props.subMenu, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine, renderIcon = props.renderIcon;
14
14
  var _a = useContext(LayoutMenuContext), mainMenuSelectedKeys = _a.mainMenuSelectedKeys, setMainMenuSelectedKeys = _a.setMainMenuSelectedKeys, userMenus = _a.userMenus, apps = _a.apps, mergeSystemIds = _a.mergeSystemIds, postMergeSystemIds = _a.postMergeSystemIds, getNewPath = _a.getNewPath, renderItem = _a.renderItem, filterMenuHandle = _a.filterMenuHandle;
15
15
  // 获取主菜单展开的内容
16
16
  var _b = useMainMenuOpenKeys(userMenus, mainMenuSelectedKeys, { apps: apps, mergeSystemIds: mergeSystemIds, postMergeSystemIds: postMergeSystemIds }), mainMenuOpenKeys = _b.mainMenuOpenKeys, onMainMenuOpenChange = _b.onMainMenuOpenChange;
@@ -56,6 +56,18 @@ var MainMenu = function (props) {
56
56
  });
57
57
  } }, { children: menuItem.name })));
58
58
  }, [addTab, getPrefixByAppId, getNewPath, renderItem]);
59
+ // 获取菜单图标,支持外部传入 renderIcon 替代默认 Icon 组件
60
+ var getIcon = useCallback(function (menuItem, placeholder) {
61
+ if (placeholder === void 0) { placeholder = false; }
62
+ if (menuItem.source) {
63
+ return renderIcon ? (renderIcon(menuItem)) : (jsx(IconFont, { type: menuItem.source, style: { fontSize: "18px" } }));
64
+ }
65
+ return placeholder ? (jsx("span", { style: {
66
+ fontSize: "18px",
67
+ display: "inline-block",
68
+ width: "1em",
69
+ } })) : null;
70
+ }, [renderIcon]);
59
71
  var items = useMemo(function () {
60
72
  var _a;
61
73
  if (!Array.isArray(userMenus)) {
@@ -75,7 +87,7 @@ var MainMenu = function (props) {
75
87
  label: getLabel(userMenu),
76
88
  title: (_a = userMenu.name) === null || _a === void 0 ? void 0 : _a.trim(),
77
89
  key: userMenu.id,
78
- icon: userMenu.source ? (jsx(IconFont, { type: userMenu.source, style: { fontSize: "18px" } })) : null,
90
+ icon: getIcon(userMenu),
79
91
  };
80
92
  });
81
93
  }
@@ -93,7 +105,7 @@ var MainMenu = function (props) {
93
105
  label: jsx("span", __assign({ title: (_a = userMenu.name) === null || _a === void 0 ? void 0 : _a.trim() }, { children: userMenu.name })),
94
106
  title: (_b = userMenu.name) === null || _b === void 0 ? void 0 : _b.trim(),
95
107
  key: userMenu.id,
96
- icon: userMenu.source ? (jsx(IconFont, { type: userMenu.source, style: { fontSize: "18px" } })) : null,
108
+ icon: getIcon(userMenu),
97
109
  children: children
98
110
  ? filterMenus.map(function (item) {
99
111
  var _a;
@@ -101,17 +113,13 @@ var MainMenu = function (props) {
101
113
  label: getLabel(item),
102
114
  title: (_a = item.name) === null || _a === void 0 ? void 0 : _a.trim(),
103
115
  key: item.id,
104
- icon: item.source ? (jsx(IconFont, { type: item.source, style: { fontSize: "18px" } })) : (jsx("span", { style: {
105
- fontSize: "18px",
106
- display: "inline-block",
107
- width: "1em",
108
- } })),
116
+ icon: getIcon(item, true),
109
117
  };
110
118
  })
111
119
  : null,
112
120
  };
113
121
  });
114
- }, [userMenus, getLabel, filterMenuHandle]);
122
+ }, [userMenus, getLabel, filterMenuHandle, getIcon]);
115
123
  // 主菜单选中时调用
116
124
  var onSelectHandle = useCallback(function (info) {
117
125
  var _a, _b;
@@ -8,7 +8,7 @@ import SubMenu from './SubMenu.js';
8
8
  import { SUB_MENU_FIXED_STORAGE_KEY } from './constants.js';
9
9
 
10
10
  var MenuCom = function (props) {
11
- var width = props.width, subMenuWidth = props.subMenuWidth, layoutSiderRef = props.layoutSiderRef, addTab = props.addTab, logo = props.logo, logoStyle = props.logoStyle, getPrefixByAppId = props.getPrefixByAppId, subMenuLogo = props.subMenuLogo, _a = props.defaultVisible, defaultVisible = _a === void 0 ? false : _a, openOnlyHasSubmenus = props.openOnlyHasSubmenus, defaultFixed = props.defaultFixed, isShowSearchInput = props.isShowSearchInput, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine, subMenuItemLine = props.subMenuItemLine, bottomContainer = props.bottomContainer, onLogoClick = props.onLogoClick, logoTitle = props.logoTitle, maxDeepIndex = props.maxDeepIndex, persist = props.persist;
11
+ var width = props.width, subMenuWidth = props.subMenuWidth, layoutSiderRef = props.layoutSiderRef, addTab = props.addTab, logo = props.logo, logoStyle = props.logoStyle, getPrefixByAppId = props.getPrefixByAppId, subMenuLogo = props.subMenuLogo, _a = props.defaultVisible, defaultVisible = _a === void 0 ? false : _a, openOnlyHasSubmenus = props.openOnlyHasSubmenus, defaultFixed = props.defaultFixed, isShowSearchInput = props.isShowSearchInput, hideSubMenuBg = props.hideSubMenuBg, menuItemLine = props.menuItemLine, subMenuItemLine = props.subMenuItemLine, bottomContainer = props.bottomContainer, onLogoClick = props.onLogoClick, logoTitle = props.logoTitle, maxDeepIndex = props.maxDeepIndex, persist = props.persist, renderIcon = props.renderIcon;
12
12
  // 二级菜单是否显示
13
13
  var _b = useState(function () {
14
14
  if (persist) {
@@ -38,7 +38,7 @@ var MenuCom = function (props) {
38
38
  var _a;
39
39
  (_a = subMenu.current) === null || _a === void 0 ? void 0 : _a.setVisible(false);
40
40
  }, []);
41
- return (jsxs("div", __assign({ className: "zmdms-menu", onMouseLeave: onMouseLeave }, { children: [jsx(Logo, { logo: logo, showLine: visible && !hideSubMenuBg, style: logoStyle, onClick: onLogoClick, logoTitle: logoTitle }), isShowSearchInput && jsx(SearchInput, { setVisible: setVisible }), jsx(MainMenu, { onMouseEnter: onMouseEnter, addTab: addTab, getPrefixByAppId: getPrefixByAppId, subMenu: subMenu, hideSubMenuBg: hideSubMenuBg, menuItemLine: menuItemLine }), jsx(SubMenu, { ref: subMenu, marginLeft: width, subMenuWidth: subMenuWidth, layoutSiderRef: layoutSiderRef, addTab: addTab, getPrefixByAppId: getPrefixByAppId, subMenuLogo: subMenuLogo, visible: visible, setVisible: setVisible, defaultFixed: defaultFixed, hideSubMenuBg: hideSubMenuBg, subMenuItemLine: subMenuItemLine, openOnlyHasSubmenus: openOnlyHasSubmenus, maxDeepIndex: maxDeepIndex, persist: persist }), bottomContainer] })));
41
+ return (jsxs("div", __assign({ className: "zmdms-menu", onMouseLeave: onMouseLeave }, { children: [jsx(Logo, { logo: logo, showLine: visible && !hideSubMenuBg, style: logoStyle, onClick: onLogoClick, logoTitle: logoTitle }), isShowSearchInput && jsx(SearchInput, { setVisible: setVisible }), jsx(MainMenu, { onMouseEnter: onMouseEnter, addTab: addTab, getPrefixByAppId: getPrefixByAppId, subMenu: subMenu, hideSubMenuBg: hideSubMenuBg, menuItemLine: menuItemLine, renderIcon: renderIcon }), jsx(SubMenu, { ref: subMenu, marginLeft: width, subMenuWidth: subMenuWidth, layoutSiderRef: layoutSiderRef, addTab: addTab, getPrefixByAppId: getPrefixByAppId, subMenuLogo: subMenuLogo, visible: visible, setVisible: setVisible, defaultFixed: defaultFixed, hideSubMenuBg: hideSubMenuBg, subMenuItemLine: subMenuItemLine, openOnlyHasSubmenus: openOnlyHasSubmenus, maxDeepIndex: maxDeepIndex, persist: persist }), bottomContainer] })));
42
42
  };
43
43
  var Menu = memo(MenuCom);
44
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",