@donglegeyu/company-ui 2.15.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 +4 -2
- 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 +19 -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 +4 -2
- 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 +19 -0
- package/package.json +1 -1
|
@@ -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,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/basic-components/CompanyAccountSwitcher/index.tsx
|
|
20
|
+
var CompanyAccountSwitcher_exports = {};
|
|
21
|
+
__export(CompanyAccountSwitcher_exports, {
|
|
22
|
+
CompanyAccountSwitcher: () => CompanyAccountSwitcher
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(CompanyAccountSwitcher_exports);
|
|
25
|
+
var import_icons = require("@ant-design/icons");
|
|
26
|
+
var import_index = require("./index.scss");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var CompanyAccountSwitcher = ({
|
|
29
|
+
accounts,
|
|
30
|
+
onSelectAccount,
|
|
31
|
+
onAddAccount,
|
|
32
|
+
onRemoveAccount,
|
|
33
|
+
className,
|
|
34
|
+
style
|
|
35
|
+
}) => {
|
|
36
|
+
const list = accounts || [];
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `company-account-switcher${className ? ` ${className}` : ""}`, style, children: [
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "account-switcher-list", children: list.map((account) => {
|
|
39
|
+
const displayName = account.nickname || account.username || "";
|
|
40
|
+
const subName = account.username || account.domainName || "";
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: `account-switcher-item${account.current ? " current" : ""}`,
|
|
45
|
+
onClick: () => onSelectAccount == null ? void 0 : onSelectAccount(account),
|
|
46
|
+
children: [
|
|
47
|
+
account.avatar ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "account-switcher-avatar", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: account.avatar, alt: displayName || "avatar" }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "account-switcher-avatar", children: (displayName || "A").charAt(0) }),
|
|
48
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "account-switcher-info", children: [
|
|
49
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "account-switcher-nickname", children: displayName || "账号" }),
|
|
50
|
+
subName && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "account-switcher-sub", children: subName })
|
|
51
|
+
] }),
|
|
52
|
+
account.current && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckOutlined, { className: "account-switcher-check" }),
|
|
53
|
+
onRemoveAccount && !account.current && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
import_icons.CloseOutlined,
|
|
55
|
+
{
|
|
56
|
+
className: "account-switcher-remove",
|
|
57
|
+
onClick: (e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
onRemoveAccount(account);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
account.id
|
|
66
|
+
);
|
|
67
|
+
}) }),
|
|
68
|
+
onAddAccount && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "account-switcher-divider" }),
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "account-switcher-add", onClick: onAddAccount, children: [
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.UserAddOutlined, {}),
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "登录更多账号" })
|
|
73
|
+
] })
|
|
74
|
+
] })
|
|
75
|
+
] });
|
|
76
|
+
};
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
CompanyAccountSwitcher
|
|
80
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
// src/basic-components/index.ts
|
|
17
17
|
var basic_components_exports = {};
|
|
18
18
|
module.exports = __toCommonJS(basic_components_exports);
|
|
19
|
+
__reExport(basic_components_exports, require("./CompanyAccountSwitcher"), module.exports);
|
|
19
20
|
__reExport(basic_components_exports, require("./CompanyActions"), module.exports);
|
|
20
21
|
__reExport(basic_components_exports, require("./CompanyAffix"), module.exports);
|
|
21
22
|
__reExport(basic_components_exports, require("./CompanyAlert"), module.exports);
|
|
@@ -107,6 +108,7 @@ __reExport(basic_components_exports, require("./CompanyWelcome"), module.exports
|
|
|
107
108
|
__reExport(basic_components_exports, require("./CompanyXProvider"), module.exports);
|
|
108
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
110
|
0 && (module.exports = {
|
|
111
|
+
...require("./CompanyAccountSwitcher"),
|
|
110
112
|
...require("./CompanyActions"),
|
|
111
113
|
...require("./CompanyAffix"),
|
|
112
114
|
...require("./CompanyAlert"),
|
|
@@ -217,6 +217,10 @@ var TEMPLATE_GROUPS = [
|
|
|
217
217
|
},
|
|
218
218
|
{ title: "操作按钮组 ActionCell", link: "/template-components/action-cell" },
|
|
219
219
|
{ title: "视图切换器 ViewSwitcher", link: "/template-components/view-switcher" },
|
|
220
|
+
{
|
|
221
|
+
title: "账号切换器 AccountSwitcher",
|
|
222
|
+
link: "/template-components/company-account-switcher"
|
|
223
|
+
},
|
|
220
224
|
{ title: "分组标题 SectionTitle", link: "/template-components/section-title" },
|
|
221
225
|
{ title: "页面标题 PageTitle", link: "/template-components/page-title" },
|
|
222
226
|
{ title: "多列表单 BaseInfoForm", link: "/template-components/base-info-form" },
|
|
@@ -31,8 +31,10 @@ export interface AdminLayoutTemplateProps {
|
|
|
31
31
|
userInfo?: SidebarUserInfo;
|
|
32
32
|
/** 退出登录回调 */
|
|
33
33
|
onLogout?: () => void;
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/** 切换账号面板内容(如 <CompanyAccountSwitcher/>);传入后头像下拉显示「切换账号」入口,点击后下拉内容切换为该面板(飞书式,非弹窗) */
|
|
35
|
+
accountSwitcher?: React.ReactNode;
|
|
36
|
+
/** 头像下拉自定义插槽:渲染在「切换账号」之后、「退出登录」之前(业务自定义入口区) */
|
|
37
|
+
userMenuExtra?: React.ReactNode;
|
|
36
38
|
/** 业务域列表(左侧导航顶部切换下拉) */
|
|
37
39
|
domains?: SidebarDomain[];
|
|
38
40
|
/** 当前业务域 id(受控;不传则组件内部管理) */
|
|
@@ -117,4 +119,4 @@ export interface AdminLayoutTemplateProps {
|
|
|
117
119
|
* - 间距契约固化:内容区只做滚动容器(零间距),业务模板自带全部内边距与背景
|
|
118
120
|
* - 两种内容模式:pages 配置式(key 与菜单联动)或 children 兜底(直接放业务模板)
|
|
119
121
|
*/
|
|
120
|
-
export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout,
|
|
122
|
+
export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout, accountSwitcher, userMenuExtra, domains, currentDomainId, defaultDomainId, onDomainChange, businessMenus, firstMenus, systemBottomMenus, visibleMenuCount, emptyImage, customNavMenus, onCustomNavUpdate, defaultFavorites, onFavoritesChange, defaultActiveFirstMenu, defaultActiveKey, defaultSecondSidebarFixed, tabs, defaultTabs, activeTabKey, defaultActiveTabKey, onTabsChange, onActiveTabChange, onTabClose, homeTab, homeContent, tabSearch, tabSearchPlaceholder, tabExtra, aiAssistant, aiAssistantWidth, aiAssistantDefaultOpen, aiTransport, onMenuOpen, onActiveFirstMenuChange, pages, children, contentClassName, contentStyle, }: AdminLayoutTemplateProps): import("react").JSX.Element;
|
|
@@ -317,7 +317,8 @@ function AdminLayoutTemplate({
|
|
|
317
317
|
brandName,
|
|
318
318
|
userInfo,
|
|
319
319
|
onLogout,
|
|
320
|
-
|
|
320
|
+
accountSwitcher,
|
|
321
|
+
userMenuExtra,
|
|
321
322
|
domains = [],
|
|
322
323
|
currentDomainId,
|
|
323
324
|
defaultDomainId,
|
|
@@ -826,7 +827,8 @@ function AdminLayoutTemplate({
|
|
|
826
827
|
onSecondSidebarFixedChange: setSecondSidebarFixed,
|
|
827
828
|
visibleMenuCount,
|
|
828
829
|
emptyImage,
|
|
829
|
-
|
|
830
|
+
accountSwitcher,
|
|
831
|
+
userMenuExtra,
|
|
830
832
|
onLogout
|
|
831
833
|
}
|
|
832
834
|
),
|
|
@@ -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
|
),
|
|
@@ -459,6 +459,25 @@
|
|
|
459
459
|
margin: 8px 0;
|
|
460
460
|
}
|
|
461
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
|
+
|
|
462
481
|
// ========== SecondSidebar 二级浅色侧栏 ==========
|
|
463
482
|
.company-sidebar-second {
|
|
464
483
|
width: 220px;
|
|
@@ -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"
|
|
@@ -31,8 +31,10 @@ export interface AdminLayoutTemplateProps {
|
|
|
31
31
|
userInfo?: SidebarUserInfo;
|
|
32
32
|
/** 退出登录回调 */
|
|
33
33
|
onLogout?: () => void;
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/** 切换账号面板内容(如 <CompanyAccountSwitcher/>);传入后头像下拉显示「切换账号」入口,点击后下拉内容切换为该面板(飞书式,非弹窗) */
|
|
35
|
+
accountSwitcher?: React.ReactNode;
|
|
36
|
+
/** 头像下拉自定义插槽:渲染在「切换账号」之后、「退出登录」之前(业务自定义入口区) */
|
|
37
|
+
userMenuExtra?: React.ReactNode;
|
|
36
38
|
/** 业务域列表(左侧导航顶部切换下拉) */
|
|
37
39
|
domains?: SidebarDomain[];
|
|
38
40
|
/** 当前业务域 id(受控;不传则组件内部管理) */
|
|
@@ -117,4 +119,4 @@ export interface AdminLayoutTemplateProps {
|
|
|
117
119
|
* - 间距契约固化:内容区只做滚动容器(零间距),业务模板自带全部内边距与背景
|
|
118
120
|
* - 两种内容模式:pages 配置式(key 与菜单联动)或 children 兜底(直接放业务模板)
|
|
119
121
|
*/
|
|
120
|
-
export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout,
|
|
122
|
+
export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout, accountSwitcher, userMenuExtra, domains, currentDomainId, defaultDomainId, onDomainChange, businessMenus, firstMenus, systemBottomMenus, visibleMenuCount, emptyImage, customNavMenus, onCustomNavUpdate, defaultFavorites, onFavoritesChange, defaultActiveFirstMenu, defaultActiveKey, defaultSecondSidebarFixed, tabs, defaultTabs, activeTabKey, defaultActiveTabKey, onTabsChange, onActiveTabChange, onTabClose, homeTab, homeContent, tabSearch, tabSearchPlaceholder, tabExtra, aiAssistant, aiAssistantWidth, aiAssistantDefaultOpen, aiTransport, onMenuOpen, onActiveFirstMenuChange, pages, children, contentClassName, contentStyle, }: AdminLayoutTemplateProps): import("react").JSX.Element;
|
|
@@ -448,7 +448,8 @@ export default function AdminLayoutTemplate(_ref2) {
|
|
|
448
448
|
brandName = _ref2.brandName,
|
|
449
449
|
userInfo = _ref2.userInfo,
|
|
450
450
|
onLogout = _ref2.onLogout,
|
|
451
|
-
|
|
451
|
+
accountSwitcher = _ref2.accountSwitcher,
|
|
452
|
+
userMenuExtra = _ref2.userMenuExtra,
|
|
452
453
|
_ref2$domains = _ref2.domains,
|
|
453
454
|
domains = _ref2$domains === void 0 ? [] : _ref2$domains,
|
|
454
455
|
currentDomainId = _ref2.currentDomainId,
|
|
@@ -1006,7 +1007,8 @@ export default function AdminLayoutTemplate(_ref2) {
|
|
|
1006
1007
|
onSecondSidebarFixedChange: setSecondSidebarFixed,
|
|
1007
1008
|
visibleMenuCount: visibleMenuCount,
|
|
1008
1009
|
emptyImage: emptyImage,
|
|
1009
|
-
|
|
1010
|
+
accountSwitcher: accountSwitcher,
|
|
1011
|
+
userMenuExtra: userMenuExtra,
|
|
1010
1012
|
onLogout: onLogout
|
|
1011
1013
|
}), /*#__PURE__*/_jsxs("div", {
|
|
1012
1014
|
className: "admin-layout-main",
|
|
@@ -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;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
8
|
import { CompanyPopover } from "../../basic-components";
|
|
3
9
|
import { SvgIcon } from "../../shared-components";
|
|
4
10
|
import "./index.scss";
|
|
@@ -29,9 +35,26 @@ export default function FirstSidebar(_ref) {
|
|
|
29
35
|
onBusinessMenuEnter = _ref.onBusinessMenuEnter,
|
|
30
36
|
onBusinessMenuLeave = _ref.onBusinessMenuLeave,
|
|
31
37
|
onOpenMore = _ref.onOpenMore,
|
|
32
|
-
|
|
38
|
+
accountSwitcher = _ref.accountSwitcher,
|
|
39
|
+
userMenuExtra = _ref.userMenuExtra,
|
|
33
40
|
onLogout = _ref.onLogout;
|
|
34
41
|
var hasMore = businessMenus.length > visibleMenuCount;
|
|
42
|
+
// 头像下拉视图:menu=功能菜单,accounts=切换账号面板。同一气泡内切换内容(飞书式),
|
|
43
|
+
// 单一受控 Popover / 单一 open / 单一 portal,从结构上杜绝「菜单已关、面板残留」的双气泡同步问题
|
|
44
|
+
var _useState = useState("menu"),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
adminView = _useState2[0],
|
|
47
|
+
setAdminView = _useState2[1];
|
|
48
|
+
var _useState3 = useState(adminPopoverOpen),
|
|
49
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
|
+
prevAdminOpen = _useState4[0],
|
|
51
|
+
setPrevAdminOpen = _useState4[1];
|
|
52
|
+
// 受控 open 翻为 false 的同一渲染拍内重置视图(React 官方 render 期派生模式):
|
|
53
|
+
// 关闭与视图重置原子提交,下次打开必从菜单进入,无 effect 时序竞态
|
|
54
|
+
if (prevAdminOpen !== adminPopoverOpen) {
|
|
55
|
+
setPrevAdminOpen(adminPopoverOpen);
|
|
56
|
+
if (!adminPopoverOpen) setAdminView("menu");
|
|
57
|
+
}
|
|
35
58
|
var displayMenus = function () {
|
|
36
59
|
if (Array.isArray(customNavMenus) && customNavMenus.length > 0) {
|
|
37
60
|
return customNavMenus.slice(0, visibleMenuCount);
|
|
@@ -196,19 +219,49 @@ export default function FirstSidebar(_ref) {
|
|
|
196
219
|
open: adminPopoverOpen,
|
|
197
220
|
onOpenChange: onAdminPopoverOpenChange,
|
|
198
221
|
trigger: "click",
|
|
199
|
-
placement: "rightBottom"
|
|
200
|
-
|
|
222
|
+
placement: "rightBottom"
|
|
223
|
+
// 关闭即销毁整个内容树(含账号面板):单一 portal,不存在失锚残留/漂移
|
|
224
|
+
,
|
|
225
|
+
destroyOnHidden: true,
|
|
226
|
+
content: adminView === "accounts" ? /*#__PURE__*/_jsxs("div", {
|
|
227
|
+
className: "admin-popover-content admin-popover-content--panel",
|
|
228
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
229
|
+
className: "admin-popover-item admin-popover-back",
|
|
230
|
+
onClick: function onClick() {
|
|
231
|
+
return setAdminView("menu");
|
|
232
|
+
},
|
|
233
|
+
children: [/*#__PURE__*/_jsx(SvgIcon, {
|
|
234
|
+
name: "left",
|
|
235
|
+
size: 20
|
|
236
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
237
|
+
children: "\u5207\u6362\u8D26\u53F7"
|
|
238
|
+
})]
|
|
239
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
240
|
+
className: "admin-popover-divider"
|
|
241
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
242
|
+
onClick: function onClick(e) {
|
|
243
|
+
// 点选账号行 / 「登录更多账号」后整体收起气泡(业务回调由 accountSwitcher 内部触发)
|
|
244
|
+
var target = e.target;
|
|
245
|
+
if (target.closest(".account-switcher-item, .account-switcher-add")) {
|
|
246
|
+
onAdminPopoverOpenChange(false);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
children: accountSwitcher
|
|
250
|
+
})]
|
|
251
|
+
}) : /*#__PURE__*/_jsxs("div", {
|
|
201
252
|
className: "admin-popover-content",
|
|
202
|
-
children: [
|
|
253
|
+
children: [accountSwitcher && /*#__PURE__*/_jsxs("div", {
|
|
203
254
|
className: "admin-popover-item",
|
|
204
|
-
onClick:
|
|
255
|
+
onClick: function onClick() {
|
|
256
|
+
return setAdminView("accounts");
|
|
257
|
+
},
|
|
205
258
|
children: [/*#__PURE__*/_jsx(SvgIcon, {
|
|
206
|
-
name: "
|
|
259
|
+
name: "transfer-data",
|
|
207
260
|
size: 20
|
|
208
261
|
}), /*#__PURE__*/_jsx("span", {
|
|
209
|
-
children: "\
|
|
262
|
+
children: "\u5207\u6362\u8D26\u53F7"
|
|
210
263
|
})]
|
|
211
|
-
}),
|
|
264
|
+
}), userMenuExtra, (accountSwitcher || userMenuExtra) && onLogout && /*#__PURE__*/_jsx("div", {
|
|
212
265
|
className: "admin-popover-divider"
|
|
213
266
|
}), onLogout && /*#__PURE__*/_jsxs("div", {
|
|
214
267
|
className: "admin-popover-item",
|
|
@@ -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;
|
|
@@ -80,7 +80,8 @@ export default function CompanySidebar(_ref) {
|
|
|
80
80
|
emptyImage = _ref.emptyImage,
|
|
81
81
|
bottomExtra = _ref.bottomExtra,
|
|
82
82
|
_onDomainPopoverOpenChange = _ref.onDomainPopoverOpenChange,
|
|
83
|
-
|
|
83
|
+
accountSwitcher = _ref.accountSwitcher,
|
|
84
|
+
userMenuExtra = _ref.userMenuExtra,
|
|
84
85
|
onLogout = _ref.onLogout;
|
|
85
86
|
var _useState = useState({
|
|
86
87
|
domainPopoverOpen: false,
|
|
@@ -329,7 +330,8 @@ export default function CompanySidebar(_ref) {
|
|
|
329
330
|
});
|
|
330
331
|
});
|
|
331
332
|
},
|
|
332
|
-
|
|
333
|
+
accountSwitcher: accountSwitcher,
|
|
334
|
+
userMenuExtra: userMenuExtra,
|
|
333
335
|
onLogout: onLogout
|
|
334
336
|
}), /*#__PURE__*/_jsx(SecondSidebar, {
|
|
335
337
|
activeFirstMenu: displayFirstMenu,
|
|
@@ -459,6 +459,25 @@
|
|
|
459
459
|
margin: 8px 0;
|
|
460
460
|
}
|
|
461
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
|
+
|
|
462
481
|
// ========== SecondSidebar 二级浅色侧栏 ==========
|
|
463
482
|
.company-sidebar-second {
|
|
464
483
|
width: 220px;
|