cfel-base-components 2.5.34 → 2.5.36
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/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import React, { useEffect, useState } from
|
|
2
|
-
import { Layout, Menu, MenuProps, Popover } from
|
|
3
|
-
import UserCard from
|
|
4
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Layout, Menu, MenuProps, Popover } from 'antd'
|
|
3
|
+
import UserCard from './user-card'
|
|
4
|
+
import './index.scss'
|
|
5
5
|
|
|
6
|
-
const { Sider } = Layout
|
|
6
|
+
const { Sider } = Layout
|
|
7
7
|
|
|
8
8
|
export interface LiosLayoutlProps {
|
|
9
|
-
appName?: any
|
|
10
|
-
productCode: string
|
|
11
|
-
children: any
|
|
12
|
-
menuList: any
|
|
13
|
-
onMenuClick: (item: any) => void
|
|
14
|
-
selectedKeys: string[]
|
|
15
|
-
customAction?: (item: any) => void
|
|
16
|
-
actions?: any[]
|
|
9
|
+
appName?: any
|
|
10
|
+
productCode: string
|
|
11
|
+
children: any
|
|
12
|
+
menuList: any
|
|
13
|
+
onMenuClick: (item: any) => void
|
|
14
|
+
selectedKeys: string[]
|
|
15
|
+
customAction?: (item: any) => void
|
|
16
|
+
actions?: any[]
|
|
17
17
|
myWalletInfo?: {
|
|
18
|
-
availableCashAmount: string
|
|
19
|
-
availableAmount: string
|
|
20
|
-
currency: string
|
|
21
|
-
}
|
|
18
|
+
availableCashAmount: string
|
|
19
|
+
availableAmount: string
|
|
20
|
+
currency: string
|
|
21
|
+
}
|
|
22
22
|
MyLoginInfo?: {
|
|
23
|
-
isAdmin: any
|
|
24
|
-
}
|
|
23
|
+
isAdmin: any
|
|
24
|
+
}
|
|
25
25
|
amountInfo?: {
|
|
26
|
-
residueNum: string
|
|
27
|
-
currencyCode: string
|
|
28
|
-
}
|
|
29
|
-
myWalletInfoAction?: Function
|
|
30
|
-
myLoginInfoAction?: Function
|
|
31
|
-
logoutUrl?: string
|
|
32
|
-
switchTenantUrl?: string
|
|
33
|
-
defaultOpenKeys?: string[]
|
|
34
|
-
isHideHeader?: boolean
|
|
26
|
+
residueNum: string
|
|
27
|
+
currencyCode: string
|
|
28
|
+
}
|
|
29
|
+
myWalletInfoAction?: Function
|
|
30
|
+
myLoginInfoAction?: Function
|
|
31
|
+
logoutUrl?: string
|
|
32
|
+
switchTenantUrl?: string
|
|
33
|
+
defaultOpenKeys?: string[]
|
|
34
|
+
isHideHeader?: boolean //是否隐藏header
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export default function LiosLayout(props: LiosLayoutlProps) {
|
|
@@ -52,33 +52,67 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
52
52
|
myWalletInfoAction,
|
|
53
53
|
myLoginInfoAction,
|
|
54
54
|
isHideHeader,
|
|
55
|
-
} = props
|
|
56
|
-
|
|
57
|
-
const { user, logo, subLogo } = (window as any)?.g_config
|
|
58
|
-
const { name, avatar } = user || {}
|
|
59
|
-
|
|
60
|
-
const [openKeys, setOpenKeys] = useState<any>(defaultOpenKeys || [])
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
} = props
|
|
56
|
+
|
|
57
|
+
const { user, logo, subLogo } = (window as any)?.g_config
|
|
58
|
+
const { name, avatar } = user || {}
|
|
59
|
+
|
|
60
|
+
const [openKeys, setOpenKeys] = useState<any>(defaultOpenKeys || [])
|
|
61
|
+
|
|
62
|
+
//处理搜索菜单后自动展开目录
|
|
63
|
+
interface TreeNode {
|
|
64
|
+
key: string
|
|
65
|
+
children?: TreeNode[]
|
|
66
|
+
}
|
|
67
|
+
const findParentMenu = (menuList: any[], pathname: string) => {
|
|
68
|
+
const result: TreeNode[] = []
|
|
69
|
+
|
|
70
|
+
const findNode = (nodes: TreeNode[], path: TreeNode[]): boolean => {
|
|
71
|
+
for (const node of nodes) {
|
|
72
|
+
if (node.key === pathname) {
|
|
73
|
+
result.push(...path)
|
|
74
|
+
return true
|
|
75
|
+
}
|
|
76
|
+
if (node.children && findNode(node.children, [...path, node])) {
|
|
77
|
+
return true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
findNode(menuList, [])
|
|
84
|
+
return result
|
|
85
|
+
}
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
//在这里找到当前菜单的上层目录
|
|
88
|
+
const paMenu = findParentMenu(menuList, '/' + location.pathname.split('/')[2])
|
|
89
|
+
//去重
|
|
90
|
+
const set = new Set(paMenu.map((item) => item.key))
|
|
91
|
+
openKeys.forEach((element: string) => {
|
|
92
|
+
set.add(element)
|
|
93
|
+
})
|
|
94
|
+
setOpenKeys(Array.from(set))
|
|
95
|
+
}, [location.pathname])
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const [collapsed, setCollapsed] = useState(localStorage.getItem('layout_collapsed') === 'true')
|
|
65
99
|
const [isCopied, setIsCopied] = useState({
|
|
66
|
-
account:false,
|
|
67
|
-
id:false,
|
|
68
|
-
tenantName:false,
|
|
69
|
-
tenantId:false
|
|
70
|
-
})
|
|
100
|
+
account: false,
|
|
101
|
+
id: false,
|
|
102
|
+
tenantName: false,
|
|
103
|
+
tenantId: false,
|
|
104
|
+
})
|
|
71
105
|
|
|
72
|
-
const onOpenChange: MenuProps[
|
|
73
|
-
setOpenKeys(keys)
|
|
74
|
-
}
|
|
106
|
+
const onOpenChange: MenuProps['onOpenChange'] = (keys) => {
|
|
107
|
+
setOpenKeys(keys)
|
|
108
|
+
}
|
|
75
109
|
|
|
76
|
-
const copyTextToClipboard = async (text:string,key:string) => {
|
|
110
|
+
const copyTextToClipboard = async (text: string, key: string) => {
|
|
77
111
|
try {
|
|
78
|
-
await navigator.clipboard.writeText(text)
|
|
79
|
-
setIsCopied({...isCopied,[key]:true})
|
|
112
|
+
await navigator.clipboard.writeText(text)
|
|
113
|
+
setIsCopied({ ...isCopied, [key]: true })
|
|
80
114
|
} catch (err) {}
|
|
81
|
-
}
|
|
115
|
+
}
|
|
82
116
|
|
|
83
117
|
return (
|
|
84
118
|
<Layout className="layout-warp">
|
|
@@ -86,35 +120,28 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
86
120
|
<Sider
|
|
87
121
|
className="layout-side"
|
|
88
122
|
style={{
|
|
89
|
-
backgroundSize: collapsed ?
|
|
123
|
+
backgroundSize: collapsed ? '1800%' : '900%',
|
|
90
124
|
}}
|
|
91
125
|
collapsible
|
|
92
126
|
collapsed={collapsed}
|
|
93
127
|
width={240}
|
|
94
128
|
onCollapse={(value) => {
|
|
95
|
-
localStorage.setItem(
|
|
96
|
-
setCollapsed(value)
|
|
129
|
+
localStorage.setItem('layout_collapsed', value.toString())
|
|
130
|
+
setCollapsed(value)
|
|
97
131
|
}}
|
|
98
132
|
>
|
|
99
|
-
<div
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}`}
|
|
107
|
-
src={logo || ""}
|
|
108
|
-
/>
|
|
109
|
-
}
|
|
133
|
+
<div
|
|
134
|
+
className="layout-logo"
|
|
135
|
+
onClick={() => {
|
|
136
|
+
window.open('/home')
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
{<img className={`logo-img ${!collapsed ? 'current-logo' : 'hide-logo'}`} src={logo || ''} />}
|
|
110
140
|
{
|
|
111
141
|
<img
|
|
112
142
|
className={`logo-img sub-logo
|
|
113
|
-
${collapsed ?
|
|
114
|
-
src={
|
|
115
|
-
subLogo ||
|
|
116
|
-
"https://cdn.chengfengerlai.com/logo/company-logo/chengfengerlai-white.png"
|
|
117
|
-
}
|
|
143
|
+
${collapsed ? 'current-logo' : 'hide-sub-logo'}`}
|
|
144
|
+
src={subLogo || 'https://cdn.chengfengerlai.com/logo/company-logo/chengfengerlai-white.png'}
|
|
118
145
|
/>
|
|
119
146
|
}
|
|
120
147
|
</div>
|
|
@@ -126,7 +153,7 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
126
153
|
onOpenChange={onOpenChange}
|
|
127
154
|
items={menuList}
|
|
128
155
|
onClick={(item): any => {
|
|
129
|
-
onMenuClick && onMenuClick(item)
|
|
156
|
+
onMenuClick && onMenuClick(item)
|
|
130
157
|
}}
|
|
131
158
|
selectedKeys={selectedKeys}
|
|
132
159
|
theme="dark"
|
|
@@ -153,34 +180,26 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
153
180
|
<div className="actions-item" key={index}>
|
|
154
181
|
{item}
|
|
155
182
|
</div>
|
|
156
|
-
)
|
|
183
|
+
)
|
|
157
184
|
})}
|
|
158
185
|
</div>
|
|
159
186
|
|
|
160
187
|
<Popover
|
|
161
188
|
placement="bottom"
|
|
162
189
|
content={
|
|
163
|
-
<UserCard
|
|
164
|
-
myWalletInfo={myWalletInfo}
|
|
165
|
-
MyLoginInfo={MyLoginInfo}
|
|
166
|
-
amountInfo={amountInfo}
|
|
167
|
-
customAction={customAction}
|
|
168
|
-
isCopied={isCopied}
|
|
169
|
-
copyTextToClipboard={copyTextToClipboard}
|
|
170
|
-
/>
|
|
190
|
+
<UserCard myWalletInfo={myWalletInfo} MyLoginInfo={MyLoginInfo} amountInfo={amountInfo} customAction={customAction} isCopied={isCopied} copyTextToClipboard={copyTextToClipboard} />
|
|
171
191
|
}
|
|
172
192
|
arrow={false}
|
|
173
193
|
trigger="click"
|
|
174
194
|
onOpenChange={(e) => {
|
|
175
|
-
if (!e) return
|
|
195
|
+
if (!e) return
|
|
176
196
|
setIsCopied({
|
|
177
|
-
account:false,
|
|
178
|
-
id:false,
|
|
179
|
-
tenantName:false,
|
|
180
|
-
tenantId:false
|
|
181
|
-
})
|
|
182
|
-
myLoginInfoAction && myLoginInfoAction()
|
|
183
|
-
|
|
197
|
+
account: false,
|
|
198
|
+
id: false,
|
|
199
|
+
tenantName: false,
|
|
200
|
+
tenantId: false,
|
|
201
|
+
})
|
|
202
|
+
myLoginInfoAction && myLoginInfoAction()
|
|
184
203
|
}}
|
|
185
204
|
>
|
|
186
205
|
<div className="layout-header-user">
|
|
@@ -193,5 +212,5 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
193
212
|
<div className="layout-content">{props.children}</div>
|
|
194
213
|
</div>
|
|
195
214
|
</Layout>
|
|
196
|
-
)
|
|
215
|
+
)
|
|
197
216
|
}
|