@donglegeyu/company-ui 2.8.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/CompanySidebar/CustomNavPanel.js +5 -3
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.d.ts +2 -2
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.js +19 -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.js +42 -11
- package/dist/cjs/template-components/CompanySidebar/index.scss +6 -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/CompanySidebar/CustomNavPanel.js +6 -4
- package/dist/es/template-components/CompanySidebar/FirstSidebar.d.ts +2 -2
- package/dist/es/template-components/CompanySidebar/FirstSidebar.js +18 -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.js +70 -14
- package/dist/es/template-components/CompanySidebar/index.scss +6 -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
|
@@ -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
|
]
|
|
@@ -21,8 +21,8 @@ export interface FirstSidebarProps {
|
|
|
21
21
|
onAdminPopoverOpenChange: (open: boolean) => void;
|
|
22
22
|
onDomainChange: (domain: SidebarDomain) => void;
|
|
23
23
|
onMenuClick: (menu: SidebarMenuItem) => void;
|
|
24
|
-
onBusinessMenuEnter: (menu: SidebarMenuItem) => void;
|
|
25
|
-
onBusinessMenuLeave: () => void;
|
|
24
|
+
onBusinessMenuEnter: (menu: SidebarMenuItem, e: React.MouseEvent) => void;
|
|
25
|
+
onBusinessMenuLeave: (e: React.MouseEvent) => void;
|
|
26
26
|
onOpenMore: () => void;
|
|
27
27
|
onThemeSettings?: () => void;
|
|
28
28
|
onLogout?: () => void;
|
|
@@ -95,10 +95,10 @@ function FirstSidebar({
|
|
|
95
95
|
{
|
|
96
96
|
className: `menu-item menu-item--normal${activeKey === menu.key ? " active" : ""}`,
|
|
97
97
|
onClick: () => onMenuClick(menu),
|
|
98
|
-
onMouseEnter: () => menu.key === "favorites" && onBusinessMenuEnter(menu),
|
|
99
|
-
onMouseLeave: () => menu.key === "favorites" && onBusinessMenuLeave(),
|
|
98
|
+
onMouseEnter: (e) => menu.key === "favorites" && onBusinessMenuEnter(menu, e),
|
|
99
|
+
onMouseLeave: (e) => menu.key === "favorites" && onBusinessMenuLeave(e),
|
|
100
100
|
children: [
|
|
101
|
-
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" }),
|
|
102
102
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
103
103
|
]
|
|
104
104
|
},
|
|
@@ -112,24 +112,32 @@ function FirstSidebar({
|
|
|
112
112
|
{
|
|
113
113
|
className: `business-menu-item${activeFirstMenu === menu.key || activeKey === menu.key ? " active" : ""}`,
|
|
114
114
|
onClick: () => onMenuClick(menu),
|
|
115
|
-
onMouseEnter: () => onBusinessMenuEnter(menu),
|
|
116
|
-
onMouseLeave: onBusinessMenuLeave,
|
|
115
|
+
onMouseEnter: (e) => onBusinessMenuEnter(menu, e),
|
|
116
|
+
onMouseLeave: (e) => onBusinessMenuLeave(e),
|
|
117
117
|
children: [
|
|
118
|
-
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" }),
|
|
119
119
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
120
120
|
]
|
|
121
121
|
},
|
|
122
122
|
menu.key
|
|
123
123
|
)),
|
|
124
|
-
hasMore && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
+
)
|
|
128
136
|
] }),
|
|
129
137
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "system-menu-bottom", children: [
|
|
130
138
|
(systemBottomMenus || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "nav-divider" }),
|
|
131
139
|
(systemBottomMenus || []).map((menu) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "system-bottom-item", onClick: () => onMenuClick(menu), children: [
|
|
132
|
-
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" }),
|
|
133
141
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
|
|
134
142
|
] }, menu.key)),
|
|
135
143
|
bottomExtra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bottom-extra", children: bottomExtra }),
|
|
@@ -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,
|
|
@@ -123,6 +123,7 @@ function CompanySidebar({
|
|
|
123
123
|
if (firstKey && firstKey !== activeFirstMenu) {
|
|
124
124
|
onFirstMenuSelect(firstKey);
|
|
125
125
|
}
|
|
126
|
+
setState((prev) => ({ ...prev, hoverKey: null }));
|
|
126
127
|
onMenuClick(menu);
|
|
127
128
|
},
|
|
128
129
|
[leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]
|
|
@@ -152,29 +153,56 @@ function CompanySidebar({
|
|
|
152
153
|
setState((prev) => ({ ...prev, secondSidebarHovered: true }));
|
|
153
154
|
}, [hideSidebarTimerRef]);
|
|
154
155
|
const handleBusinessMenuEnter = (0, import_react.useCallback)(
|
|
155
|
-
(menu) => {
|
|
156
|
-
|
|
157
|
-
|
|
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
|
+
});
|
|
158
172
|
},
|
|
159
|
-
[
|
|
173
|
+
[secondSidebarFixed, hideSidebarTimerRef, leafToFirstKeyMap]
|
|
174
|
+
);
|
|
175
|
+
const handleBusinessMenuLeave = (0, import_react.useCallback)(
|
|
176
|
+
(e) => {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
if (!secondSidebarFixed) {
|
|
179
|
+
delayHideSidebar();
|
|
180
|
+
return;
|
|
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 }));
|
|
189
|
+
},
|
|
190
|
+
[secondSidebarFixed, delayHideSidebar]
|
|
160
191
|
);
|
|
161
|
-
const handleBusinessMenuLeave = (0, import_react.useCallback)(() => {
|
|
162
|
-
delayHideSidebar();
|
|
163
|
-
}, [delayHideSidebar]);
|
|
164
192
|
const handleFirstMenuClick = (0, import_react.useCallback)(
|
|
165
193
|
(menu) => {
|
|
166
194
|
const firstKey = leafToFirstKeyMap.get(menu.key) || menu.key;
|
|
167
195
|
if (firstKey !== activeFirstMenu) {
|
|
168
196
|
onFirstMenuSelect(firstKey);
|
|
169
197
|
}
|
|
198
|
+
setState((prev) => ({ ...prev, hoverKey: null }));
|
|
170
199
|
onMenuClick(menu);
|
|
171
200
|
},
|
|
172
201
|
[leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]
|
|
173
202
|
);
|
|
174
203
|
const handleMoreSelect = (0, import_react.useCallback)(
|
|
175
|
-
(menu
|
|
176
|
-
|
|
177
|
-
handleLeafMenuClick(target);
|
|
204
|
+
(menu) => {
|
|
205
|
+
handleLeafMenuClick(menu);
|
|
178
206
|
setState((prev) => ({ ...prev, moreDrawerOpen: false }));
|
|
179
207
|
},
|
|
180
208
|
[handleLeafMenuClick]
|
|
@@ -234,7 +262,10 @@ function CompanySidebar({
|
|
|
234
262
|
onDomainPopoverOpenChange == null ? void 0 : onDomainPopoverOpenChange(open);
|
|
235
263
|
},
|
|
236
264
|
onAdminPopoverOpenChange: (open) => setState((prev) => ({ ...prev, adminPopoverOpen: open })),
|
|
237
|
-
onDomainChange
|
|
265
|
+
onDomainChange: (d) => {
|
|
266
|
+
setState((prev) => ({ ...prev, domainPopoverOpen: false }));
|
|
267
|
+
onDomainChange(d);
|
|
268
|
+
},
|
|
238
269
|
onMenuClick: handleFirstMenuClick,
|
|
239
270
|
onBusinessMenuEnter: handleBusinessMenuEnter,
|
|
240
271
|
onBusinessMenuLeave: handleBusinessMenuLeave,
|
|
@@ -409,6 +409,11 @@
|
|
|
409
409
|
color: var(--company-color-primary, #f95914);
|
|
410
410
|
font-weight: 500;
|
|
411
411
|
}
|
|
412
|
+
|
|
413
|
+
/* 勾选图标跟随主题色(check-one 为 stroke="currentColor") */
|
|
414
|
+
svg {
|
|
415
|
+
color: var(--company-color-primary, #f95914);
|
|
416
|
+
}
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
419
|
|
|
@@ -938,6 +943,7 @@
|
|
|
938
943
|
gap: 10px;
|
|
939
944
|
align-self: stretch;
|
|
940
945
|
z-index: 0;
|
|
946
|
+
cursor: pointer;
|
|
941
947
|
|
|
942
948
|
.title-bar {
|
|
943
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("请输入图标名称");
|
|
@@ -53,7 +53,8 @@ export default function CustomNavPanel(_ref) {
|
|
|
53
53
|
selectedItems.push({
|
|
54
54
|
key: menu.key,
|
|
55
55
|
label: menu.label,
|
|
56
|
-
icon: menu.icon || "folder-open"
|
|
56
|
+
icon: menu.icon || "folder-open",
|
|
57
|
+
iconNode: menu.iconNode
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -71,7 +72,8 @@ export default function CustomNavPanel(_ref) {
|
|
|
71
72
|
return {
|
|
72
73
|
key: menu.key,
|
|
73
74
|
label: menu.label,
|
|
74
|
-
icon: menu.icon || "folder-open"
|
|
75
|
+
icon: menu.icon || "folder-open",
|
|
76
|
+
iconNode: menu.iconNode
|
|
75
77
|
};
|
|
76
78
|
});
|
|
77
79
|
setAllMenus([].concat(selectedItems, _toConsumableArray(unselectedItems)));
|
|
@@ -162,8 +164,8 @@ export default function CustomNavPanel(_ref) {
|
|
|
162
164
|
})
|
|
163
165
|
}), /*#__PURE__*/_jsx("div", {
|
|
164
166
|
className: "menu-icon",
|
|
165
|
-
children: /*#__PURE__*/_jsx(SvgIcon, {
|
|
166
|
-
|
|
167
|
+
children: item.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
168
|
+
href: item.icon || "folder-open",
|
|
167
169
|
size: 16
|
|
168
170
|
})
|
|
169
171
|
}), /*#__PURE__*/_jsx("span", {
|
|
@@ -21,8 +21,8 @@ export interface FirstSidebarProps {
|
|
|
21
21
|
onAdminPopoverOpenChange: (open: boolean) => void;
|
|
22
22
|
onDomainChange: (domain: SidebarDomain) => void;
|
|
23
23
|
onMenuClick: (menu: SidebarMenuItem) => void;
|
|
24
|
-
onBusinessMenuEnter: (menu: SidebarMenuItem) => void;
|
|
25
|
-
onBusinessMenuLeave: () => void;
|
|
24
|
+
onBusinessMenuEnter: (menu: SidebarMenuItem, e: React.MouseEvent) => void;
|
|
25
|
+
onBusinessMenuLeave: (e: React.MouseEvent) => void;
|
|
26
26
|
onOpenMore: () => void;
|
|
27
27
|
onThemeSettings?: () => void;
|
|
28
28
|
onLogout?: () => void;
|
|
@@ -101,14 +101,14 @@ export default function FirstSidebar(_ref) {
|
|
|
101
101
|
onClick: function onClick() {
|
|
102
102
|
return onMenuClick(menu);
|
|
103
103
|
},
|
|
104
|
-
onMouseEnter: function onMouseEnter() {
|
|
105
|
-
return menu.key === "favorites" && onBusinessMenuEnter(menu);
|
|
104
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
105
|
+
return menu.key === "favorites" && onBusinessMenuEnter(menu, e);
|
|
106
106
|
},
|
|
107
|
-
onMouseLeave: function onMouseLeave() {
|
|
108
|
-
return menu.key === "favorites" && onBusinessMenuLeave();
|
|
107
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
108
|
+
return menu.key === "favorites" && onBusinessMenuLeave(e);
|
|
109
109
|
},
|
|
110
110
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
111
|
-
|
|
111
|
+
href: menu.icon || "home",
|
|
112
112
|
className: "menu-icon"
|
|
113
113
|
}), /*#__PURE__*/_jsx("span", {
|
|
114
114
|
className: "menu-label",
|
|
@@ -126,12 +126,14 @@ export default function FirstSidebar(_ref) {
|
|
|
126
126
|
onClick: function onClick() {
|
|
127
127
|
return onMenuClick(menu);
|
|
128
128
|
},
|
|
129
|
-
onMouseEnter: function onMouseEnter() {
|
|
130
|
-
return onBusinessMenuEnter(menu);
|
|
129
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
130
|
+
return onBusinessMenuEnter(menu, e);
|
|
131
|
+
},
|
|
132
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
133
|
+
return onBusinessMenuLeave(e);
|
|
131
134
|
},
|
|
132
|
-
onMouseLeave: onBusinessMenuLeave,
|
|
133
135
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
134
|
-
|
|
136
|
+
href: menu.icon || "folder-open",
|
|
135
137
|
className: "menu-icon"
|
|
136
138
|
}), /*#__PURE__*/_jsx("span", {
|
|
137
139
|
className: "menu-label",
|
|
@@ -140,7 +142,12 @@ export default function FirstSidebar(_ref) {
|
|
|
140
142
|
}, menu.key);
|
|
141
143
|
}), hasMore && /*#__PURE__*/_jsxs("div", {
|
|
142
144
|
className: "business-menu-item more-btn",
|
|
143
|
-
onClick: onOpenMore
|
|
145
|
+
onClick: onOpenMore
|
|
146
|
+
// 固定态下鼠标经「更多」移出到内容区时,触发清理恢复选中内容(与业务菜单同链路)
|
|
147
|
+
,
|
|
148
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
149
|
+
return onBusinessMenuLeave(e);
|
|
150
|
+
},
|
|
144
151
|
children: [/*#__PURE__*/_jsx(SvgIcon, {
|
|
145
152
|
name: "more-three",
|
|
146
153
|
className: "menu-icon"
|
|
@@ -160,7 +167,7 @@ export default function FirstSidebar(_ref) {
|
|
|
160
167
|
return onMenuClick(menu);
|
|
161
168
|
},
|
|
162
169
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
163
|
-
|
|
170
|
+
href: menu.icon || "setting",
|
|
164
171
|
className: "menu-icon"
|
|
165
172
|
}), /*#__PURE__*/_jsx("span", {
|
|
166
173
|
className: "menu-label",
|
|
@@ -186,6 +186,9 @@ export default function MoreMenuDrawer(_ref) {
|
|
|
186
186
|
className: "menu-section",
|
|
187
187
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
188
188
|
className: "section-title",
|
|
189
|
+
onClick: function onClick() {
|
|
190
|
+
return handleChildClick(child);
|
|
191
|
+
},
|
|
189
192
|
children: [/*#__PURE__*/_jsx("div", {
|
|
190
193
|
className: "title-bar"
|
|
191
194
|
}), /*#__PURE__*/_jsx("span", {
|
|
@@ -225,8 +228,10 @@ export default function MoreMenuDrawer(_ref) {
|
|
|
225
228
|
value: inputValue,
|
|
226
229
|
onChange: handleSearchChange,
|
|
227
230
|
onCompositionStart: handleCompositionStart,
|
|
228
|
-
onCompositionEnd: handleCompositionEnd
|
|
229
|
-
|
|
231
|
+
onCompositionEnd: handleCompositionEnd
|
|
232
|
+
// 自动聚焦仅高亮输入框;下拉面板需用户主动点击输入框才显示,避免打开抽屉即弹出全量菜单
|
|
233
|
+
,
|
|
234
|
+
onClick: function onClick() {
|
|
230
235
|
return setSearchPanelOpen(true);
|
|
231
236
|
},
|
|
232
237
|
onBlur: function onBlur() {
|
|
@@ -279,7 +284,7 @@ export default function MoreMenuDrawer(_ref) {
|
|
|
279
284
|
return handleSelect(menu);
|
|
280
285
|
},
|
|
281
286
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
282
|
-
|
|
287
|
+
href: menu.icon || "folder-open",
|
|
283
288
|
className: "menu-icon"
|
|
284
289
|
}), /*#__PURE__*/_jsx("span", {
|
|
285
290
|
className: "menu-label",
|
|
@@ -136,7 +136,7 @@ export default function SecondSidebar(_ref) {
|
|
|
136
136
|
return toggleExpand(menu.key);
|
|
137
137
|
},
|
|
138
138
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
139
|
-
|
|
139
|
+
href: menu.icon || "home",
|
|
140
140
|
className: "menu-icon"
|
|
141
141
|
}), /*#__PURE__*/_jsx("span", {
|
|
142
142
|
className: "menu-label",
|
|
@@ -179,7 +179,7 @@ export default function SecondSidebar(_ref) {
|
|
|
179
179
|
return onMenuClick(menu);
|
|
180
180
|
},
|
|
181
181
|
children: [menu.iconNode || /*#__PURE__*/_jsx(SvgIcon, {
|
|
182
|
-
|
|
182
|
+
href: menu.icon || "home",
|
|
183
183
|
className: "menu-icon"
|
|
184
184
|
}), /*#__PURE__*/_jsx("span", {
|
|
185
185
|
className: "menu-label",
|
|
@@ -53,7 +53,7 @@ export default function CompanySidebar(_ref) {
|
|
|
53
53
|
style = _ref.style,
|
|
54
54
|
domains = _ref.domains,
|
|
55
55
|
currentDomainId = _ref.currentDomainId,
|
|
56
|
-
|
|
56
|
+
_onDomainChange = _ref.onDomainChange,
|
|
57
57
|
userInfo = _ref.userInfo,
|
|
58
58
|
_ref$logo = _ref.logo,
|
|
59
59
|
logo = _ref$logo === void 0 ? DEFAULT_LOGO : _ref$logo,
|
|
@@ -124,6 +124,12 @@ export default function CompanySidebar(_ref) {
|
|
|
124
124
|
if (firstKey && firstKey !== activeFirstMenu) {
|
|
125
125
|
onFirstMenuSelect(firstKey);
|
|
126
126
|
}
|
|
127
|
+
// 点击是明确导航意图:清掉 hover 预览,防止 hoverKey 残留导致二级栏内容与选中项不一致
|
|
128
|
+
setState(function (prev) {
|
|
129
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
130
|
+
hoverKey: null
|
|
131
|
+
});
|
|
132
|
+
});
|
|
127
133
|
onMenuClick(menu);
|
|
128
134
|
}, [leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]);
|
|
129
135
|
useEffect(function () {
|
|
@@ -168,29 +174,71 @@ export default function CompanySidebar(_ref) {
|
|
|
168
174
|
});
|
|
169
175
|
});
|
|
170
176
|
}, [hideSidebarTimerRef]);
|
|
171
|
-
var handleBusinessMenuEnter = useCallback(function (menu) {
|
|
172
|
-
|
|
177
|
+
var handleBusinessMenuEnter = useCallback(function (menu, e) {
|
|
178
|
+
var _related$closest, _related$closest2;
|
|
179
|
+
// 固定态下用 relatedTarget 精确判断鼠标来源(不依赖持久 hovered 状态,避免泄漏误判):
|
|
180
|
+
// 来自二级栏 → 预览;来自一级栏业务菜单且预览中 → 连续滑动保持预览;
|
|
181
|
+
// 来自内容区/顶部菜单等 → 不预切换,二级栏内容保持选中项
|
|
182
|
+
var related = e.relatedTarget;
|
|
183
|
+
var fromSecondSidebar = !!(related !== null && related !== void 0 && (_related$closest = related.closest) !== null && _related$closest !== void 0 && _related$closest.call(related, ".company-sidebar-second"));
|
|
184
|
+
var fromBusinessItem = !!(related !== null && related !== void 0 && (_related$closest2 = related.closest) !== null && _related$closest2 !== void 0 && _related$closest2.call(related, ".business-menu-item"));
|
|
185
|
+
var isBusinessMenu = leafToFirstKeyMap.has(menu.key);
|
|
186
|
+
setState(function (prev) {
|
|
187
|
+
if (secondSidebarFixed && (!isBusinessMenu || !fromSecondSidebar && !(fromBusinessItem && prev.hoverKey))) {
|
|
188
|
+
return prev;
|
|
189
|
+
}
|
|
190
|
+
// 预览生效:取消挂起的隐藏/清理定时器,避免预览中被 100ms 定时器清掉(幂等,StrictMode 双调用安全)
|
|
191
|
+
if (hideSidebarTimerRef.current) {
|
|
192
|
+
clearTimeout(hideSidebarTimerRef.current);
|
|
193
|
+
hideSidebarTimerRef.current = null;
|
|
194
|
+
}
|
|
195
|
+
// hover 预切换:仅更新内部 hoverKey,不改 activeFirstMenu(不污染业务 store)
|
|
196
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
197
|
+
hoverKey: menu.key,
|
|
198
|
+
secondSidebarHovered: true
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}, [secondSidebarFixed, hideSidebarTimerRef, leafToFirstKeyMap]);
|
|
202
|
+
var handleBusinessMenuLeave = useCallback(function (e) {
|
|
203
|
+
var _related$closest3, _related$closest4;
|
|
204
|
+
if (!secondSidebarFixed) {
|
|
205
|
+
// 非固定态:延迟隐藏浮层,保留 100ms 缓冲供鼠标移入二级栏
|
|
206
|
+
delayHideSidebar();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// 固定态:按鼠标去向决定预览去留——
|
|
210
|
+
// 移入二级栏(预览内容待点击)或一级栏内其他业务菜单(连续滑动)→ 保留;
|
|
211
|
+
// 移向内容区/顶部菜单等 → 立即恢复选中内容
|
|
212
|
+
var related = e.relatedTarget;
|
|
213
|
+
var toSecondSidebar = !!(related !== null && related !== void 0 && (_related$closest3 = related.closest) !== null && _related$closest3 !== void 0 && _related$closest3.call(related, ".company-sidebar-second"));
|
|
214
|
+
var toBusinessItem = !!(related !== null && related !== void 0 && (_related$closest4 = related.closest) !== null && _related$closest4 !== void 0 && _related$closest4.call(related, ".business-menu-item"));
|
|
215
|
+
if (toSecondSidebar || toBusinessItem) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
173
218
|
setState(function (prev) {
|
|
174
219
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
175
|
-
hoverKey:
|
|
220
|
+
hoverKey: null,
|
|
221
|
+
secondSidebarHovered: false
|
|
176
222
|
});
|
|
177
223
|
});
|
|
178
|
-
|
|
179
|
-
}, [cancelHideSidebar]);
|
|
180
|
-
var handleBusinessMenuLeave = useCallback(function () {
|
|
181
|
-
delayHideSidebar();
|
|
182
|
-
}, [delayHideSidebar]);
|
|
224
|
+
}, [secondSidebarFixed, delayHideSidebar]);
|
|
183
225
|
var handleFirstMenuClick = useCallback(function (menu) {
|
|
184
226
|
var firstKey = leafToFirstKeyMap.get(menu.key) || menu.key;
|
|
185
227
|
if (firstKey !== activeFirstMenu) {
|
|
186
228
|
onFirstMenuSelect(firstKey);
|
|
187
229
|
}
|
|
230
|
+
// 点击是明确导航意图:清掉 hover 预览,二级栏立即显示点击项内容
|
|
231
|
+
setState(function (prev) {
|
|
232
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
233
|
+
hoverKey: null
|
|
234
|
+
});
|
|
235
|
+
});
|
|
188
236
|
onMenuClick(menu);
|
|
189
237
|
}, [leafToFirstKeyMap, activeFirstMenu, onFirstMenuSelect, onMenuClick]);
|
|
190
|
-
var handleMoreSelect = useCallback(function (menu
|
|
191
|
-
|
|
192
|
-
//
|
|
193
|
-
handleLeafMenuClick(
|
|
238
|
+
var handleMoreSelect = useCallback(function (menu) {
|
|
239
|
+
// 抽屉 onSelect 第一参数即被点击项(二级叶子 / 三级叶子 / 二级分组标题),直接以其为导航目标;
|
|
240
|
+
// 经反查表同步所属一级菜单高亮,保证各级点击均符合导航契约
|
|
241
|
+
handleLeafMenuClick(menu);
|
|
194
242
|
setState(function (prev) {
|
|
195
243
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
196
244
|
moreDrawerOpen: false
|
|
@@ -263,7 +311,15 @@ export default function CompanySidebar(_ref) {
|
|
|
263
311
|
});
|
|
264
312
|
});
|
|
265
313
|
},
|
|
266
|
-
onDomainChange: onDomainChange
|
|
314
|
+
onDomainChange: function onDomainChange(d) {
|
|
315
|
+
// 点击选择域是明确意图:关闭空间弹层再透传业务回调
|
|
316
|
+
setState(function (prev) {
|
|
317
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
318
|
+
domainPopoverOpen: false
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
_onDomainChange(d);
|
|
322
|
+
},
|
|
267
323
|
onMenuClick: handleFirstMenuClick,
|
|
268
324
|
onBusinessMenuEnter: handleBusinessMenuEnter,
|
|
269
325
|
onBusinessMenuLeave: handleBusinessMenuLeave,
|
|
@@ -409,6 +409,11 @@
|
|
|
409
409
|
color: var(--company-color-primary, #f95914);
|
|
410
410
|
font-weight: 500;
|
|
411
411
|
}
|
|
412
|
+
|
|
413
|
+
/* 勾选图标跟随主题色(check-one 为 stroke="currentColor") */
|
|
414
|
+
svg {
|
|
415
|
+
color: var(--company-color-primary, #f95914);
|
|
416
|
+
}
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
419
|
|
|
@@ -938,6 +943,7 @@
|
|
|
938
943
|
gap: 10px;
|
|
939
944
|
align-self: stretch;
|
|
940
945
|
z-index: 0;
|
|
946
|
+
cursor: pointer;
|
|
941
947
|
|
|
942
948
|
.title-bar {
|
|
943
949
|
width: 4px;
|
|
@@ -68,13 +68,20 @@ var KEYWORD_ICON_MAP = [{
|
|
|
68
68
|
icon: "search"
|
|
69
69
|
}];
|
|
70
70
|
var DEFAULT_ICON = "folder-open";
|
|
71
|
+
|
|
72
|
+
// dev 提醒去重:自定义 sprite id 属于合法值,每个值只警告一次,避免每次渲染刷屏
|
|
73
|
+
var warnedIcons = new Set();
|
|
71
74
|
export function getMenuIcon(menu) {
|
|
75
|
+
// icon 为显式配置:与 IconSelect 图标池对齐(内置精选键或 Sprite symbol id),未命中内置表也透传,
|
|
76
|
+
// 渲染层用 <SvgIcon href> 让 Sprite symbol id 正常显示(旧数据图标名由业务侧负责翻译)
|
|
72
77
|
if (menu.icon) {
|
|
73
|
-
if (VALID_ICONS.has(menu.icon)
|
|
74
|
-
|
|
75
|
-
console.warn("[CompanySidebar] \u83DC\u5355 \"".concat(menu.label, "\" \u7684 icon \"").concat(menu.icon, "\" \u4E0D\u5728\u5185\u7F6E\u56FE\u6807\u96C6\u4E2D\uFF0C\
|
|
78
|
+
if (!VALID_ICONS.has(menu.icon) && process.env.NODE_ENV !== "production" && !warnedIcons.has(menu.icon)) {
|
|
79
|
+
warnedIcons.add(menu.icon);
|
|
80
|
+
console.warn("[CompanySidebar] \u83DC\u5355 \"".concat(menu.label, "\" \u7684 icon \"").concat(menu.icon, "\" \u4E0D\u5728\u5185\u7F6E\u56FE\u6807\u96C6\u4E2D\uFF0C\u5C06\u6309 Sprite symbol \u6E32\u67D3\uFF08\u8BF7\u786E\u8BA4\u9875\u9762\u5DF2\u52A0\u8F7D\u5BF9\u5E94 sprite\uFF09\u3002\u5185\u7F6E\u56FE\u6807\u952E\u53EF\u67E5\u9605\u6587\u6863\u7AD9 /icon-library \u7CBE\u9009\u96C6\u3002"));
|
|
76
81
|
}
|
|
82
|
+
return menu.icon;
|
|
77
83
|
}
|
|
84
|
+
// 未配置 icon:按 label 关键词自动匹配
|
|
78
85
|
var label = (menu.label || "").toLowerCase();
|
|
79
86
|
var _iterator = _createForOfIteratorHelper(KEYWORD_ICON_MAP),
|
|
80
87
|
_step;
|
|
@@ -66,6 +66,9 @@ var iconMap = {
|
|
|
66
66
|
setting: "setting"
|
|
67
67
|
};
|
|
68
68
|
function getIconName(icon) {
|
|
69
|
+
// 精选集原生键原样渲染(iconMap 旧名翻译不得误伤同名键,如 search/tool/clipboard/user),
|
|
70
|
+
// 仅对不在精选集的值(antd 旧名、自定义 sprite id)做翻译/透传
|
|
71
|
+
if (iconNames.includes(icon)) return icon;
|
|
69
72
|
return iconMap[icon] || icon;
|
|
70
73
|
}
|
|
71
74
|
export default function IconSelect(props) {
|
|
@@ -195,12 +198,12 @@ function IconSelectInner(_ref) {
|
|
|
195
198
|
return _saveIconConfig.apply(this, arguments);
|
|
196
199
|
}
|
|
197
200
|
function _saveIconConfig() {
|
|
198
|
-
_saveIconConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
199
|
-
return _regeneratorRuntime().wrap(function
|
|
200
|
-
while (1) switch (
|
|
201
|
+
_saveIconConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
|
|
202
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
203
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
201
204
|
case 0:
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
_context3.prev = 0;
|
|
206
|
+
_context3.next = 3;
|
|
204
207
|
return fetch(iconEndpoint, {
|
|
205
208
|
method: "PUT",
|
|
206
209
|
headers: {
|
|
@@ -209,17 +212,17 @@ function IconSelectInner(_ref) {
|
|
|
209
212
|
body: JSON.stringify(data)
|
|
210
213
|
});
|
|
211
214
|
case 3:
|
|
212
|
-
|
|
215
|
+
_context3.next = 8;
|
|
213
216
|
break;
|
|
214
217
|
case 5:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
console.error("[IconSelect] saveIconConfig failed:",
|
|
218
|
+
_context3.prev = 5;
|
|
219
|
+
_context3.t0 = _context3["catch"](0);
|
|
220
|
+
console.error("[IconSelect] saveIconConfig failed:", _context3.t0);
|
|
218
221
|
case 8:
|
|
219
222
|
case "end":
|
|
220
|
-
return
|
|
223
|
+
return _context3.stop();
|
|
221
224
|
}
|
|
222
|
-
},
|
|
225
|
+
}, _callee3, null, [[0, 5]]);
|
|
223
226
|
}));
|
|
224
227
|
return _saveIconConfig.apply(this, arguments);
|
|
225
228
|
}
|
|
@@ -237,22 +240,19 @@ function IconSelectInner(_ref) {
|
|
|
237
240
|
setSearchText("");
|
|
238
241
|
onChange === null || onChange === void 0 || onChange(val);
|
|
239
242
|
}, [onChange]);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
_loadSvgScript = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url) {
|
|
245
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
246
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
243
|
+
var loadSvgScript = useCallback( /*#__PURE__*/function () {
|
|
244
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
|
|
245
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
246
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
247
247
|
case 0:
|
|
248
248
|
if (!loadedScriptsRef.current.has(url)) {
|
|
249
|
-
|
|
249
|
+
_context2.next = 2;
|
|
250
250
|
break;
|
|
251
251
|
}
|
|
252
|
-
return
|
|
252
|
+
return _context2.abrupt("return", true);
|
|
253
253
|
case 2:
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
_context2.prev = 2;
|
|
255
|
+
_context2.next = 5;
|
|
256
256
|
return new Promise(function (resolve, reject) {
|
|
257
257
|
var existing = document.querySelector("script[src=\"".concat(url, "\"]"));
|
|
258
258
|
if (existing) {
|
|
@@ -271,19 +271,34 @@ function IconSelectInner(_ref) {
|
|
|
271
271
|
});
|
|
272
272
|
case 5:
|
|
273
273
|
loadedScriptsRef.current.add(url);
|
|
274
|
-
return
|
|
274
|
+
return _context2.abrupt("return", true);
|
|
275
275
|
case 9:
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
276
|
+
_context2.prev = 9;
|
|
277
|
+
_context2.t0 = _context2["catch"](2);
|
|
278
|
+
return _context2.abrupt("return", false);
|
|
279
279
|
case 12:
|
|
280
280
|
case "end":
|
|
281
|
-
return
|
|
281
|
+
return _context2.stop();
|
|
282
282
|
}
|
|
283
|
-
},
|
|
283
|
+
}, _callee2, null, [[2, 9]]);
|
|
284
284
|
}));
|
|
285
|
-
return
|
|
286
|
-
|
|
285
|
+
return function (_x2) {
|
|
286
|
+
return _ref3.apply(this, arguments);
|
|
287
|
+
};
|
|
288
|
+
}(), []);
|
|
289
|
+
|
|
290
|
+
// SVG Symbol URL 输入后自动加载 sprite(防抖):首次添加时抽屉预览即可真实渲染。
|
|
291
|
+
// 否则 sprite 只在点「确定」后才注入,预览恒为空,「预览为空=图标标识不存在」提示反而误导
|
|
292
|
+
useEffect(function () {
|
|
293
|
+
var url = newIconSvgUrl.trim();
|
|
294
|
+
if (!url) return;
|
|
295
|
+
var timer = setTimeout(function () {
|
|
296
|
+
void loadSvgScript(url);
|
|
297
|
+
}, 500);
|
|
298
|
+
return function () {
|
|
299
|
+
return clearTimeout(timer);
|
|
300
|
+
};
|
|
301
|
+
}, [newIconSvgUrl, loadSvgScript]);
|
|
287
302
|
function handleAddIcon() {
|
|
288
303
|
return _handleAddIcon.apply(this, arguments);
|
|
289
304
|
}
|