@donglegeyu/company-ui 2.7.0 → 2.8.0

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.
@@ -357,20 +357,19 @@ function AdminLayoutTemplate({
357
357
  contentClassName,
358
358
  contentStyle
359
359
  }) {
360
- var _a;
361
360
  const effectiveFirstMenus = firstMenus ?? DEFAULT_FIRST_MENUS;
362
361
  const effectiveSystemBottomMenus = systemBottomMenus ?? DEFAULT_SYSTEM_BOTTOM_MENUS;
363
362
  const [initialActiveKey] = (0, import_react.useState)(() => {
364
- var _a2;
363
+ var _a;
365
364
  if (defaultActiveKey)
366
365
  return defaultActiveKey;
367
366
  const menu = defaultActiveFirstMenu ? businessMenus.find((m) => m.key === defaultActiveFirstMenu) : businessMenus[0];
368
- return ((_a2 = findFirstLeaf((menu == null ? void 0 : menu.children) ?? [])) == null ? void 0 : _a2.key) ?? (menu == null ? void 0 : menu.key) ?? "home";
367
+ return ((_a = findFirstLeaf((menu == null ? void 0 : menu.children) ?? [])) == null ? void 0 : _a.key) ?? (menu == null ? void 0 : menu.key) ?? "home";
369
368
  });
370
369
  const [internalDomainId, setInternalDomainId] = (0, import_react.useState)(
371
370
  () => {
372
- var _a2;
373
- return defaultDomainId ?? ((_a2 = domains[0]) == null ? void 0 : _a2.id) ?? null;
371
+ var _a;
372
+ return defaultDomainId ?? ((_a = domains[0]) == null ? void 0 : _a.id) ?? null;
374
373
  }
375
374
  );
376
375
  const isDomainControlled = currentDomainId !== void 0;
@@ -383,8 +382,8 @@ function AdminLayoutTemplate({
383
382
  const [favorites, setFavorites] = (0, import_react.useState)(defaultFavorites);
384
383
  const [activeFirstMenu, setActiveFirstMenu] = (0, import_react.useState)(
385
384
  () => {
386
- var _a2;
387
- return defaultActiveFirstMenu ?? ((_a2 = businessMenus[0]) == null ? void 0 : _a2.key) ?? "home";
385
+ var _a;
386
+ return defaultActiveFirstMenu ?? ((_a = businessMenus[0]) == null ? void 0 : _a.key) ?? "home";
388
387
  }
389
388
  );
390
389
  const [activeKey, setActiveKey] = (0, import_react.useState)(initialActiveKey);
@@ -420,7 +419,6 @@ function AdminLayoutTemplate({
420
419
  const effectiveTabs = isTabsControlled ? tabs : internalTabs;
421
420
  const isTabActiveControlled = activeTabKey !== void 0;
422
421
  const effectiveActiveTabKey = isTabActiveControlled ? activeTabKey : internalActiveTabKey;
423
- const secondMenus = ((_a = businessMenus.find((m) => m.key === activeFirstMenu)) == null ? void 0 : _a.children) ?? [];
424
422
  const isHomeActive = homeTab ? effectiveActiveTabKey === homeTab.key : false;
425
423
  const activePage = pages == null ? void 0 : pages.find((p) => p.key === effectiveActiveTabKey);
426
424
  const content = isHomeActive ? homeContent ?? children : (activePage == null ? void 0 : activePage.component) ?? children;
@@ -440,11 +438,11 @@ function AdminLayoutTemplate({
440
438
  return [
441
439
  ...home,
442
440
  ...effectiveTabs.map((tab) => {
443
- var _a2;
441
+ var _a;
444
442
  return {
445
443
  key: tab.key,
446
444
  label: typeof tab.label === "string" ? tab.label : tab.key,
447
- capability: (_a2 = pages == null ? void 0 : pages.find((page) => page.key === tab.key)) == null ? void 0 : _a2.aiCapability
445
+ capability: (_a = pages == null ? void 0 : pages.find((page) => page.key === tab.key)) == null ? void 0 : _a.aiCapability
448
446
  };
449
447
  })
450
448
  ];
@@ -457,11 +455,11 @@ function AdminLayoutTemplate({
457
455
  return () => document.removeEventListener("fullscreenchange", onFullscreenChange);
458
456
  }, []);
459
457
  const toggleFullscreen = (0, import_react.useCallback)(() => {
460
- var _a2;
458
+ var _a;
461
459
  if (document.fullscreenElement) {
462
460
  void document.exitFullscreen();
463
461
  } else {
464
- void ((_a2 = rootRef.current) == null ? void 0 : _a2.requestFullscreen());
462
+ void ((_a = rootRef.current) == null ? void 0 : _a.requestFullscreen());
465
463
  }
466
464
  }, []);
467
465
  const systemMenuKeys = (0, import_react.useMemo)(
@@ -596,17 +594,17 @@ function AdminLayoutTemplate({
596
594
  }, [homeTab, isTabActiveControlled, onActiveFirstMenuChange, onActiveTabChange]);
597
595
  const handleFirstMenuSelect = (0, import_react.useCallback)(
598
596
  (key) => {
599
- var _a2;
597
+ var _a;
600
598
  setActiveFirstMenu(key);
601
599
  onActiveFirstMenuChange == null ? void 0 : onActiveFirstMenuChange(key);
602
- const nextSecondMenus = ((_a2 = businessMenus.find((m) => m.key === key)) == null ? void 0 : _a2.children) ?? [];
600
+ const nextSecondMenus = ((_a = businessMenus.find((m) => m.key === key)) == null ? void 0 : _a.children) ?? [];
603
601
  setExpandedKeys(collectParentKeys(nextSecondMenus));
604
602
  },
605
603
  [businessMenus, onActiveFirstMenuChange]
606
604
  );
607
605
  const handleMenuClick = (0, import_react.useCallback)(
608
606
  (menu) => {
609
- var _a2;
607
+ var _a;
610
608
  setActiveKey(menu.key);
611
609
  const parentModule = businessMenus.find((m) => findMenuByKey(m.children ?? [], menu.key));
612
610
  if (parentModule && parentModule.key !== activeFirstMenu) {
@@ -614,7 +612,7 @@ function AdminLayoutTemplate({
614
612
  setExpandedKeys(collectParentKeys(parentModule.children ?? []));
615
613
  onActiveFirstMenuChange == null ? void 0 : onActiveFirstMenuChange(parentModule.key);
616
614
  }
617
- if ((_a2 = menu.children) == null ? void 0 : _a2.length)
615
+ if ((_a = menu.children) == null ? void 0 : _a.length)
618
616
  return;
619
617
  if (systemMenuKeys.has(menu.key)) {
620
618
  if (homeTab && menu.key === homeTab.key) {
@@ -717,7 +715,6 @@ function AdminLayoutTemplate({
717
715
  firstMenus: effectiveFirstMenus,
718
716
  systemBottomMenus: effectiveSystemBottomMenus,
719
717
  businessMenus,
720
- secondMenus,
721
718
  customNavMenus: effectiveCustomNavMenus,
722
719
  onCustomNavUpdate: handleCustomNavUpdate,
723
720
  favorites,
@@ -14,6 +14,7 @@ export interface FirstSidebarProps {
14
14
  activeKey: string;
15
15
  activeFirstMenu: string;
16
16
  visibleMenuCount?: number;
17
+ bottomExtra?: React.ReactNode;
17
18
  domainPopoverOpen: boolean;
18
19
  adminPopoverOpen: boolean;
19
20
  onDomainPopoverOpenChange: (open: boolean) => void;
@@ -26,4 +27,4 @@ export interface FirstSidebarProps {
26
27
  onThemeSettings?: () => void;
27
28
  onLogout?: () => void;
28
29
  }
29
- export default function FirstSidebar({ domains, currentDomainId, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, activeKey, activeFirstMenu, visibleMenuCount, domainPopoverOpen, adminPopoverOpen, onDomainPopoverOpenChange, onAdminPopoverOpenChange, onDomainChange, onMenuClick, onBusinessMenuEnter, onBusinessMenuLeave, onOpenMore, onThemeSettings, onLogout, }: FirstSidebarProps): import("react").JSX.Element;
30
+ export default function FirstSidebar({ domains, currentDomainId, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, activeKey, activeFirstMenu, visibleMenuCount, bottomExtra, domainPopoverOpen, adminPopoverOpen, onDomainPopoverOpenChange, onAdminPopoverOpenChange, onDomainChange, onMenuClick, onBusinessMenuEnter, onBusinessMenuLeave, onOpenMore, onThemeSettings, onLogout, }: FirstSidebarProps): import("react").JSX.Element;
@@ -39,6 +39,7 @@ function FirstSidebar({
39
39
  activeKey,
40
40
  activeFirstMenu,
41
41
  visibleMenuCount = 6,
42
+ bottomExtra,
42
43
  domainPopoverOpen,
43
44
  adminPopoverOpen,
44
45
  onDomainPopoverOpenChange,
@@ -131,6 +132,7 @@ function FirstSidebar({
131
132
  menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: menu.icon || "setting", className: "menu-icon" }),
132
133
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
133
134
  ] }, menu.key)),
135
+ bottomExtra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bottom-extra", children: bottomExtra }),
134
136
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
137
  import_basic_components.CompanyPopover,
136
138
  {
@@ -13,7 +13,6 @@ export interface CompanySidebarProps {
13
13
  firstMenus: SidebarMenuItem[];
14
14
  systemBottomMenus: SidebarMenuItem[];
15
15
  businessMenus: SidebarMenuItem[];
16
- secondMenus: SidebarMenuItem[];
17
16
  customNavMenus: SidebarMenuItem[];
18
17
  onCustomNavUpdate: (selected: SidebarMenuItem[]) => void;
19
18
  favorites: SidebarFavoriteItem[];
@@ -30,7 +29,9 @@ export interface CompanySidebarProps {
30
29
  onSecondSidebarFixedChange: (fixed: boolean) => void;
31
30
  visibleMenuCount?: number;
32
31
  emptyImage?: string;
32
+ bottomExtra?: React.ReactNode;
33
+ onDomainPopoverOpenChange?: (open: boolean) => void;
33
34
  onThemeSettings?: () => void;
34
35
  onLogout?: () => void;
35
36
  }
36
- export default function CompanySidebar({ className, style, domains, currentDomainId, onDomainChange, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, secondMenus, customNavMenus, onCustomNavUpdate, favorites, onAddFavorite, onRemoveFavorite, onFavoritesReorder, activeFirstMenu, activeKey, onFirstMenuSelect, onMenuClick, expandedKeys, onExpandedKeysChange, secondSidebarFixed, onSecondSidebarFixedChange, visibleMenuCount, emptyImage, onThemeSettings, onLogout, }: CompanySidebarProps): import("react").JSX.Element;
37
+ export default function CompanySidebar({ className, style, domains, currentDomainId, onDomainChange, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, onCustomNavUpdate, favorites, onAddFavorite, onRemoveFavorite, onFavoritesReorder, activeFirstMenu, activeKey, onFirstMenuSelect, onMenuClick, expandedKeys, onExpandedKeysChange, secondSidebarFixed, onSecondSidebarFixedChange, visibleMenuCount, emptyImage, bottomExtra, onDomainPopoverOpenChange, onThemeSettings, onLogout, }: CompanySidebarProps): import("react").JSX.Element;
@@ -74,7 +74,6 @@ function CompanySidebar({
74
74
  firstMenus,
75
75
  systemBottomMenus,
76
76
  businessMenus,
77
- secondMenus,
78
77
  customNavMenus,
79
78
  onCustomNavUpdate,
80
79
  favorites,
@@ -91,6 +90,8 @@ function CompanySidebar({
91
90
  onSecondSidebarFixedChange,
92
91
  visibleMenuCount = 6,
93
92
  emptyImage,
93
+ bottomExtra,
94
+ onDomainPopoverOpenChange,
94
95
  onThemeSettings,
95
96
  onLogout
96
97
  }) {
@@ -98,6 +99,7 @@ function CompanySidebar({
98
99
  domainPopoverOpen: false,
99
100
  adminPopoverOpen: false,
100
101
  secondSidebarHovered: false,
102
+ hoverKey: null,
101
103
  moreDrawerOpen: false,
102
104
  customNavVisible: false,
103
105
  localExpandedKeys: expandedKeys,
@@ -105,8 +107,15 @@ function CompanySidebar({
105
107
  hasError: false
106
108
  });
107
109
  const resolvedBusinessMenus = (0, import_react.useMemo)(() => (0, import_menuIconMap.resolveMenuIcons)(businessMenus), [businessMenus]);
108
- const resolvedSecondMenus = (0, import_react.useMemo)(() => (0, import_menuIconMap.resolveMenuIcons)(secondMenus), [secondMenus]);
109
110
  const resolvedCustomNavMenus = (0, import_react.useMemo)(() => (0, import_menuIconMap.resolveMenuIcons)(customNavMenus), [customNavMenus]);
111
+ const displayFirstMenu = state.hoverKey ?? activeFirstMenu;
112
+ const displaySecondMenus = (0, import_react.useMemo)(
113
+ () => {
114
+ var _a;
115
+ return ((_a = resolvedBusinessMenus.find((m) => m.key === displayFirstMenu)) == null ? void 0 : _a.children) ?? [];
116
+ },
117
+ [resolvedBusinessMenus, displayFirstMenu]
118
+ );
110
119
  const leafToFirstKeyMap = (0, import_react.useMemo)(() => buildLeafToFirstKeyMap(businessMenus), [businessMenus]);
111
120
  const handleLeafMenuClick = (0, import_react.useCallback)(
112
121
  (menu) => {
@@ -132,7 +141,7 @@ function CompanySidebar({
132
141
  if (hideSidebarTimerRef.current)
133
142
  clearTimeout(hideSidebarTimerRef.current);
134
143
  hideSidebarTimerRef.current = setTimeout(() => {
135
- setState((prev) => ({ ...prev, secondSidebarHovered: false }));
144
+ setState((prev) => ({ ...prev, secondSidebarHovered: false, hoverKey: null }));
136
145
  }, 100);
137
146
  }, [hideSidebarTimerRef]);
138
147
  const cancelHideSidebar = (0, import_react.useCallback)(() => {
@@ -143,12 +152,11 @@ function CompanySidebar({
143
152
  setState((prev) => ({ ...prev, secondSidebarHovered: true }));
144
153
  }, [hideSidebarTimerRef]);
145
154
  const handleBusinessMenuEnter = (0, import_react.useCallback)(
146
- (_menu) => {
147
- if (!secondSidebarFixed) {
148
- cancelHideSidebar();
149
- }
155
+ (menu) => {
156
+ setState((prev) => ({ ...prev, hoverKey: menu.key }));
157
+ cancelHideSidebar();
150
158
  },
151
- [secondSidebarFixed, cancelHideSidebar]
159
+ [cancelHideSidebar]
152
160
  );
153
161
  const handleBusinessMenuLeave = (0, import_react.useCallback)(() => {
154
162
  delayHideSidebar();
@@ -218,9 +226,13 @@ function CompanySidebar({
218
226
  activeKey,
219
227
  activeFirstMenu,
220
228
  visibleMenuCount,
229
+ bottomExtra,
221
230
  domainPopoverOpen: state.domainPopoverOpen,
222
231
  adminPopoverOpen: state.adminPopoverOpen,
223
- onDomainPopoverOpenChange: (open) => setState((prev) => ({ ...prev, domainPopoverOpen: open })),
232
+ onDomainPopoverOpenChange: (open) => {
233
+ setState((prev) => ({ ...prev, domainPopoverOpen: open }));
234
+ onDomainPopoverOpenChange == null ? void 0 : onDomainPopoverOpenChange(open);
235
+ },
224
236
  onAdminPopoverOpenChange: (open) => setState((prev) => ({ ...prev, adminPopoverOpen: open })),
225
237
  onDomainChange,
226
238
  onMenuClick: handleFirstMenuClick,
@@ -234,11 +246,11 @@ function CompanySidebar({
234
246
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
235
247
  import_SecondSidebar.default,
236
248
  {
237
- activeFirstMenu,
249
+ activeFirstMenu: displayFirstMenu,
238
250
  activeKey,
239
251
  secondSidebarHovered: state.secondSidebarHovered,
240
252
  secondSidebarFixed,
241
- secondMenus: resolvedSecondMenus,
253
+ secondMenus: displaySecondMenus,
242
254
  favorites: state.localFavorites,
243
255
  expandedKeys: state.localExpandedKeys,
244
256
  emptyImage,
@@ -179,6 +179,16 @@
179
179
  align-self: stretch;
180
180
  z-index: 5;
181
181
  cursor: pointer;
182
+
183
+ &:hover {
184
+ .avatar {
185
+ background: rgba(255, 255, 255, 0.25);
186
+ }
187
+
188
+ .name {
189
+ color: #fff;
190
+ }
191
+ }
182
192
  }
183
193
 
184
194
  .person-info .avatar {
@@ -195,6 +205,7 @@
195
205
  background: rgba(255, 255, 255, 0.15);
196
206
  color: #fff;
197
207
  font-size: 10px;
208
+ transition: background 0.2s ease;
198
209
  }
199
210
 
200
211
  .person-info .name {
@@ -202,6 +213,7 @@
202
213
  font-weight: normal;
203
214
  line-height: 20px;
204
215
  color: rgba(255, 255, 255, 0.65);
216
+ transition: color 0.25s ease;
205
217
  overflow: hidden;
206
218
  text-overflow: ellipsis;
207
219
  white-space: nowrap;
@@ -225,6 +237,10 @@
225
237
  &:hover:not(.active) {
226
238
  color: #fff;
227
239
  background: rgba(255, 255, 255, 0.08);
240
+
241
+ .menu-label {
242
+ color: #fff;
243
+ }
228
244
  }
229
245
 
230
246
  &.active {
@@ -261,6 +277,10 @@
261
277
  &:hover:not(.active) {
262
278
  color: #fff;
263
279
  background: rgba(255, 255, 255, 0.08);
280
+
281
+ .menu-label {
282
+ color: #fff;
283
+ }
264
284
  }
265
285
 
266
286
  &.active {
@@ -322,6 +342,14 @@
322
342
  transition: all 0.2s;
323
343
  z-index: 5;
324
344
 
345
+ &:hover {
346
+ color: #fff;
347
+
348
+ .menu-label {
349
+ color: #fff;
350
+ }
351
+ }
352
+
325
353
  .menu-icon {
326
354
  width: 16px;
327
355
  height: 16px;
@@ -340,6 +368,14 @@
340
368
  white-space: nowrap;
341
369
  }
342
370
  }
371
+
372
+ .bottom-extra {
373
+ width: 100%;
374
+ min-width: 0;
375
+ flex-shrink: 0;
376
+ color: rgba(255, 255, 255, 0.65);
377
+ font-size: 12px;
378
+ }
343
379
  }
344
380
 
345
381
  // ========== Domain Popover ==========
@@ -441,7 +441,7 @@ function AiAssistantAside(_ref) {
441
441
  * - 两种内容模式:pages 配置式(key 与菜单联动)或 children 兜底(直接放业务模板)
442
442
  */
443
443
  export default function AdminLayoutTemplate(_ref2) {
444
- var _businessMenus$find$c, _businessMenus$find, _activePage$component;
444
+ var _activePage$component;
445
445
  var className = _ref2.className,
446
446
  style = _ref2.style,
447
447
  logo = _ref2.logo,
@@ -596,11 +596,6 @@ export default function AdminLayoutTemplate(_ref2) {
596
596
  var isTabActiveControlled = activeTabKey !== undefined;
597
597
  var effectiveActiveTabKey = isTabActiveControlled ? activeTabKey : internalActiveTabKey;
598
598
 
599
- // —— 二级菜单:由当前激活一级模块派生 ——
600
- var secondMenus = (_businessMenus$find$c = (_businessMenus$find = businessMenus.find(function (m) {
601
- return m.key === activeFirstMenu;
602
- })) === null || _businessMenus$find === void 0 ? void 0 : _businessMenus$find.children) !== null && _businessMenus$find$c !== void 0 ? _businessMenus$find$c : [];
603
-
604
599
  // —— 内容:pages 配置式优先,回落 children ——
605
600
  var isHomeActive = homeTab ? effectiveActiveTabKey === homeTab.key : false;
606
601
  var activePage = pages === null || pages === void 0 ? void 0 : pages.find(function (p) {
@@ -781,13 +776,13 @@ export default function AdminLayoutTemplate(_ref2) {
781
776
  });
782
777
  }, [homeTab, isTabActiveControlled, onActiveFirstMenuChange, onActiveTabChange]);
783
778
  var handleFirstMenuSelect = useCallback(function (key) {
784
- var _businessMenus$find$c2, _businessMenus$find2;
779
+ var _businessMenus$find$c, _businessMenus$find;
785
780
  setActiveFirstMenu(key);
786
781
  onActiveFirstMenuChange === null || onActiveFirstMenuChange === void 0 || onActiveFirstMenuChange(key);
787
782
  // 切换模块时自动展开二级菜单的父级分组
788
- var nextSecondMenus = (_businessMenus$find$c2 = (_businessMenus$find2 = businessMenus.find(function (m) {
783
+ var nextSecondMenus = (_businessMenus$find$c = (_businessMenus$find = businessMenus.find(function (m) {
789
784
  return m.key === key;
790
- })) === null || _businessMenus$find2 === void 0 ? void 0 : _businessMenus$find2.children) !== null && _businessMenus$find$c2 !== void 0 ? _businessMenus$find$c2 : [];
785
+ })) === null || _businessMenus$find === void 0 ? void 0 : _businessMenus$find.children) !== null && _businessMenus$find$c !== void 0 ? _businessMenus$find$c : [];
791
786
  setExpandedKeys(collectParentKeys(nextSecondMenus));
792
787
  }, [businessMenus, onActiveFirstMenuChange]);
793
788
  var handleMenuClick = useCallback(function (menu) {
@@ -913,7 +908,6 @@ export default function AdminLayoutTemplate(_ref2) {
913
908
  firstMenus: effectiveFirstMenus,
914
909
  systemBottomMenus: effectiveSystemBottomMenus,
915
910
  businessMenus: businessMenus,
916
- secondMenus: secondMenus,
917
911
  customNavMenus: effectiveCustomNavMenus,
918
912
  onCustomNavUpdate: handleCustomNavUpdate,
919
913
  favorites: favorites,
@@ -14,6 +14,7 @@ export interface FirstSidebarProps {
14
14
  activeKey: string;
15
15
  activeFirstMenu: string;
16
16
  visibleMenuCount?: number;
17
+ bottomExtra?: React.ReactNode;
17
18
  domainPopoverOpen: boolean;
18
19
  adminPopoverOpen: boolean;
19
20
  onDomainPopoverOpenChange: (open: boolean) => void;
@@ -26,4 +27,4 @@ export interface FirstSidebarProps {
26
27
  onThemeSettings?: () => void;
27
28
  onLogout?: () => void;
28
29
  }
29
- export default function FirstSidebar({ domains, currentDomainId, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, activeKey, activeFirstMenu, visibleMenuCount, domainPopoverOpen, adminPopoverOpen, onDomainPopoverOpenChange, onAdminPopoverOpenChange, onDomainChange, onMenuClick, onBusinessMenuEnter, onBusinessMenuLeave, onOpenMore, onThemeSettings, onLogout, }: FirstSidebarProps): import("react").JSX.Element;
30
+ export default function FirstSidebar({ domains, currentDomainId, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, activeKey, activeFirstMenu, visibleMenuCount, bottomExtra, domainPopoverOpen, adminPopoverOpen, onDomainPopoverOpenChange, onAdminPopoverOpenChange, onDomainChange, onMenuClick, onBusinessMenuEnter, onBusinessMenuLeave, onOpenMore, onThemeSettings, onLogout, }: FirstSidebarProps): import("react").JSX.Element;
@@ -18,6 +18,7 @@ export default function FirstSidebar(_ref) {
18
18
  activeFirstMenu = _ref.activeFirstMenu,
19
19
  _ref$visibleMenuCount = _ref.visibleMenuCount,
20
20
  visibleMenuCount = _ref$visibleMenuCount === void 0 ? 6 : _ref$visibleMenuCount,
21
+ bottomExtra = _ref.bottomExtra,
21
22
  domainPopoverOpen = _ref.domainPopoverOpen,
22
23
  adminPopoverOpen = _ref.adminPopoverOpen,
23
24
  onDomainPopoverOpenChange = _ref.onDomainPopoverOpenChange,
@@ -166,6 +167,9 @@ export default function FirstSidebar(_ref) {
166
167
  children: menu.label
167
168
  })]
168
169
  }, menu.key);
170
+ }), bottomExtra && /*#__PURE__*/_jsx("div", {
171
+ className: "bottom-extra",
172
+ children: bottomExtra
169
173
  }), /*#__PURE__*/_jsx(CompanyPopover, {
170
174
  open: adminPopoverOpen,
171
175
  onOpenChange: onAdminPopoverOpenChange,
@@ -13,7 +13,6 @@ export interface CompanySidebarProps {
13
13
  firstMenus: SidebarMenuItem[];
14
14
  systemBottomMenus: SidebarMenuItem[];
15
15
  businessMenus: SidebarMenuItem[];
16
- secondMenus: SidebarMenuItem[];
17
16
  customNavMenus: SidebarMenuItem[];
18
17
  onCustomNavUpdate: (selected: SidebarMenuItem[]) => void;
19
18
  favorites: SidebarFavoriteItem[];
@@ -30,7 +29,9 @@ export interface CompanySidebarProps {
30
29
  onSecondSidebarFixedChange: (fixed: boolean) => void;
31
30
  visibleMenuCount?: number;
32
31
  emptyImage?: string;
32
+ bottomExtra?: React.ReactNode;
33
+ onDomainPopoverOpenChange?: (open: boolean) => void;
33
34
  onThemeSettings?: () => void;
34
35
  onLogout?: () => void;
35
36
  }
36
- export default function CompanySidebar({ className, style, domains, currentDomainId, onDomainChange, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, secondMenus, customNavMenus, onCustomNavUpdate, favorites, onAddFavorite, onRemoveFavorite, onFavoritesReorder, activeFirstMenu, activeKey, onFirstMenuSelect, onMenuClick, expandedKeys, onExpandedKeysChange, secondSidebarFixed, onSecondSidebarFixedChange, visibleMenuCount, emptyImage, onThemeSettings, onLogout, }: CompanySidebarProps): import("react").JSX.Element;
37
+ export default function CompanySidebar({ className, style, domains, currentDomainId, onDomainChange, userInfo, logo, brandName, firstMenus, systemBottomMenus, businessMenus, customNavMenus, onCustomNavUpdate, favorites, onAddFavorite, onRemoveFavorite, onFavoritesReorder, activeFirstMenu, activeKey, onFirstMenuSelect, onMenuClick, expandedKeys, onExpandedKeysChange, secondSidebarFixed, onSecondSidebarFixedChange, visibleMenuCount, emptyImage, bottomExtra, onDomainPopoverOpenChange, onThemeSettings, onLogout, }: CompanySidebarProps): import("react").JSX.Element;
@@ -48,6 +48,7 @@ function DefaultFallback() {
48
48
  });
49
49
  }
50
50
  export default function CompanySidebar(_ref) {
51
+ var _state$hoverKey;
51
52
  var className = _ref.className,
52
53
  style = _ref.style,
53
54
  domains = _ref.domains,
@@ -60,7 +61,6 @@ export default function CompanySidebar(_ref) {
60
61
  firstMenus = _ref.firstMenus,
61
62
  systemBottomMenus = _ref.systemBottomMenus,
62
63
  businessMenus = _ref.businessMenus,
63
- secondMenus = _ref.secondMenus,
64
64
  customNavMenus = _ref.customNavMenus,
65
65
  onCustomNavUpdate = _ref.onCustomNavUpdate,
66
66
  favorites = _ref.favorites,
@@ -78,12 +78,15 @@ export default function CompanySidebar(_ref) {
78
78
  _ref$visibleMenuCount = _ref.visibleMenuCount,
79
79
  visibleMenuCount = _ref$visibleMenuCount === void 0 ? 6 : _ref$visibleMenuCount,
80
80
  emptyImage = _ref.emptyImage,
81
+ bottomExtra = _ref.bottomExtra,
82
+ _onDomainPopoverOpenChange = _ref.onDomainPopoverOpenChange,
81
83
  onThemeSettings = _ref.onThemeSettings,
82
84
  onLogout = _ref.onLogout;
83
85
  var _useState = useState({
84
86
  domainPopoverOpen: false,
85
87
  adminPopoverOpen: false,
86
88
  secondSidebarHovered: false,
89
+ hoverKey: null,
87
90
  moreDrawerOpen: false,
88
91
  customNavVisible: false,
89
92
  localExpandedKeys: expandedKeys,
@@ -96,13 +99,20 @@ export default function CompanySidebar(_ref) {
96
99
  var resolvedBusinessMenus = useMemo(function () {
97
100
  return resolveMenuIcons(businessMenus);
98
101
  }, [businessMenus]);
99
- var resolvedSecondMenus = useMemo(function () {
100
- return resolveMenuIcons(secondMenus);
101
- }, [secondMenus]);
102
102
  var resolvedCustomNavMenus = useMemo(function () {
103
103
  return resolveMenuIcons(customNavMenus);
104
104
  }, [customNavMenus]);
105
105
 
106
+ // hover 预切换:二级栏内容由内部 hoverKey 驱动(hover 期间预览悬浮项),activeFirstMenu 始终表示点击选中项
107
+ var displayFirstMenu = (_state$hoverKey = state.hoverKey) !== null && _state$hoverKey !== void 0 ? _state$hoverKey : activeFirstMenu;
108
+ // 二级栏内容直接由业务菜单树按 displayFirstMenu 派生,业务侧无需拼接 secondMenus
109
+ var displaySecondMenus = useMemo(function () {
110
+ var _resolvedBusinessMenu, _resolvedBusinessMenu2;
111
+ return (_resolvedBusinessMenu = (_resolvedBusinessMenu2 = resolvedBusinessMenus.find(function (m) {
112
+ return m.key === displayFirstMenu;
113
+ })) === null || _resolvedBusinessMenu2 === void 0 ? void 0 : _resolvedBusinessMenu2.children) !== null && _resolvedBusinessMenu !== void 0 ? _resolvedBusinessMenu : [];
114
+ }, [resolvedBusinessMenus, displayFirstMenu]);
115
+
106
116
  // 叶子 key -> 一级菜单 key 反查表(业务菜单树全量)
107
117
  var leafToFirstKeyMap = useMemo(function () {
108
118
  return buildLeafToFirstKeyMap(businessMenus);
@@ -138,9 +148,11 @@ export default function CompanySidebar(_ref) {
138
148
  var delayHideSidebar = useCallback(function () {
139
149
  if (hideSidebarTimerRef.current) clearTimeout(hideSidebarTimerRef.current);
140
150
  hideSidebarTimerRef.current = setTimeout(function () {
151
+ // 延迟隐藏时同步清空 hoverKey,避免预览内容残留
141
152
  setState(function (prev) {
142
153
  return _objectSpread(_objectSpread({}, prev), {}, {
143
- secondSidebarHovered: false
154
+ secondSidebarHovered: false,
155
+ hoverKey: null
144
156
  });
145
157
  });
146
158
  }, 100);
@@ -156,11 +168,15 @@ export default function CompanySidebar(_ref) {
156
168
  });
157
169
  });
158
170
  }, [hideSidebarTimerRef]);
159
- var handleBusinessMenuEnter = useCallback(function (_menu) {
160
- if (!secondSidebarFixed) {
161
- cancelHideSidebar();
162
- }
163
- }, [secondSidebarFixed, cancelHideSidebar]);
171
+ var handleBusinessMenuEnter = useCallback(function (menu) {
172
+ // hover 预切换:仅更新内部 hoverKey,不改 activeFirstMenu(不污染业务 store),定时器竞态由 cancelHideSidebar 消化
173
+ setState(function (prev) {
174
+ return _objectSpread(_objectSpread({}, prev), {}, {
175
+ hoverKey: menu.key
176
+ });
177
+ });
178
+ cancelHideSidebar();
179
+ }, [cancelHideSidebar]);
164
180
  var handleBusinessMenuLeave = useCallback(function () {
165
181
  delayHideSidebar();
166
182
  }, [delayHideSidebar]);
@@ -229,14 +245,16 @@ export default function CompanySidebar(_ref) {
229
245
  activeKey: activeKey,
230
246
  activeFirstMenu: activeFirstMenu,
231
247
  visibleMenuCount: visibleMenuCount,
248
+ bottomExtra: bottomExtra,
232
249
  domainPopoverOpen: state.domainPopoverOpen,
233
250
  adminPopoverOpen: state.adminPopoverOpen,
234
251
  onDomainPopoverOpenChange: function onDomainPopoverOpenChange(open) {
235
- return setState(function (prev) {
252
+ setState(function (prev) {
236
253
  return _objectSpread(_objectSpread({}, prev), {}, {
237
254
  domainPopoverOpen: open
238
255
  });
239
256
  });
257
+ _onDomainPopoverOpenChange === null || _onDomainPopoverOpenChange === void 0 || _onDomainPopoverOpenChange(open);
240
258
  },
241
259
  onAdminPopoverOpenChange: function onAdminPopoverOpenChange(open) {
242
260
  return setState(function (prev) {
@@ -259,11 +277,11 @@ export default function CompanySidebar(_ref) {
259
277
  onThemeSettings: onThemeSettings,
260
278
  onLogout: onLogout
261
279
  }), /*#__PURE__*/_jsx(SecondSidebar, {
262
- activeFirstMenu: activeFirstMenu,
280
+ activeFirstMenu: displayFirstMenu,
263
281
  activeKey: activeKey,
264
282
  secondSidebarHovered: state.secondSidebarHovered,
265
283
  secondSidebarFixed: secondSidebarFixed,
266
- secondMenus: resolvedSecondMenus,
284
+ secondMenus: displaySecondMenus,
267
285
  favorites: state.localFavorites,
268
286
  expandedKeys: state.localExpandedKeys,
269
287
  emptyImage: emptyImage,
@@ -179,6 +179,16 @@
179
179
  align-self: stretch;
180
180
  z-index: 5;
181
181
  cursor: pointer;
182
+
183
+ &:hover {
184
+ .avatar {
185
+ background: rgba(255, 255, 255, 0.25);
186
+ }
187
+
188
+ .name {
189
+ color: #fff;
190
+ }
191
+ }
182
192
  }
183
193
 
184
194
  .person-info .avatar {
@@ -195,6 +205,7 @@
195
205
  background: rgba(255, 255, 255, 0.15);
196
206
  color: #fff;
197
207
  font-size: 10px;
208
+ transition: background 0.2s ease;
198
209
  }
199
210
 
200
211
  .person-info .name {
@@ -202,6 +213,7 @@
202
213
  font-weight: normal;
203
214
  line-height: 20px;
204
215
  color: rgba(255, 255, 255, 0.65);
216
+ transition: color 0.25s ease;
205
217
  overflow: hidden;
206
218
  text-overflow: ellipsis;
207
219
  white-space: nowrap;
@@ -225,6 +237,10 @@
225
237
  &:hover:not(.active) {
226
238
  color: #fff;
227
239
  background: rgba(255, 255, 255, 0.08);
240
+
241
+ .menu-label {
242
+ color: #fff;
243
+ }
228
244
  }
229
245
 
230
246
  &.active {
@@ -261,6 +277,10 @@
261
277
  &:hover:not(.active) {
262
278
  color: #fff;
263
279
  background: rgba(255, 255, 255, 0.08);
280
+
281
+ .menu-label {
282
+ color: #fff;
283
+ }
264
284
  }
265
285
 
266
286
  &.active {
@@ -322,6 +342,14 @@
322
342
  transition: all 0.2s;
323
343
  z-index: 5;
324
344
 
345
+ &:hover {
346
+ color: #fff;
347
+
348
+ .menu-label {
349
+ color: #fff;
350
+ }
351
+ }
352
+
325
353
  .menu-icon {
326
354
  width: 16px;
327
355
  height: 16px;
@@ -340,6 +368,14 @@
340
368
  white-space: nowrap;
341
369
  }
342
370
  }
371
+
372
+ .bottom-extra {
373
+ width: 100%;
374
+ min-width: 0;
375
+ flex-shrink: 0;
376
+ color: rgba(255, 255, 255, 0.65);
377
+ font-size: 12px;
378
+ }
343
379
  }
344
380
 
345
381
  // ========== Domain Popover ==========
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donglegeyu/company-ui",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",