@donglegeyu/company-ui 2.14.0 → 2.16.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/basic-components/CompanyAccountSwitcher/index.d.ts +34 -0
- package/dist/cjs/basic-components/CompanyAccountSwitcher/index.js +80 -0
- package/dist/cjs/basic-components/CompanyAccountSwitcher/index.scss +128 -0
- package/dist/cjs/basic-components/index.d.ts +1 -0
- package/dist/cjs/basic-components/index.js +2 -0
- package/dist/cjs/sidebar-config.js +4 -0
- package/dist/cjs/template-components/AdminLayoutTemplate/index.d.ts +5 -3
- package/dist/cjs/template-components/AdminLayoutTemplate/index.js +120 -23
- package/dist/cjs/template-components/AdminLayoutTemplate/index.scss +13 -0
- package/dist/cjs/template-components/CompanyMultiTabs/index.d.ts +2 -0
- package/dist/cjs/template-components/CompanyMultiTabs/index.js +164 -3
- package/dist/cjs/template-components/CompanyMultiTabs/index.scss +33 -0
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.d.ts +5 -2
- package/dist/cjs/template-components/CompanySidebar/FirstSidebar.js +41 -6
- package/dist/cjs/template-components/CompanySidebar/index.d.ts +5 -2
- package/dist/cjs/template-components/CompanySidebar/index.js +4 -2
- package/dist/cjs/template-components/CompanySidebar/index.scss +24 -0
- package/dist/es/basic-components/CompanyAccountSwitcher/index.d.ts +34 -0
- package/dist/es/basic-components/CompanyAccountSwitcher/index.js +74 -0
- package/dist/es/basic-components/CompanyAccountSwitcher/index.scss +128 -0
- package/dist/es/basic-components/index.d.ts +1 -0
- package/dist/es/basic-components/index.js +1 -0
- package/dist/es/sidebar-config.js +3 -0
- package/dist/es/template-components/AdminLayoutTemplate/index.d.ts +5 -3
- package/dist/es/template-components/AdminLayoutTemplate/index.js +114 -30
- package/dist/es/template-components/AdminLayoutTemplate/index.scss +13 -0
- package/dist/es/template-components/CompanyMultiTabs/index.d.ts +2 -0
- package/dist/es/template-components/CompanyMultiTabs/index.js +198 -4
- package/dist/es/template-components/CompanyMultiTabs/index.scss +33 -0
- package/dist/es/template-components/CompanySidebar/FirstSidebar.d.ts +5 -2
- package/dist/es/template-components/CompanySidebar/FirstSidebar.js +62 -9
- package/dist/es/template-components/CompanySidebar/index.d.ts +5 -2
- package/dist/es/template-components/CompanySidebar/index.js +4 -2
- package/dist/es/template-components/CompanySidebar/index.scss +24 -0
- package/package.json +1 -1
|
@@ -127,11 +127,37 @@ function CompanyMultiTabsInner(props) {
|
|
|
127
127
|
searchOptions,
|
|
128
128
|
searchPlaceholder,
|
|
129
129
|
onSearchSelect,
|
|
130
|
+
showFullscreen,
|
|
130
131
|
className,
|
|
131
132
|
style
|
|
132
133
|
} = props;
|
|
133
134
|
const { token } = import_antd.theme.useToken();
|
|
134
135
|
const showSearchEntry = Boolean(searchOptions == null ? void 0 : searchOptions.length);
|
|
136
|
+
const [isFullscreen, setIsFullscreen] = (0, import_react.useState)(false);
|
|
137
|
+
const fullscreenSupported = typeof document !== "undefined" && document.fullscreenEnabled;
|
|
138
|
+
(0, import_react.useEffect)(() => {
|
|
139
|
+
if (!showFullscreen)
|
|
140
|
+
return;
|
|
141
|
+
const onFullscreenChange = () => setIsFullscreen(Boolean(document.fullscreenElement));
|
|
142
|
+
document.addEventListener("fullscreenchange", onFullscreenChange);
|
|
143
|
+
return () => document.removeEventListener("fullscreenchange", onFullscreenChange);
|
|
144
|
+
}, [showFullscreen]);
|
|
145
|
+
const toggleFullscreen = (0, import_react.useCallback)(() => {
|
|
146
|
+
if (document.fullscreenElement) {
|
|
147
|
+
void document.exitFullscreen();
|
|
148
|
+
} else {
|
|
149
|
+
void document.documentElement.requestFullscreen();
|
|
150
|
+
}
|
|
151
|
+
}, []);
|
|
152
|
+
const [moreOpen, setMoreOpen] = (0, import_react.useState)(false);
|
|
153
|
+
const hasClosableOthers = tabs.some((t) => t.key !== activeKey && t.closable !== false);
|
|
154
|
+
const closeOtherTabs = (0, import_react.useCallback)(() => {
|
|
155
|
+
setMoreOpen(false);
|
|
156
|
+
tabs.forEach((t) => {
|
|
157
|
+
if (t.key !== activeKey && t.closable !== false)
|
|
158
|
+
onClose == null ? void 0 : onClose(t.key, t);
|
|
159
|
+
});
|
|
160
|
+
}, [tabs, activeKey, onClose]);
|
|
135
161
|
const handleTabClick = (0, import_react.useCallback)(
|
|
136
162
|
(tab) => {
|
|
137
163
|
if (tab.disabled)
|
|
@@ -143,9 +169,15 @@ function CompanyMultiTabsInner(props) {
|
|
|
143
169
|
const handleClose = (0, import_react.useCallback)(
|
|
144
170
|
(e, tab) => {
|
|
145
171
|
e.stopPropagation();
|
|
172
|
+
if (tab.key === activeKey) {
|
|
173
|
+
const idx = tabs.findIndex((t) => t.key === tab.key);
|
|
174
|
+
const neighbor = tabs[idx + 1] ?? tabs[idx - 1];
|
|
175
|
+
if (neighbor)
|
|
176
|
+
onChange == null ? void 0 : onChange(neighbor.key, neighbor);
|
|
177
|
+
}
|
|
146
178
|
onClose == null ? void 0 : onClose(tab.key, tab);
|
|
147
179
|
},
|
|
148
|
-
[onClose]
|
|
180
|
+
[tabs, activeKey, onChange, onClose]
|
|
149
181
|
);
|
|
150
182
|
const renderLabel = (0, import_react.useCallback)(
|
|
151
183
|
(tab) => {
|
|
@@ -155,6 +187,30 @@ function CompanyMultiTabsInner(props) {
|
|
|
155
187
|
},
|
|
156
188
|
[getItemLabel]
|
|
157
189
|
);
|
|
190
|
+
const listRef = (0, import_react.useRef)(null);
|
|
191
|
+
(0, import_react.useEffect)(() => {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
const list = listRef.current;
|
|
194
|
+
if (!list)
|
|
195
|
+
return;
|
|
196
|
+
const activeEl = list.querySelector(".company-multi-tabs__item.is-active");
|
|
197
|
+
if (!activeEl)
|
|
198
|
+
return;
|
|
199
|
+
const listRect = list.getBoundingClientRect();
|
|
200
|
+
const itemRect = activeEl.getBoundingClientRect();
|
|
201
|
+
const RESERVE = 12;
|
|
202
|
+
if (itemRect.left < listRect.left) {
|
|
203
|
+
(_a = list.scrollTo) == null ? void 0 : _a.call(list, {
|
|
204
|
+
left: list.scrollLeft + (itemRect.left - listRect.left) - RESERVE,
|
|
205
|
+
behavior: "smooth"
|
|
206
|
+
});
|
|
207
|
+
} else if (itemRect.right > listRect.right) {
|
|
208
|
+
(_b = list.scrollTo) == null ? void 0 : _b.call(list, {
|
|
209
|
+
left: list.scrollLeft + (itemRect.right - listRect.right) + RESERVE,
|
|
210
|
+
behavior: "smooth"
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, [activeKey, tabs, isHomeActive]);
|
|
158
214
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
159
215
|
"div",
|
|
160
216
|
{
|
|
@@ -192,7 +248,7 @@ function CompanyMultiTabsInner(props) {
|
|
|
192
248
|
onSelect: onSearchSelect
|
|
193
249
|
}
|
|
194
250
|
) : null,
|
|
195
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__list", children: [
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__list", ref: listRef, children: [
|
|
196
252
|
homeTab ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
197
253
|
"div",
|
|
198
254
|
{
|
|
@@ -220,7 +276,112 @@ function CompanyMultiTabsInner(props) {
|
|
|
220
276
|
);
|
|
221
277
|
})
|
|
222
278
|
] }),
|
|
223
|
-
extra ? /* @__PURE__ */ (0, import_jsx_runtime.
|
|
279
|
+
extra || showFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__extra", children: [
|
|
280
|
+
extra,
|
|
281
|
+
showFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
283
|
+
import_basic_components.CompanyDropdown,
|
|
284
|
+
{
|
|
285
|
+
placement: "bottomRight",
|
|
286
|
+
trigger: ["click"],
|
|
287
|
+
open: moreOpen,
|
|
288
|
+
onOpenChange: setMoreOpen,
|
|
289
|
+
popupRender: () => (
|
|
290
|
+
// antd 6 Dropdown 弹层默认挂载 body,不在组件子树内,
|
|
291
|
+
// 组件根注入的 CSS 变量无法继承,弹层容器样式需用 token 内联消费
|
|
292
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
className: "company-multi-tabs-more-popup",
|
|
296
|
+
style: {
|
|
297
|
+
display: "flex",
|
|
298
|
+
flexDirection: "column",
|
|
299
|
+
overflow: "hidden",
|
|
300
|
+
background: token.colorBgContainer,
|
|
301
|
+
borderRadius: token.borderRadiusLG,
|
|
302
|
+
boxShadow: token.boxShadowSecondary
|
|
303
|
+
},
|
|
304
|
+
children: [
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { maxHeight: 180, overflowY: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
306
|
+
import_basic_components.CompanyMenu,
|
|
307
|
+
{
|
|
308
|
+
selectedKeys: [activeKey],
|
|
309
|
+
onClick: ({ key }) => {
|
|
310
|
+
setMoreOpen(false);
|
|
311
|
+
if (homeTab && key === homeTab.key) {
|
|
312
|
+
onHomeClick == null ? void 0 : onHomeClick();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const tab = tabs.find((t) => t.key === key);
|
|
316
|
+
if (tab)
|
|
317
|
+
onChange == null ? void 0 : onChange(tab.key, tab);
|
|
318
|
+
},
|
|
319
|
+
items: [
|
|
320
|
+
...homeTab ? [{ key: homeTab.key, label: homeTab.label }] : [],
|
|
321
|
+
...tabs.map((t) => ({
|
|
322
|
+
key: t.key,
|
|
323
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
324
|
+
"span",
|
|
325
|
+
{
|
|
326
|
+
style: {
|
|
327
|
+
display: "flex",
|
|
328
|
+
alignItems: "center",
|
|
329
|
+
justifyContent: "space-between",
|
|
330
|
+
gap: token.marginXS
|
|
331
|
+
},
|
|
332
|
+
children: [
|
|
333
|
+
t.label,
|
|
334
|
+
t.closable !== false ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
335
|
+
import_shared_components.SvgIcon,
|
|
336
|
+
{
|
|
337
|
+
href: "close",
|
|
338
|
+
size: 12,
|
|
339
|
+
style: {
|
|
340
|
+
color: token.colorTextSecondary,
|
|
341
|
+
flexShrink: 0
|
|
342
|
+
},
|
|
343
|
+
onClick: (e) => {
|
|
344
|
+
handleClose(e, t);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
) : null
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
}))
|
|
352
|
+
]
|
|
353
|
+
}
|
|
354
|
+
) }),
|
|
355
|
+
hasClosableOthers ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
356
|
+
import_basic_components.CompanyMenu,
|
|
357
|
+
{
|
|
358
|
+
selectable: false,
|
|
359
|
+
onClick: closeOtherTabs,
|
|
360
|
+
items: [
|
|
361
|
+
{ type: "divider" },
|
|
362
|
+
{ key: "__close_others__", label: "关闭其他页签" }
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
) : null
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
),
|
|
370
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "company-multi-tabs__action", "aria-label": "更多页签", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "more-one", size: 16 }) })
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
fullscreenSupported ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: isFullscreen ? "退出全屏" : "全屏", mouseEnterDelay: 0.5, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
374
|
+
"button",
|
|
375
|
+
{
|
|
376
|
+
type: "button",
|
|
377
|
+
"aria-label": isFullscreen ? "退出全屏" : "进入全屏",
|
|
378
|
+
className: "company-multi-tabs__action",
|
|
379
|
+
onClick: toggleFullscreen,
|
|
380
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: isFullscreen ? "off-screen" : "full-screen", size: 16 })
|
|
381
|
+
}
|
|
382
|
+
) }) : null
|
|
383
|
+
] }) : null
|
|
384
|
+
] }) : null
|
|
224
385
|
]
|
|
225
386
|
}
|
|
226
387
|
);
|
|
@@ -217,6 +217,30 @@
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
// —— 操作区最右侧内置动作按钮(更多页签下拉 / 全屏切换,showFullscreen 开启时渲染):样式对齐搜索入口 ——
|
|
221
|
+
&__action {
|
|
222
|
+
box-sizing: border-box;
|
|
223
|
+
width: 28px;
|
|
224
|
+
height: 28px;
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
padding: 0;
|
|
229
|
+
border: none;
|
|
230
|
+
border-radius: var(--cmt-item-radius);
|
|
231
|
+
background: var(--cmt-item-bg);
|
|
232
|
+
color: var(--cmt-icon);
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
transition:
|
|
235
|
+
background 0.2s,
|
|
236
|
+
color 0.2s;
|
|
237
|
+
|
|
238
|
+
&:hover {
|
|
239
|
+
background: var(--cmt-item-bg-hover);
|
|
240
|
+
color: var(--cmt-icon-hover);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
220
244
|
&__extra {
|
|
221
245
|
display: flex;
|
|
222
246
|
align-items: center;
|
|
@@ -225,3 +249,12 @@
|
|
|
225
249
|
flex-shrink: 0;
|
|
226
250
|
}
|
|
227
251
|
}
|
|
252
|
+
|
|
253
|
+
// —— 「更多页签」下拉弹层(antd 6 默认挂载 body,需顶层作用域块):
|
|
254
|
+
// 覆盖 antd Menu 根元素的四角圆角,圆角由外层投影容器统一裁剪(上 padding 保留 antd 默认 4px)。
|
|
255
|
+
// 提升特异性(0,2,0 > 0,1,0)自然胜出,不使用 !important。
|
|
256
|
+
.company-multi-tabs-more-popup {
|
|
257
|
+
.ant-dropdown-menu {
|
|
258
|
+
border-radius: 0;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -24,7 +24,10 @@ export interface FirstSidebarProps {
|
|
|
24
24
|
onBusinessMenuEnter: (menu: SidebarMenuItem, e: React.MouseEvent) => void;
|
|
25
25
|
onBusinessMenuLeave: (e: React.MouseEvent) => void;
|
|
26
26
|
onOpenMore: () => void;
|
|
27
|
-
|
|
27
|
+
/** 切换账号面板内容(如 <CompanyAccountSwitcher/>);传入后头像下拉显示「切换账号」入口,点击后下拉内容切换为该面板(飞书式,非弹窗) */
|
|
28
|
+
accountSwitcher?: React.ReactNode;
|
|
29
|
+
/** 头像下拉自定义插槽:渲染在「切换账号」之后、「退出登录」之前(业务自定义入口区,如帮助中心等) */
|
|
30
|
+
userMenuExtra?: React.ReactNode;
|
|
28
31
|
onLogout?: () => void;
|
|
29
32
|
}
|
|
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,
|
|
33
|
+
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, accountSwitcher, userMenuExtra, onLogout, }: FirstSidebarProps): import("react").JSX.Element;
|
|
@@ -50,10 +50,18 @@ function FirstSidebar({
|
|
|
50
50
|
onBusinessMenuEnter,
|
|
51
51
|
onBusinessMenuLeave,
|
|
52
52
|
onOpenMore,
|
|
53
|
-
|
|
53
|
+
accountSwitcher,
|
|
54
|
+
userMenuExtra,
|
|
54
55
|
onLogout
|
|
55
56
|
}) {
|
|
56
57
|
const hasMore = businessMenus.length > visibleMenuCount;
|
|
58
|
+
const [adminView, setAdminView] = (0, import_react.useState)("menu");
|
|
59
|
+
const [prevAdminOpen, setPrevAdminOpen] = (0, import_react.useState)(adminPopoverOpen);
|
|
60
|
+
if (prevAdminOpen !== adminPopoverOpen) {
|
|
61
|
+
setPrevAdminOpen(adminPopoverOpen);
|
|
62
|
+
if (!adminPopoverOpen)
|
|
63
|
+
setAdminView("menu");
|
|
64
|
+
}
|
|
57
65
|
const displayMenus = (() => {
|
|
58
66
|
if (Array.isArray(customNavMenus) && customNavMenus.length > 0) {
|
|
59
67
|
return customNavMenus.slice(0, visibleMenuCount);
|
|
@@ -159,12 +167,39 @@ function FirstSidebar({
|
|
|
159
167
|
onOpenChange: onAdminPopoverOpenChange,
|
|
160
168
|
trigger: "click",
|
|
161
169
|
placement: "rightBottom",
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
destroyOnHidden: true,
|
|
171
|
+
content: adminView === "accounts" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "admin-popover-content admin-popover-content--panel", children: [
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: "admin-popover-item admin-popover-back",
|
|
176
|
+
onClick: () => setAdminView("menu"),
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "left", size: 20 }),
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "切换账号" })
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "admin-popover-divider" }),
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
onClick: (e) => {
|
|
188
|
+
const target = e.target;
|
|
189
|
+
if (target.closest(".account-switcher-item, .account-switcher-add")) {
|
|
190
|
+
onAdminPopoverOpenChange(false);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
children: accountSwitcher
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "admin-popover-content", children: [
|
|
197
|
+
accountSwitcher && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "admin-popover-item", onClick: () => setAdminView("accounts"), children: [
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "transfer-data", size: 20 }),
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "切换账号" })
|
|
166
200
|
] }),
|
|
167
|
-
|
|
201
|
+
userMenuExtra,
|
|
202
|
+
(accountSwitcher || userMenuExtra) && onLogout && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "admin-popover-divider" }),
|
|
168
203
|
onLogout && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "admin-popover-item", onClick: onLogout, children: [
|
|
169
204
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "logout", size: 20 }),
|
|
170
205
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "退出登录" })
|
|
@@ -31,7 +31,10 @@ export interface CompanySidebarProps {
|
|
|
31
31
|
emptyImage?: string;
|
|
32
32
|
bottomExtra?: React.ReactNode;
|
|
33
33
|
onDomainPopoverOpenChange?: (open: boolean) => void;
|
|
34
|
-
|
|
34
|
+
/** 切换账号面板内容(如 <CompanyAccountSwitcher/>);传入后头像下拉显示「切换账号」入口,点击后下拉内容切换为该面板(飞书式,非弹窗) */
|
|
35
|
+
accountSwitcher?: React.ReactNode;
|
|
36
|
+
/** 头像下拉自定义插槽:渲染在「切换账号」之后、「退出登录」之前(业务自定义入口区,如帮助中心等) */
|
|
37
|
+
userMenuExtra?: React.ReactNode;
|
|
35
38
|
onLogout?: () => void;
|
|
36
39
|
}
|
|
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,
|
|
40
|
+
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, accountSwitcher, userMenuExtra, onLogout, }: CompanySidebarProps): import("react").JSX.Element;
|
|
@@ -92,7 +92,8 @@ function CompanySidebar({
|
|
|
92
92
|
emptyImage,
|
|
93
93
|
bottomExtra,
|
|
94
94
|
onDomainPopoverOpenChange,
|
|
95
|
-
|
|
95
|
+
accountSwitcher,
|
|
96
|
+
userMenuExtra,
|
|
96
97
|
onLogout
|
|
97
98
|
}) {
|
|
98
99
|
const [state, setState] = (0, import_react.useState)({
|
|
@@ -266,7 +267,8 @@ function CompanySidebar({
|
|
|
266
267
|
onBusinessMenuEnter: handleBusinessMenuEnter,
|
|
267
268
|
onBusinessMenuLeave: handleBusinessMenuLeave,
|
|
268
269
|
onOpenMore: () => setState((prev) => ({ ...prev, moreDrawerOpen: !prev.moreDrawerOpen })),
|
|
269
|
-
|
|
270
|
+
accountSwitcher,
|
|
271
|
+
userMenuExtra,
|
|
270
272
|
onLogout
|
|
271
273
|
}
|
|
272
274
|
),
|
|
@@ -145,6 +145,10 @@
|
|
|
145
145
|
display: flex;
|
|
146
146
|
flex-direction: column;
|
|
147
147
|
overflow-y: auto;
|
|
148
|
+
|
|
149
|
+
/* 菜单滚到边界后截断滚动链:文档站页面可滚时避免穿透带动整个框架移动;
|
|
150
|
+
真实业务中框架占满视口、页面本身不滚,此属性无副作用 */
|
|
151
|
+
overscroll-behavior: contain;
|
|
148
152
|
padding: 0 8px;
|
|
149
153
|
gap: 4px;
|
|
150
154
|
}
|
|
@@ -455,6 +459,25 @@
|
|
|
455
459
|
margin: 8px 0;
|
|
456
460
|
}
|
|
457
461
|
|
|
462
|
+
// 切换账号面板视图:气泡容器(.ant-popover-container,左右各 12px 内边距)总宽固定 200px,
|
|
463
|
+
// 内容区 176px;覆盖 CompanyAccountSwitcher 的 240px 最小宽度,让其铺满容器
|
|
464
|
+
.admin-popover-content--panel {
|
|
465
|
+
width: 176px;
|
|
466
|
+
|
|
467
|
+
.company-account-switcher {
|
|
468
|
+
width: 100%;
|
|
469
|
+
min-width: 0;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// 面板视图顶部的返回行(返回功能菜单):紧凑内边距与间距(覆盖 .admin-popover-item 的 38px / 4px 12px / 6px)
|
|
474
|
+
.admin-popover-back {
|
|
475
|
+
height: 32px;
|
|
476
|
+
padding: 4px;
|
|
477
|
+
gap: 4px;
|
|
478
|
+
color: var(--company-color-text-secondary, rgba(0, 0, 0, 0.65));
|
|
479
|
+
}
|
|
480
|
+
|
|
458
481
|
// ========== SecondSidebar 二级浅色侧栏 ==========
|
|
459
482
|
.company-sidebar-second {
|
|
460
483
|
width: 220px;
|
|
@@ -482,6 +505,7 @@
|
|
|
482
505
|
.menu-list {
|
|
483
506
|
flex: 1;
|
|
484
507
|
overflow-y: auto;
|
|
508
|
+
overscroll-behavior: contain;
|
|
485
509
|
display: flex;
|
|
486
510
|
flex-direction: column;
|
|
487
511
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
export interface CompanyAccountItem {
|
|
4
|
+
/** 账号唯一标识 */
|
|
5
|
+
id: string | number;
|
|
6
|
+
/** 昵称(展示名,缺省回退 username) */
|
|
7
|
+
nickname?: string;
|
|
8
|
+
/** 登录用户名 */
|
|
9
|
+
username?: string;
|
|
10
|
+
/** 头像图片地址;缺省渲染昵称首字符圆标 */
|
|
11
|
+
avatar?: string;
|
|
12
|
+
/** 所属组织 / 域名称(副标题兜底展示) */
|
|
13
|
+
domainName?: string;
|
|
14
|
+
/** 是否当前登录账号(当前项右侧渲染对勾,不显示移除按钮) */
|
|
15
|
+
current?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface CompanyAccountSwitcherProps {
|
|
18
|
+
/** 账号列表(受控数据,由业务侧注入) */
|
|
19
|
+
accounts: CompanyAccountItem[];
|
|
20
|
+
/** 点击账号项回调(业务侧执行切换登录) */
|
|
21
|
+
onSelectAccount?: (account: CompanyAccountItem) => void;
|
|
22
|
+
/** 点击「登录更多账号」回调;不传则不渲染该入口 */
|
|
23
|
+
onAddAccount?: () => void;
|
|
24
|
+
/** 移除账号回调;传入后非当前账号 hover 显示移除按钮 */
|
|
25
|
+
onRemoveAccount?: (account: CompanyAccountItem) => void;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 通用账号切换面板(纯 UI 受控组件)。
|
|
31
|
+
* 渲染:账号列表(首字符头像 + 昵称 + 用户名/组织名,当前项打勾)+ 分隔线 + 「登录更多账号」。
|
|
32
|
+
* 数据与动作全部由业务侧通过 Props 注入,组件内不耦合任何登录/会话逻辑。
|
|
33
|
+
*/
|
|
34
|
+
export declare const CompanyAccountSwitcher: React.FC<CompanyAccountSwitcherProps>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CheckOutlined, CloseOutlined, UserAddOutlined } from "@ant-design/icons";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* 通用账号切换面板(纯 UI 受控组件)。
|
|
8
|
+
* 渲染:账号列表(首字符头像 + 昵称 + 用户名/组织名,当前项打勾)+ 分隔线 + 「登录更多账号」。
|
|
9
|
+
* 数据与动作全部由业务侧通过 Props 注入,组件内不耦合任何登录/会话逻辑。
|
|
10
|
+
*/
|
|
11
|
+
export var CompanyAccountSwitcher = function CompanyAccountSwitcher(_ref) {
|
|
12
|
+
var accounts = _ref.accounts,
|
|
13
|
+
onSelectAccount = _ref.onSelectAccount,
|
|
14
|
+
onAddAccount = _ref.onAddAccount,
|
|
15
|
+
onRemoveAccount = _ref.onRemoveAccount,
|
|
16
|
+
className = _ref.className,
|
|
17
|
+
style = _ref.style;
|
|
18
|
+
var list = accounts || [];
|
|
19
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
20
|
+
className: "company-account-switcher".concat(className ? " ".concat(className) : ""),
|
|
21
|
+
style: style,
|
|
22
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
23
|
+
className: "account-switcher-list",
|
|
24
|
+
children: list.map(function (account) {
|
|
25
|
+
var displayName = account.nickname || account.username || "";
|
|
26
|
+
var subName = account.username || account.domainName || "";
|
|
27
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
28
|
+
className: "account-switcher-item".concat(account.current ? " current" : ""),
|
|
29
|
+
onClick: function onClick() {
|
|
30
|
+
return onSelectAccount === null || onSelectAccount === void 0 ? void 0 : onSelectAccount(account);
|
|
31
|
+
},
|
|
32
|
+
children: [account.avatar ? /*#__PURE__*/_jsx("span", {
|
|
33
|
+
className: "account-switcher-avatar",
|
|
34
|
+
children: /*#__PURE__*/_jsx("img", {
|
|
35
|
+
src: account.avatar,
|
|
36
|
+
alt: displayName || "avatar"
|
|
37
|
+
})
|
|
38
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
39
|
+
className: "account-switcher-avatar",
|
|
40
|
+
children: (displayName || "A").charAt(0)
|
|
41
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
42
|
+
className: "account-switcher-info",
|
|
43
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
44
|
+
className: "account-switcher-nickname",
|
|
45
|
+
children: displayName || "账号"
|
|
46
|
+
}), subName && /*#__PURE__*/_jsx("div", {
|
|
47
|
+
className: "account-switcher-sub",
|
|
48
|
+
children: subName
|
|
49
|
+
})]
|
|
50
|
+
}), account.current && /*#__PURE__*/_jsx(CheckOutlined, {
|
|
51
|
+
className: "account-switcher-check"
|
|
52
|
+
}), onRemoveAccount && !account.current && /*#__PURE__*/_jsx(CloseOutlined, {
|
|
53
|
+
className: "account-switcher-remove",
|
|
54
|
+
onClick: function onClick(e) {
|
|
55
|
+
// 移除是独立意图:阻断账号项的选中冒泡
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
onRemoveAccount(account);
|
|
58
|
+
}
|
|
59
|
+
})]
|
|
60
|
+
}, account.id);
|
|
61
|
+
})
|
|
62
|
+
}), onAddAccount && /*#__PURE__*/_jsxs(_Fragment, {
|
|
63
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
64
|
+
className: "account-switcher-divider"
|
|
65
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
66
|
+
className: "account-switcher-add",
|
|
67
|
+
onClick: onAddAccount,
|
|
68
|
+
children: [/*#__PURE__*/_jsx(UserAddOutlined, {}), /*#__PURE__*/_jsx("span", {
|
|
69
|
+
children: "\u767B\u5F55\u66F4\u591A\u8D26\u53F7"
|
|
70
|
+
})]
|
|
71
|
+
})]
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// ========== Account Switcher ==========
|
|
2
|
+
// 与 CompanySidebar admin-popover 同风格族:hover 浅灰底 + 4px 圆角 + 1px 分隔线
|
|
3
|
+
.company-account-switcher {
|
|
4
|
+
min-width: 240px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.account-switcher-list {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: 2px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.account-switcher-item {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 10px;
|
|
17
|
+
padding: 4px;
|
|
18
|
+
border-radius: 4px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background 0.2s;
|
|
21
|
+
|
|
22
|
+
/* 当前账号行间距更紧凑 */
|
|
23
|
+
&.current {
|
|
24
|
+
gap: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
background: var(--company-color-bg-light, #f5f5f5);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.account-switcher-avatar {
|
|
33
|
+
width: 28px;
|
|
34
|
+
height: 28px;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
background: var(--company-color-primary-bg, #fff1e6);
|
|
42
|
+
color: var(--company-color-primary, #f95914);
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
|
|
45
|
+
img {
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
object-fit: cover;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.account-switcher-info {
|
|
53
|
+
flex: 1;
|
|
54
|
+
min-width: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.account-switcher-nickname {
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 20px;
|
|
60
|
+
color: var(--company-color-text, rgba(0, 0, 0, 0.88));
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.account-switcher-sub {
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
line-height: 18px;
|
|
69
|
+
color: var(--company-color-text-tertiary, rgba(0, 0, 0, 0.45));
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.account-switcher-check {
|
|
76
|
+
flex-shrink: 0;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
color: var(--company-color-primary, #f95914);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.account-switcher-remove {
|
|
82
|
+
flex-shrink: 0;
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
color: var(--company-color-text-quaternary, rgba(0, 0, 0, 0.25));
|
|
85
|
+
opacity: 0;
|
|
86
|
+
transition:
|
|
87
|
+
opacity 0.2s,
|
|
88
|
+
color 0.2s;
|
|
89
|
+
|
|
90
|
+
&:hover {
|
|
91
|
+
color: var(--company-color-error, #ff4d4f);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.account-switcher-item:hover .account-switcher-remove {
|
|
96
|
+
opacity: 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.account-switcher-divider {
|
|
100
|
+
height: 1px;
|
|
101
|
+
background: var(--company-color-border-secondary, #f0f0f0);
|
|
102
|
+
margin: 8px 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.account-switcher-add {
|
|
106
|
+
height: 32px;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
padding: 4px 12px;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
transition: background 0.2s;
|
|
114
|
+
color: var(--company-color-text, rgba(0, 0, 0, 0.88));
|
|
115
|
+
|
|
116
|
+
&:hover {
|
|
117
|
+
background: var(--company-color-bg-light, #f5f5f5);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.anticon {
|
|
121
|
+
font-size: 16px;
|
|
122
|
+
color: var(--company-color-primary, #f95914);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
span {
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -373,6 +373,9 @@ export var TEMPLATE_GROUPS = [{
|
|
|
373
373
|
}, {
|
|
374
374
|
title: "视图切换器 ViewSwitcher",
|
|
375
375
|
link: "/template-components/view-switcher"
|
|
376
|
+
}, {
|
|
377
|
+
title: "账号切换器 AccountSwitcher",
|
|
378
|
+
link: "/template-components/company-account-switcher"
|
|
376
379
|
}, {
|
|
377
380
|
title: "分组标题 SectionTitle",
|
|
378
381
|
link: "/template-components/section-title"
|