@donglegeyu/company-ui 2.7.0 → 2.9.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.
- package/dist/cjs/template-components/AdminLayoutTemplate/index.js +14 -17
- package/dist/cjs/template-components/CompanySidebar/CustomNavPanel.js +5 -3
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.d.ts +4 -3
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.js +21 -11
- package/dist/cjs/template-components/CompanySidebar/MoreMenuDrawer.js +3 -3
- package/dist/cjs/template-components/CompanySidebar/SecondSidebar.js +2 -2
- package/dist/cjs/template-components/CompanySidebar/index.d.ts +3 -2
- package/dist/cjs/template-components/CompanySidebar/index.js +59 -16
- package/dist/cjs/template-components/CompanySidebar/index.scss +42 -0
- package/dist/cjs/template-components/CompanySidebar/menuIconMap.js +5 -4
- package/dist/cjs/template-components/IconSelect/index.js +13 -2
- package/dist/es/template-components/AdminLayoutTemplate/index.js +4 -10
- package/dist/es/template-components/CompanySidebar/CustomNavPanel.js +6 -4
- package/dist/es/template-components/CompanySidebar/FirstSidebar.d.ts +4 -3
- package/dist/es/template-components/CompanySidebar/FirstSidebar.js +22 -11
- package/dist/es/template-components/CompanySidebar/MoreMenuDrawer.js +8 -3
- package/dist/es/template-components/CompanySidebar/SecondSidebar.js +2 -2
- package/dist/es/template-components/CompanySidebar/index.d.ts +3 -2
- package/dist/es/template-components/CompanySidebar/index.js +94 -20
- package/dist/es/template-components/CompanySidebar/index.scss +42 -0
- package/dist/es/template-components/CompanySidebar/menuIconMap.js +10 -3
- package/dist/es/template-components/IconSelect/index.js +45 -30
- package/package.json +1 -1
|
@@ -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
|
|
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 ((
|
|
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
|
|
373
|
-
return defaultDomainId ?? ((
|
|
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
|
|
387
|
-
return defaultActiveFirstMenu ?? ((
|
|
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
|
|
441
|
+
var _a;
|
|
444
442
|
return {
|
|
445
443
|
key: tab.key,
|
|
446
444
|
label: typeof tab.label === "string" ? tab.label : tab.key,
|
|
447
|
-
capability: (
|
|
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
|
|
458
|
+
var _a;
|
|
461
459
|
if (document.fullscreenElement) {
|
|
462
460
|
void document.exitFullscreen();
|
|
463
461
|
} else {
|
|
464
|
-
void ((
|
|
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
|
|
597
|
+
var _a;
|
|
600
598
|
setActiveFirstMenu(key);
|
|
601
599
|
onActiveFirstMenuChange == null ? void 0 : onActiveFirstMenuChange(key);
|
|
602
|
-
const nextSecondMenus = ((
|
|
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
|
|
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 ((
|
|
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,
|
|
@@ -51,7 +51,8 @@ function CustomNavPanel({
|
|
|
51
51
|
selectedItems.push({
|
|
52
52
|
key: menu.key,
|
|
53
53
|
label: menu.label,
|
|
54
|
-
icon: menu.icon || "folder-open"
|
|
54
|
+
icon: menu.icon || "folder-open",
|
|
55
|
+
iconNode: menu.iconNode
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -60,7 +61,8 @@ function CustomNavPanel({
|
|
|
60
61
|
(menu) => ({
|
|
61
62
|
key: menu.key,
|
|
62
63
|
label: menu.label,
|
|
63
|
-
icon: menu.icon || "folder-open"
|
|
64
|
+
icon: menu.icon || "folder-open",
|
|
65
|
+
iconNode: menu.iconNode
|
|
64
66
|
})
|
|
65
67
|
);
|
|
66
68
|
setAllMenus([...selectedItems, ...unselectedItems]);
|
|
@@ -134,7 +136,7 @@ function CustomNavPanel({
|
|
|
134
136
|
onDragEnd,
|
|
135
137
|
children: [
|
|
136
138
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drag-handle", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "drag", size: 16 }) }),
|
|
137
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "menu-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "menu-icon", children: item.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: item.icon || "folder-open", size: 16 }) }),
|
|
138
140
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: item.label }),
|
|
139
141
|
index < totalCount && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "nav-badge", children: "导航栏" })
|
|
140
142
|
]
|
|
@@ -14,16 +14,17 @@ 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;
|
|
20
21
|
onAdminPopoverOpenChange: (open: boolean) => void;
|
|
21
22
|
onDomainChange: (domain: SidebarDomain) => void;
|
|
22
23
|
onMenuClick: (menu: SidebarMenuItem) => void;
|
|
23
|
-
onBusinessMenuEnter: (menu: SidebarMenuItem) => void;
|
|
24
|
-
onBusinessMenuLeave: () => void;
|
|
24
|
+
onBusinessMenuEnter: (menu: SidebarMenuItem, e: React.MouseEvent) => void;
|
|
25
|
+
onBusinessMenuLeave: (e: React.MouseEvent) => void;
|
|
25
26
|
onOpenMore: () => void;
|
|
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,
|
|
@@ -94,10 +95,10 @@ function FirstSidebar({
|
|
|
94
95
|
{
|
|
95
96
|
className: `menu-item menu-item--normal${activeKey === menu.key ? " active" : ""}`,
|
|
96
97
|
onClick: () => onMenuClick(menu),
|
|
97
|
-
onMouseEnter: () => menu.key === "favorites" && onBusinessMenuEnter(menu),
|
|
98
|
-
onMouseLeave: () => menu.key === "favorites" && onBusinessMenuLeave(),
|
|
98
|
+
onMouseEnter: (e) => menu.key === "favorites" && onBusinessMenuEnter(menu, e),
|
|
99
|
+
onMouseLeave: (e) => menu.key === "favorites" && onBusinessMenuLeave(e),
|
|
99
100
|
children: [
|
|
100
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
101
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "home", className: "menu-icon" }),
|
|
101
102
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
102
103
|
]
|
|
103
104
|
},
|
|
@@ -111,26 +112,35 @@ function FirstSidebar({
|
|
|
111
112
|
{
|
|
112
113
|
className: `business-menu-item${activeFirstMenu === menu.key || activeKey === menu.key ? " active" : ""}`,
|
|
113
114
|
onClick: () => onMenuClick(menu),
|
|
114
|
-
onMouseEnter: () => onBusinessMenuEnter(menu),
|
|
115
|
-
onMouseLeave: onBusinessMenuLeave,
|
|
115
|
+
onMouseEnter: (e) => onBusinessMenuEnter(menu, e),
|
|
116
|
+
onMouseLeave: (e) => onBusinessMenuLeave(e),
|
|
116
117
|
children: [
|
|
117
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
118
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "folder-open", className: "menu-icon" }),
|
|
118
119
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
119
120
|
]
|
|
120
121
|
},
|
|
121
122
|
menu.key
|
|
122
123
|
)),
|
|
123
|
-
hasMore && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
hasMore && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: "business-menu-item more-btn",
|
|
128
|
+
onClick: onOpenMore,
|
|
129
|
+
onMouseLeave: (e) => onBusinessMenuLeave(e),
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "more-three", className: "menu-icon" }),
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: "更多" })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
)
|
|
127
136
|
] }),
|
|
128
137
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "system-menu-bottom", children: [
|
|
129
138
|
(systemBottomMenus || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "nav-divider" }),
|
|
130
139
|
(systemBottomMenus || []).map((menu) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "system-bottom-item", onClick: () => onMenuClick(menu), children: [
|
|
131
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
140
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "setting", className: "menu-icon" }),
|
|
132
141
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
133
142
|
] }, menu.key)),
|
|
143
|
+
bottomExtra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bottom-extra", children: bottomExtra }),
|
|
134
144
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
145
|
import_basic_components.CompanyPopover,
|
|
136
146
|
{
|
|
@@ -149,7 +149,7 @@ function MoreMenuDrawer({
|
|
|
149
149
|
flushLeafRun();
|
|
150
150
|
blocks.push(
|
|
151
151
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-section", children: [
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "section-title", children: [
|
|
152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "section-title", onClick: () => handleChildClick(child), children: [
|
|
153
153
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "title-bar" }),
|
|
154
154
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "title-text", children: child.label })
|
|
155
155
|
] }),
|
|
@@ -179,7 +179,7 @@ function MoreMenuDrawer({
|
|
|
179
179
|
onChange: handleSearchChange,
|
|
180
180
|
onCompositionStart: handleCompositionStart,
|
|
181
181
|
onCompositionEnd: handleCompositionEnd,
|
|
182
|
-
|
|
182
|
+
onClick: () => setSearchPanelOpen(true),
|
|
183
183
|
onBlur: () => setSearchPanelOpen(false),
|
|
184
184
|
className: "search-input",
|
|
185
185
|
placeholder: "请输入关键词搜索应用和菜单"
|
|
@@ -217,7 +217,7 @@ function MoreMenuDrawer({
|
|
|
217
217
|
className: `menu-item${selectedKey === menu.key ? " active" : ""}`,
|
|
218
218
|
onClick: () => handleSelect(menu),
|
|
219
219
|
children: [
|
|
220
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
220
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "folder-open", className: "menu-icon" }),
|
|
221
221
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
222
222
|
]
|
|
223
223
|
},
|
|
@@ -129,7 +129,7 @@ function SecondSidebar({
|
|
|
129
129
|
className: `menu-item parent${expandedKeys.includes(menu.key) ? " expanded" : ""}`,
|
|
130
130
|
onClick: () => toggleExpand(menu.key),
|
|
131
131
|
children: [
|
|
132
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
132
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "home", className: "menu-icon" }),
|
|
133
133
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label }),
|
|
134
134
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
135
|
import_shared_components.SvgIcon,
|
|
@@ -179,7 +179,7 @@ function SecondSidebar({
|
|
|
179
179
|
className: `menu-item single${activeKey === menu.key ? " active" : ""}`,
|
|
180
180
|
onClick: () => onMenuClick(menu),
|
|
181
181
|
children: [
|
|
182
|
-
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, {
|
|
182
|
+
menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: menu.icon || "home", className: "menu-icon" }),
|
|
183
183
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label }),
|
|
184
184
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
185
185
|
import_shared_components.SvgIcon,
|
|
@@ -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,
|
|
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) => {
|
|
@@ -114,6 +123,7 @@ function CompanySidebar({
|
|
|
114
123
|
if (firstKey && firstKey !== activeFirstMenu) {
|
|
115
124
|
onFirstMenuSelect(firstKey);
|
|
116
125
|
}
|
|
126
|
+
setState((prev) => ({ ...prev, hoverKey: null }));
|
|
117
127
|
onMenuClick(menu);
|
|
118
128
|
},
|
|
119
129
|
[leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]
|
|
@@ -132,7 +142,7 @@ function CompanySidebar({
|
|
|
132
142
|
if (hideSidebarTimerRef.current)
|
|
133
143
|
clearTimeout(hideSidebarTimerRef.current);
|
|
134
144
|
hideSidebarTimerRef.current = setTimeout(() => {
|
|
135
|
-
setState((prev) => ({ ...prev, secondSidebarHovered: false }));
|
|
145
|
+
setState((prev) => ({ ...prev, secondSidebarHovered: false, hoverKey: null }));
|
|
136
146
|
}, 100);
|
|
137
147
|
}, [hideSidebarTimerRef]);
|
|
138
148
|
const cancelHideSidebar = (0, import_react.useCallback)(() => {
|
|
@@ -143,30 +153,56 @@ function CompanySidebar({
|
|
|
143
153
|
setState((prev) => ({ ...prev, secondSidebarHovered: true }));
|
|
144
154
|
}, [hideSidebarTimerRef]);
|
|
145
155
|
const handleBusinessMenuEnter = (0, import_react.useCallback)(
|
|
146
|
-
(
|
|
156
|
+
(menu, e) => {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
const related = e.relatedTarget;
|
|
159
|
+
const fromSecondSidebar = !!((_a = related == null ? void 0 : related.closest) == null ? void 0 : _a.call(related, ".company-sidebar-second"));
|
|
160
|
+
const fromBusinessItem = !!((_b = related == null ? void 0 : related.closest) == null ? void 0 : _b.call(related, ".business-menu-item"));
|
|
161
|
+
const isBusinessMenu = leafToFirstKeyMap.has(menu.key);
|
|
162
|
+
setState((prev) => {
|
|
163
|
+
if (secondSidebarFixed && (!isBusinessMenu || !fromSecondSidebar && !(fromBusinessItem && prev.hoverKey))) {
|
|
164
|
+
return prev;
|
|
165
|
+
}
|
|
166
|
+
if (hideSidebarTimerRef.current) {
|
|
167
|
+
clearTimeout(hideSidebarTimerRef.current);
|
|
168
|
+
hideSidebarTimerRef.current = null;
|
|
169
|
+
}
|
|
170
|
+
return { ...prev, hoverKey: menu.key, secondSidebarHovered: true };
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
[secondSidebarFixed, hideSidebarTimerRef, leafToFirstKeyMap]
|
|
174
|
+
);
|
|
175
|
+
const handleBusinessMenuLeave = (0, import_react.useCallback)(
|
|
176
|
+
(e) => {
|
|
177
|
+
var _a, _b;
|
|
147
178
|
if (!secondSidebarFixed) {
|
|
148
|
-
|
|
179
|
+
delayHideSidebar();
|
|
180
|
+
return;
|
|
149
181
|
}
|
|
182
|
+
const related = e.relatedTarget;
|
|
183
|
+
const toSecondSidebar = !!((_a = related == null ? void 0 : related.closest) == null ? void 0 : _a.call(related, ".company-sidebar-second"));
|
|
184
|
+
const toBusinessItem = !!((_b = related == null ? void 0 : related.closest) == null ? void 0 : _b.call(related, ".business-menu-item"));
|
|
185
|
+
if (toSecondSidebar || toBusinessItem) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
setState((prev) => ({ ...prev, hoverKey: null, secondSidebarHovered: false }));
|
|
150
189
|
},
|
|
151
|
-
[secondSidebarFixed,
|
|
190
|
+
[secondSidebarFixed, delayHideSidebar]
|
|
152
191
|
);
|
|
153
|
-
const handleBusinessMenuLeave = (0, import_react.useCallback)(() => {
|
|
154
|
-
delayHideSidebar();
|
|
155
|
-
}, [delayHideSidebar]);
|
|
156
192
|
const handleFirstMenuClick = (0, import_react.useCallback)(
|
|
157
193
|
(menu) => {
|
|
158
194
|
const firstKey = leafToFirstKeyMap.get(menu.key) || menu.key;
|
|
159
195
|
if (firstKey !== activeFirstMenu) {
|
|
160
196
|
onFirstMenuSelect(firstKey);
|
|
161
197
|
}
|
|
198
|
+
setState((prev) => ({ ...prev, hoverKey: null }));
|
|
162
199
|
onMenuClick(menu);
|
|
163
200
|
},
|
|
164
201
|
[leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]
|
|
165
202
|
);
|
|
166
203
|
const handleMoreSelect = (0, import_react.useCallback)(
|
|
167
|
-
(menu
|
|
168
|
-
|
|
169
|
-
handleLeafMenuClick(target);
|
|
204
|
+
(menu) => {
|
|
205
|
+
handleLeafMenuClick(menu);
|
|
170
206
|
setState((prev) => ({ ...prev, moreDrawerOpen: false }));
|
|
171
207
|
},
|
|
172
208
|
[handleLeafMenuClick]
|
|
@@ -218,11 +254,18 @@ function CompanySidebar({
|
|
|
218
254
|
activeKey,
|
|
219
255
|
activeFirstMenu,
|
|
220
256
|
visibleMenuCount,
|
|
257
|
+
bottomExtra,
|
|
221
258
|
domainPopoverOpen: state.domainPopoverOpen,
|
|
222
259
|
adminPopoverOpen: state.adminPopoverOpen,
|
|
223
|
-
onDomainPopoverOpenChange: (open) =>
|
|
260
|
+
onDomainPopoverOpenChange: (open) => {
|
|
261
|
+
setState((prev) => ({ ...prev, domainPopoverOpen: open }));
|
|
262
|
+
onDomainPopoverOpenChange == null ? void 0 : onDomainPopoverOpenChange(open);
|
|
263
|
+
},
|
|
224
264
|
onAdminPopoverOpenChange: (open) => setState((prev) => ({ ...prev, adminPopoverOpen: open })),
|
|
225
|
-
onDomainChange
|
|
265
|
+
onDomainChange: (d) => {
|
|
266
|
+
setState((prev) => ({ ...prev, domainPopoverOpen: false }));
|
|
267
|
+
onDomainChange(d);
|
|
268
|
+
},
|
|
226
269
|
onMenuClick: handleFirstMenuClick,
|
|
227
270
|
onBusinessMenuEnter: handleBusinessMenuEnter,
|
|
228
271
|
onBusinessMenuLeave: handleBusinessMenuLeave,
|
|
@@ -234,11 +277,11 @@ function CompanySidebar({
|
|
|
234
277
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
235
278
|
import_SecondSidebar.default,
|
|
236
279
|
{
|
|
237
|
-
activeFirstMenu,
|
|
280
|
+
activeFirstMenu: displayFirstMenu,
|
|
238
281
|
activeKey,
|
|
239
282
|
secondSidebarHovered: state.secondSidebarHovered,
|
|
240
283
|
secondSidebarFixed,
|
|
241
|
-
secondMenus:
|
|
284
|
+
secondMenus: displaySecondMenus,
|
|
242
285
|
favorites: state.localFavorites,
|
|
243
286
|
expandedKeys: state.localExpandedKeys,
|
|
244
287
|
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 ==========
|
|
@@ -373,6 +409,11 @@
|
|
|
373
409
|
color: var(--company-color-primary, #f95914);
|
|
374
410
|
font-weight: 500;
|
|
375
411
|
}
|
|
412
|
+
|
|
413
|
+
/* 勾选图标跟随主题色(check-one 为 stroke="currentColor") */
|
|
414
|
+
svg {
|
|
415
|
+
color: var(--company-color-primary, #f95914);
|
|
416
|
+
}
|
|
376
417
|
}
|
|
377
418
|
}
|
|
378
419
|
|
|
@@ -902,6 +943,7 @@
|
|
|
902
943
|
gap: 10px;
|
|
903
944
|
align-self: stretch;
|
|
904
945
|
z-index: 0;
|
|
946
|
+
cursor: pointer;
|
|
905
947
|
|
|
906
948
|
.title-bar {
|
|
907
949
|
width: 4px;
|
|
@@ -48,15 +48,16 @@ var KEYWORD_ICON_MAP = [
|
|
|
48
48
|
{ keywords: ["搜索", "查询", "检索", "search"], icon: "search" }
|
|
49
49
|
];
|
|
50
50
|
var DEFAULT_ICON = "folder-open";
|
|
51
|
+
var warnedIcons = /* @__PURE__ */ new Set();
|
|
51
52
|
function getMenuIcon(menu) {
|
|
52
53
|
if (menu.icon) {
|
|
53
|
-
if (VALID_ICONS.has(menu.icon))
|
|
54
|
-
|
|
55
|
-
if (process.env.NODE_ENV !== "production") {
|
|
54
|
+
if (!VALID_ICONS.has(menu.icon) && process.env.NODE_ENV !== "production" && !warnedIcons.has(menu.icon)) {
|
|
55
|
+
warnedIcons.add(menu.icon);
|
|
56
56
|
console.warn(
|
|
57
|
-
`[CompanySidebar] 菜单 "${menu.label}" 的 icon "${menu.icon}"
|
|
57
|
+
`[CompanySidebar] 菜单 "${menu.label}" 的 icon "${menu.icon}" 不在内置图标集中,将按 Sprite symbol 渲染(请确认页面已加载对应 sprite)。内置图标键可查阅文档站 /icon-library 精选集。`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
+
return menu.icon;
|
|
60
61
|
}
|
|
61
62
|
const label = (menu.label || "").toLowerCase();
|
|
62
63
|
for (const { keywords, icon } of KEYWORD_ICON_MAP) {
|
|
@@ -66,6 +66,8 @@ var iconMap = {
|
|
|
66
66
|
setting: "setting"
|
|
67
67
|
};
|
|
68
68
|
function getIconName(icon) {
|
|
69
|
+
if (import_icons.iconNames.includes(icon))
|
|
70
|
+
return icon;
|
|
69
71
|
return iconMap[icon] || icon;
|
|
70
72
|
}
|
|
71
73
|
function IconSelect(props) {
|
|
@@ -159,7 +161,7 @@ function IconSelectInner({
|
|
|
159
161
|
},
|
|
160
162
|
[onChange]
|
|
161
163
|
);
|
|
162
|
-
|
|
164
|
+
const loadSvgScript = (0, import_react.useCallback)(async (url) => {
|
|
163
165
|
if (loadedScriptsRef.current.has(url))
|
|
164
166
|
return true;
|
|
165
167
|
try {
|
|
@@ -180,7 +182,16 @@ function IconSelectInner({
|
|
|
180
182
|
} catch {
|
|
181
183
|
return false;
|
|
182
184
|
}
|
|
183
|
-
}
|
|
185
|
+
}, []);
|
|
186
|
+
(0, import_react.useEffect)(() => {
|
|
187
|
+
const url = newIconSvgUrl.trim();
|
|
188
|
+
if (!url)
|
|
189
|
+
return;
|
|
190
|
+
const timer = setTimeout(() => {
|
|
191
|
+
void loadSvgScript(url);
|
|
192
|
+
}, 500);
|
|
193
|
+
return () => clearTimeout(timer);
|
|
194
|
+
}, [newIconSvgUrl, loadSvgScript]);
|
|
184
195
|
async function handleAddIcon() {
|
|
185
196
|
if (!newIconLabel.trim()) {
|
|
186
197
|
import_basic_components.CompanyMessage.error("请输入图标名称");
|
|
@@ -441,7 +441,7 @@ function AiAssistantAside(_ref) {
|
|
|
441
441
|
* - 两种内容模式:pages 配置式(key 与菜单联动)或 children 兜底(直接放业务模板)
|
|
442
442
|
*/
|
|
443
443
|
export default function AdminLayoutTemplate(_ref2) {
|
|
444
|
-
var
|
|
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$
|
|
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$
|
|
783
|
+
var nextSecondMenus = (_businessMenus$find$c = (_businessMenus$find = businessMenus.find(function (m) {
|
|
789
784
|
return m.key === key;
|
|
790
|
-
})) === null || _businessMenus$
|
|
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,
|