cfel-base-components 2.4.4 → 2.5.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.
@@ -1,13 +1,10 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import { Layout, Menu, MenuProps, Popover } from "antd";
3
- import { SwapOutlined, FormOutlined } from "@ant-design/icons";
3
+ import UserCard from "./user-card";
4
4
  import "./index.scss";
5
5
 
6
- const currencyList = [
7
- { value: "JPY", label: "日元", icon: "¥" },
8
- { value: "USD", label: "美元", icon: "$" },
9
- { value: "CNY", label: "人民币", icon: "¥" },
10
- ];
6
+ const { Sider } = Layout;
7
+
11
8
  export interface LiosLayoutlProps {
12
9
  appName?: any;
13
10
  productCode: string;
@@ -16,19 +13,6 @@ export interface LiosLayoutlProps {
16
13
  onMenuClick: (item: any) => void;
17
14
  selectedKeys: string[];
18
15
  actions?: any[];
19
- user?: {
20
- name: string;
21
- avatar: string;
22
- tenantName: string;
23
- role: any[];
24
- };
25
- custom?: {
26
- type: string;
27
- isCompleted: number;
28
- isAudited: number;
29
- hrefUrl: string;
30
- historyAction?: any;
31
- };
32
16
  myWalletInfo?: {
33
17
  availableCashAmount: string;
34
18
  availableAmount: string;
@@ -42,8 +26,6 @@ export interface LiosLayoutlProps {
42
26
  logoutUrl?: string;
43
27
  switchTenantUrl?: string;
44
28
  defaultOpenKeys?: string[];
45
- productList?: any;
46
- logoUrl?: string;
47
29
  isHideHeader?: boolean; //是否隐藏header
48
30
  }
49
31
 
@@ -51,295 +33,124 @@ export default function LiosLayout(props: LiosLayoutlProps) {
51
33
  const {
52
34
  appName,
53
35
  productCode,
54
- logoUrl,
55
36
  menuList,
56
37
  onMenuClick,
57
38
  selectedKeys,
58
39
  actions,
59
- user,
60
- custom,
61
- logoutUrl,
62
- switchTenantUrl,
40
+
63
41
  defaultOpenKeys,
64
- productList,
65
42
  myWalletInfo,
66
43
  amountInfo,
67
44
  myWalletInfoAction,
68
45
  isHideHeader,
69
46
  } = props;
70
47
 
71
- const { name, avatar, tenantName, role } = user || {};
72
- const { isCompleted, isAudited, hrefUrl, historyAction } = custom || {};
73
-
74
- const { availableCashAmount, availableAmount, currency } = myWalletInfo || {};
75
-
76
- const { residueNum, currencyCode } = amountInfo || {};
48
+ const { user, logo, subLogo } = (window as any)?.g_config;
49
+ const { name, avatar } = user || {};
77
50
 
78
51
  const [openKeys, setOpenKeys] = useState<any>(defaultOpenKeys || []);
79
- // const [currentProduct, setCurrentProduct] = useState<any>({});
80
-
81
- const { Sider } = Layout;
82
-
83
- const [collapsed, setCollapsed] = useState(false);
84
52
 
85
- // useEffect(() => {
86
- // if (!productList) return
87
- // let cp = productList?.filter((i: any) => i.productCode == productCode)[0]
88
- // setCurrentProduct(cp)
89
- // }, [productList])
53
+ const [collapsed, setCollapsed] = useState(
54
+ localStorage.getItem("layout_collapsed") === "true"
55
+ );
90
56
 
91
57
  const onOpenChange: MenuProps["onOpenChange"] = (keys) => {
92
58
  setOpenKeys(keys);
93
59
  };
94
- const editUserInfo = () => {
95
- const { origin } = window.location;
96
- if (historyAction) {
97
- historyAction?.push({
98
- pathname: hrefUrl,
99
- });
100
- } else {
101
- window.location.href = origin + hrefUrl;
102
- }
103
- };
104
- const currencyText = (currencyText: any) => {
105
- let text = "";
106
- currencyList.some((item: any) => {
107
- if (item.value == currencyText) {
108
- text = item.icon;
109
- return true;
110
- }
111
- });
112
- return text;
113
- };
114
-
115
- const UserCard = () => {
116
- return (
117
- <div className="user-card">
118
- <div className="user-info">
119
- <img className="author" src={avatar} />
120
- <div className="user-info-right">
121
- <span className="name">{name}</span>
122
- <div className="role-list">
123
- {role?.map((i) => (
124
- <span className="role-item" key={i}>
125
- {i}
126
- </span>
127
- ))}
128
- </div>
129
- </div>
130
- </div>
131
-
132
- {myWalletInfo && (
133
- <div className="lios-userInfo">
134
- <div className="lios-li">
135
- <div className="lios-key">现金余额</div>
136
- <div className="lios-value">
137
- <span>{currencyText(currency)}</span>
138
- {availableCashAmount || "加载中..."}
139
- </div>
140
- </div>
141
- <div className="lios-li">
142
- <div className="lios-key">可用额度</div>
143
- <div className="lios-value">
144
- <span>{currencyText(currency)}</span>
145
- {availableAmount || "加载中..."}
146
- </div>
147
- </div>
148
- {amountInfo && (
149
- <div className="lios-li">
150
- <div className="lios-key">抵用金余额</div>
151
- <div className="lios-value">
152
- <span>{currencyText(currencyCode)}</span>
153
- {residueNum || "加载中..."}
154
- </div>
155
- </div>
156
- )}
157
- </div>
158
- )}
159
- {custom && (
160
- <div className="lios-userInfo">
161
- <div className="lios-li li-flex">
162
- <div className="lios-key">客户类型</div>
163
- <div className="lios-value">{custom.type || ""}</div>
164
- <div
165
- className="lios-icon"
166
- onClick={() => {
167
- editUserInfo();
168
- }}
169
- >
170
- <FormOutlined />
171
- </div>
172
- </div>
173
- <div className="lios-li">
174
- <div className="lios-key">是否审核</div>
175
- <div className="lios-value">{isAudited ? "是" : "否"}</div>
176
- </div>
177
- <div className="lios-li">
178
- <div className="lios-key">是否资料完备</div>
179
- <div className="lios-value">{isCompleted ? "是" : "否"}</div>
180
- </div>
181
- </div>
182
- )}
183
60
 
184
- {tenantName && (
185
- <div className="lios-tenant">
186
- <div className="tenant-label">租户</div>
187
- <div className="tenant-switch">
188
- <div className="tenant-value">{tenantName}</div>
189
- {switchTenantUrl && (
190
- <div
191
- className="tenant-icon"
192
- onClick={() => {
193
- location.href = switchTenantUrl;
194
- }}
195
- >
196
- <SwapOutlined />
197
- </div>
198
- )}
199
- </div>
200
- </div>
201
- )}
202
-
203
- {logoutUrl && (
204
- <div
205
- className="lios-logout"
206
- onClick={() => {
207
- location.href = logoutUrl;
208
- }}
209
- >
210
- <svg
211
- className="logout-icon"
212
- viewBox="0 0 1024 1024"
213
- version="1.1"
214
- xmlns="http://www.w3.org/2000/svg"
215
- p-id="5022"
216
- width="16"
217
- height="16"
218
- >
219
- <path
220
- d="M295.589 239.512c17.942-12.888 42.935-8.79 55.823 9.153 12.888 17.942 8.79 42.935-9.153 55.823C266.667 358.783 221 445.786 221 540.488 221 700.92 351.272 831 512 831s291-130.08 291-290.512c0-94.663-45.63-181.634-121.17-235.935-17.937-12.895-22.026-37.89-9.131-55.827 12.894-17.938 37.889-22.026 55.827-9.132C824.752 308.766 883 419.788 883 540.488 883 745.13 716.884 911 512 911S141 745.13 141 540.488c0-120.75 58.297-231.812 154.589-300.976z"
221
- fill="currentColor"
222
- p-id="5023"
223
- ></path>
224
- <path
225
- d="M512 113c21.87 0 39.641 17.552 39.995 39.339L552 153v297c0 22.091-17.909 40-40 40-21.87 0-39.641-17.552-39.995-39.339L472 450V153c0-22.091 17.909-40 40-40z"
226
- fill="currentColor"
227
- p-id="5024"
228
- ></path>
229
- </svg>
230
- 退出登录
231
- </div>
232
- )}
233
- </div>
234
- );
235
- };
236
-
237
- const ProductListFunc = () => {
238
- return (
239
- <div className="app-list-other">
240
- {productList?.map((item) => {
241
- return (
242
- <div
243
- onClick={() => {
244
- item.productCode != productCode &&
245
- item?.portalUrl &&
246
- window.open(item?.portalUrl);
247
- }}
248
- key={item.id}
249
- className={`product-list-item ${
250
- item.productCode == productCode ? "current-product" : ""
251
- }`}
252
- >
61
+ return (
62
+ <Layout className="layout-warp">
63
+ {Array.isArray(menuList) && menuList.length > 0 && (
64
+ <Sider
65
+ className="layout-side"
66
+ style={{
67
+ backgroundSize: collapsed ? "1600%" : "800%",
68
+ }}
69
+ collapsible
70
+ collapsed={collapsed}
71
+ width={240}
72
+ onCollapse={(value) =>{
73
+ localStorage.setItem("layout_collapsed", value.toString());
74
+ setCollapsed(value)
75
+ }}
76
+ >
77
+ <div className="layout-logo">
78
+ {
253
79
  <img
80
+ className={`logo-img ${
81
+ !collapsed ? "current-logo" : "hide-logo"
82
+ }`}
83
+ src={logo || ""}
84
+ />
85
+ }
86
+ {
87
+ <img
88
+ className={`logo-img sub-logo
89
+ ${collapsed ? "current-logo" : "hide-sub-logo"}`}
254
90
  src={
255
- item?.logoUrl ||
256
- "https://pic.imgdb.cn/item/64c760291ddac507cc68440a.png"
91
+ subLogo ||
92
+ "https://cdn.chengfengerlai.com/logo/company-logo/chengfengerlai-white.png"
257
93
  }
258
- alt=""
259
94
  />
260
- <div> {item?.productName}</div>
261
- </div>
262
- );
263
- })}
264
- </div>
265
- );
266
- };
267
-
268
- const MenuStyle = {
269
- width: collapsed ? 80 : 240,
270
- };
271
-
272
- return (
273
- <Layout className="layout-warp">
274
- {!isHideHeader && (
275
- <div className="layout-header">
276
-
277
- <div className="background">
278
- <img
279
- className="background-img"
280
- src="https://pic.imgdb.cn/item/64813de01ddac507cc192a6e.jpg"
281
- alt=""
282
- />
283
- <div className="background-mask" />
95
+ }
284
96
  </div>
285
97
 
286
- <strong className="layout-header-logo">
287
- {logoUrl && <img className="logo-img" src={logoUrl || ""} />}
288
- {logoUrl && appName && <div className="interval" />}
289
- {appName && <div className="app-name">{appName}</div>}
290
- </strong>
291
-
292
- <div className="layout-header-fill" />
293
-
294
- <div className="layout-header-actions">
295
- {actions?.map((item, index) => {
296
- return (
297
- <div className="actions-item" key={index}>
298
- {item}
299
- </div>
300
- );
301
- })}
302
- </div>
303
-
304
- <Popover
305
- placement="bottom"
306
- content={<UserCard />}
307
- arrow={false}
308
- trigger="click"
309
- onOpenChange={(e) => {
310
- if (!e) return;
311
- myWalletInfoAction && myWalletInfoAction();
312
- }}
313
- >
314
- <div className="layout-header-user">
315
- <img className="author" src={avatar} />
316
- <div className="name">{name}</div>
317
- </div>
318
- </Popover>
319
- </div>
320
- )}
321
- <div className="layout-main">
322
- {Array.isArray(menuList) && menuList.length > 0 && (
323
- <Sider
324
- className="layout-side"
325
- theme={"light"}
326
- collapsible
327
- collapsed={collapsed}
328
- width={240}
329
- onCollapse={(value) => setCollapsed(value)}
330
- >
98
+ <div className="layout-menu-container">
331
99
  <Menu
332
100
  mode="inline"
333
101
  openKeys={openKeys}
334
102
  onOpenChange={onOpenChange}
335
103
  items={menuList}
336
- style={MenuStyle}
337
104
  onClick={(item): any => {
338
105
  onMenuClick && onMenuClick(item);
339
106
  }}
340
107
  selectedKeys={selectedKeys}
108
+ theme="dark"
109
+ color="red"
341
110
  />
342
- </Sider>
111
+ </div>
112
+ </Sider>
113
+ )}
114
+
115
+ <div className="layout-main">
116
+ {!isHideHeader && (
117
+ <div className="layout-header">
118
+ {appName && (
119
+ <div className="app-name">
120
+ <strong>{appName}</strong>
121
+ </div>
122
+ )}
123
+
124
+ <div className="layout-header-fill" />
125
+
126
+ <div className="layout-header-actions">
127
+ {actions?.map((item, index) => {
128
+ return (
129
+ <div className="actions-item" key={index}>
130
+ {item}
131
+ </div>
132
+ );
133
+ })}
134
+ </div>
135
+
136
+ <Popover
137
+ placement="bottom"
138
+ content={
139
+ <UserCard myWalletInfo={myWalletInfo} amountInfo={amountInfo} />
140
+ }
141
+ arrow={false}
142
+ trigger="click"
143
+ onOpenChange={(e) => {
144
+ if (!e) return;
145
+ myWalletInfoAction && myWalletInfoAction();
146
+ }}
147
+ >
148
+ <div className="layout-header-user">
149
+ <img className="avatar" src={avatar} />
150
+ <div className="name">{name}</div>
151
+ </div>
152
+ </Popover>
153
+ </div>
343
154
  )}
344
155
  <div className="layout-content">{props.children}</div>
345
156
  </div>
@@ -0,0 +1,144 @@
1
+ //用户卡片
2
+ .layout-user-card {
3
+ min-width: 182px;
4
+ max-width: 262px;
5
+
6
+ .user-info {
7
+ display: flex;
8
+
9
+ .user-avatar {
10
+ width: 72px;
11
+ height: 72px;
12
+ border-radius: 50%;
13
+ background: rgba(255, 255, 255, 0.3);
14
+ margin-right: 12px;
15
+ }
16
+
17
+ .user-info-right {
18
+ flex: 1;
19
+ }
20
+
21
+ .name {
22
+ display: inline-block;
23
+ margin-top: 18px;
24
+ }
25
+
26
+ .role-list {
27
+ font-size: 12px;
28
+ line-height: 16px;
29
+ margin-top: 4px;
30
+
31
+ .role-item {
32
+ background: rgba(204, 204, 204, 0.55);
33
+ padding: 2px 8px;
34
+ border-radius: 8px;
35
+ display: inline-block;
36
+ margin-right: 4px;
37
+ margin-bottom: 4px;
38
+ }
39
+ }
40
+ }
41
+
42
+ .lios-tenant {
43
+ padding: 5px 0px;
44
+ margin: 5px 0px;
45
+ border-top: 1px solid rgba(5, 5, 5, 0.06);
46
+
47
+ .tenant-label {
48
+ font-size: 12px;
49
+ color: rgba(0, 0, 0, 0.5);
50
+ }
51
+
52
+ .tenant-switch {
53
+ display: flex;
54
+
55
+ .tenant-value {
56
+ flex: 1;
57
+ font-size: 14px;
58
+ color: rgba(0, 0, 0, 0.85);
59
+ }
60
+
61
+ .tenant-icon {
62
+ width: 40px;
63
+ text-align: center;
64
+ color: rgba(0, 0, 0, 0.45);
65
+ display: flex;
66
+ justify-content: center;
67
+ align-items: center;
68
+ }
69
+
70
+ .tenant-icon:hover {
71
+ cursor: pointer;
72
+ color: rgba(0, 0, 0, 0.85);
73
+ }
74
+ }
75
+ }
76
+
77
+ .lios-userInfo {
78
+ padding: 5px 0px;
79
+ margin: 5px 0px;
80
+ border-top: 1px solid rgba(5, 5, 5, 0.06);
81
+
82
+ .li-flex {
83
+ display: flex;
84
+
85
+ .lios-value {
86
+ flex: 1;
87
+ }
88
+ }
89
+
90
+ .lios-li {
91
+ line-height: 22px;
92
+
93
+ .lios-key {
94
+ font-size: 12px;
95
+ color: rgba(0, 0, 0, 0.5);
96
+ display: inline-block;
97
+ }
98
+
99
+ .lios-value {
100
+ padding-left: 8px;
101
+ display: inline-block;
102
+ font-size: 12px;
103
+ color: rgba(0, 0, 0, 0.85);
104
+
105
+ span {
106
+ padding-left: 5px;
107
+ }
108
+ }
109
+
110
+ .lios-icon {
111
+ width: 40px;
112
+ text-align: center;
113
+ color: rgba(0, 0, 0, 0.45);
114
+ transition: all 0.3s;
115
+ }
116
+
117
+ .lios-icon:hover {
118
+ cursor: pointer;
119
+ color: rgba(0, 0, 0, 0.85);
120
+ }
121
+ }
122
+ }
123
+
124
+ .lios-logout {
125
+ cursor: pointer;
126
+ display: flex;
127
+ justify-content: center;
128
+ align-items: center;
129
+ color: rgba(0, 0, 0, 0.45);
130
+ border-radius: 4px;
131
+ transition: background 0.3s;
132
+ padding: 4px;
133
+
134
+ &:hover {
135
+ background: rgba(0, 0, 0, 0.08);
136
+ }
137
+
138
+ .logout-icon {
139
+ width: 16px;
140
+ height: 16px;
141
+ margin-right: 8px;
142
+ }
143
+ }
144
+ }