@yeeyoon/library 2.1.1 → 2.1.5
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/lib/components/Header/components/PlatformModal/index.jsx +7 -4
- package/lib/components/Header/components/ProductListMenu/index.jsx +11 -4
- package/lib/components/Header/index.jsx +15 -2
- package/lib/components/TenantSelector/index.jsx +55 -0
- package/lib/components/TenantSelector/service.js +11 -0
- package/lib/styles/design-system-overwrite.less +3 -0
- package/lib/utils/request.js +2 -2
- package/package.json +2 -2
- package/src/pages/index.js +10 -4
|
@@ -6,13 +6,13 @@ import { fetchSystemToken } from '../../service';
|
|
|
6
6
|
import ls from 'local-storage';
|
|
7
7
|
|
|
8
8
|
const PlatformModal = (props) => {
|
|
9
|
-
const { platforms, redirectUrl } = props;
|
|
9
|
+
const { platforms, redirectUrl, tenantId } = props;
|
|
10
10
|
const enterProductDetail = (plat) => {
|
|
11
11
|
if (plat.code == '20210811003') {
|
|
12
12
|
window.open(
|
|
13
13
|
`${plat.forwardDomainName}?token=${ls.get(
|
|
14
14
|
'X-Auth-Token'
|
|
15
|
-
)}&userId=${ls.get('X-Auth-Id')}`
|
|
15
|
+
)}&userId=${ls.get('X-Auth-Id')}&tenantId=${tenantId}`
|
|
16
16
|
);
|
|
17
17
|
} else {
|
|
18
18
|
getSystemToken(plat);
|
|
@@ -24,12 +24,14 @@ const PlatformModal = (props) => {
|
|
|
24
24
|
if (success) {
|
|
25
25
|
const { token, ...rest } = data;
|
|
26
26
|
if (redirectUrl) {
|
|
27
|
-
window.open(
|
|
27
|
+
window.open(
|
|
28
|
+
`${redirectUrl}?token=${token}&userId=${rest.userId}&tenantId=${tenantId}`
|
|
29
|
+
);
|
|
28
30
|
} else if (plat.forwardDomainName) {
|
|
29
31
|
window.open(
|
|
30
32
|
`${plat.forwardDomainName}?token=${token}&userInfo=${JSON.stringify(
|
|
31
33
|
rest
|
|
32
|
-
)}`
|
|
34
|
+
)}&tenantId=${tenantId}`
|
|
33
35
|
);
|
|
34
36
|
} else {
|
|
35
37
|
message.error('该系统尚未开发,敬请期待');
|
|
@@ -71,6 +73,7 @@ const PlatformModal = (props) => {
|
|
|
71
73
|
PlatformModal.propTypes = {
|
|
72
74
|
platforms: PropTypes.array,
|
|
73
75
|
redirectUrl: PropTypes.string,
|
|
76
|
+
tenantId: PropTypes.string,
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
export default PlatformModal;
|
|
@@ -11,13 +11,17 @@ import { fetchSystemToken } from '../../service';
|
|
|
11
11
|
const { SubMenu } = Menu;
|
|
12
12
|
|
|
13
13
|
const ProductListMenu = (props) => {
|
|
14
|
-
const { productList, recommendProductList } = props;
|
|
14
|
+
const { productList, recommendProductList, tenantId } = props;
|
|
15
15
|
const [openKeys] = useState(['sub1', 'sub2']);
|
|
16
16
|
const [platModal, setPlatModal] = useState(false);
|
|
17
17
|
const [platforms, setPlatforms] = useState([]);
|
|
18
18
|
const enterDetail = (item) => {
|
|
19
19
|
if (item.code == 200000729) {
|
|
20
|
-
window.open(
|
|
20
|
+
window.open(
|
|
21
|
+
`${getCollabRedirectUrl()}?token=${ls.get(
|
|
22
|
+
'X-Auth-Token'
|
|
23
|
+
)}&tenantId=${tenantId}`
|
|
24
|
+
);
|
|
21
25
|
} else if (item.platforms?.length > 1) {
|
|
22
26
|
setPlatModal(true);
|
|
23
27
|
setPlatforms(item.platforms);
|
|
@@ -30,7 +34,9 @@ const ProductListMenu = (props) => {
|
|
|
30
34
|
const { success, data } = resp;
|
|
31
35
|
if (success) {
|
|
32
36
|
const { token, ...rest } = data;
|
|
33
|
-
window.open(
|
|
37
|
+
window.open(
|
|
38
|
+
`${item.forwardDomainName}?token=${token}&userInfo=${rest}&tenantId=${tenantId}`
|
|
39
|
+
);
|
|
34
40
|
}
|
|
35
41
|
};
|
|
36
42
|
return (
|
|
@@ -91,7 +97,7 @@ const ProductListMenu = (props) => {
|
|
|
91
97
|
footer={null}
|
|
92
98
|
onCancel={() => setPlatModal(false)}
|
|
93
99
|
>
|
|
94
|
-
<PlatformModal platforms={platforms} />
|
|
100
|
+
<PlatformModal platforms={platforms} tenantId={tenantId} />
|
|
95
101
|
</Modal>
|
|
96
102
|
</div>
|
|
97
103
|
);
|
|
@@ -100,6 +106,7 @@ const ProductListMenu = (props) => {
|
|
|
100
106
|
ProductListMenu.propTypes = {
|
|
101
107
|
productList: PropTypes.array,
|
|
102
108
|
recommendProductList: PropTypes.array,
|
|
109
|
+
tenantId: PropTypes.string,
|
|
103
110
|
};
|
|
104
111
|
|
|
105
112
|
export default ProductListMenu;
|
|
@@ -42,7 +42,13 @@ let leftProduct = [];
|
|
|
42
42
|
const CY_PLATFORM_ID = 'f12a71b6063611ecb0c00c42a1ff8370';
|
|
43
43
|
|
|
44
44
|
const Header = (props) => {
|
|
45
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
token,
|
|
47
|
+
tenantId = '',
|
|
48
|
+
productName = 'profile',
|
|
49
|
+
avatar,
|
|
50
|
+
userName,
|
|
51
|
+
} = props;
|
|
46
52
|
const [platforms, setPlatforms] = useState([]);
|
|
47
53
|
const [userInfo, setUserInfo] = useState(null);
|
|
48
54
|
const [systemUserInfo, setSystemUserInfo] = useState(null);
|
|
@@ -98,6 +104,10 @@ const Header = (props) => {
|
|
|
98
104
|
}
|
|
99
105
|
}, [tenantId]);
|
|
100
106
|
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
setAvatarProps({ src: avatar });
|
|
109
|
+
}, [avatar]);
|
|
110
|
+
|
|
101
111
|
const backToIam = () => {
|
|
102
112
|
const { origin, pathname } = window.location;
|
|
103
113
|
window.location.href = `${HOST_IAM}?redirect=${origin}${pathname}`;
|
|
@@ -244,7 +254,7 @@ const Header = (props) => {
|
|
|
244
254
|
{userInfo && (
|
|
245
255
|
<>
|
|
246
256
|
<span className={styles['comp-header__user-name']}>
|
|
247
|
-
{userInfo.name}
|
|
257
|
+
{userName || userInfo.name}
|
|
248
258
|
</span>
|
|
249
259
|
<Dropdown overlay={menu} placement="bottomRight">
|
|
250
260
|
<Avatar {...avatarProps} />
|
|
@@ -267,6 +277,7 @@ const Header = (props) => {
|
|
|
267
277
|
<ProductListMenu
|
|
268
278
|
productList={currentProduct}
|
|
269
279
|
recommendProductList={leftProduct}
|
|
280
|
+
tenantId={tenantId}
|
|
270
281
|
/>
|
|
271
282
|
</Drawer>
|
|
272
283
|
<Modal
|
|
@@ -297,6 +308,8 @@ Header.propTypes = {
|
|
|
297
308
|
token: PropTypes.string.isRequired,
|
|
298
309
|
tenantId: PropTypes.string,
|
|
299
310
|
productName: PropTypes.string,
|
|
311
|
+
avatar: PropTypes.string,
|
|
312
|
+
userName: PropTypes.string,
|
|
300
313
|
};
|
|
301
314
|
|
|
302
315
|
export default Header;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Select } from 'antd';
|
|
4
|
+
|
|
5
|
+
import { fetchUserInfo } from './service';
|
|
6
|
+
|
|
7
|
+
const { Option } = Select;
|
|
8
|
+
|
|
9
|
+
const TenantSelector = (props) => {
|
|
10
|
+
const { tenantId, tenantIdChangeCb } = props;
|
|
11
|
+
const [tenantList, setTenantList] = useState([]);
|
|
12
|
+
const [currentTenantId, setCurrentTenantId] = useState('');
|
|
13
|
+
|
|
14
|
+
useEffect(async () => {
|
|
15
|
+
const resp = await fetchUserInfo();
|
|
16
|
+
const { data, success } = resp;
|
|
17
|
+
if (success) {
|
|
18
|
+
const { tenants } = data;
|
|
19
|
+
const id = tenantId || tenants[0].id;
|
|
20
|
+
setTenantList(tenants);
|
|
21
|
+
setCurrentTenantId(id);
|
|
22
|
+
tenantIdChangeCb(id);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Select
|
|
28
|
+
bordered={false}
|
|
29
|
+
// size="large"
|
|
30
|
+
value={currentTenantId}
|
|
31
|
+
style={{ width: '200px' }}
|
|
32
|
+
onChange={(value) => {
|
|
33
|
+
setCurrentTenantId(value);
|
|
34
|
+
if (tenantIdChangeCb) {
|
|
35
|
+
tenantIdChangeCb(value);
|
|
36
|
+
}
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{tenantList.map((item) => {
|
|
40
|
+
return (
|
|
41
|
+
<Option value={item.id} key={item.id}>
|
|
42
|
+
{item.name}
|
|
43
|
+
</Option>
|
|
44
|
+
);
|
|
45
|
+
})}
|
|
46
|
+
</Select>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
TenantSelector.propTypes = {
|
|
51
|
+
tenantId: PropTypes.string,
|
|
52
|
+
tenantIdChangeCb: PropTypes.func,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default TenantSelector;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import request from '../../utils/request';
|
|
2
|
+
import { API_IAM } from '../../config/env';
|
|
3
|
+
|
|
4
|
+
// 获取用户信息
|
|
5
|
+
export async function fetchUserInfo() {
|
|
6
|
+
return request('/findOidcUser', {
|
|
7
|
+
prefix: `${API_IAM}/api/oidc/v1/oidcuser`,
|
|
8
|
+
method: 'post',
|
|
9
|
+
data: {},
|
|
10
|
+
});
|
|
11
|
+
}
|
package/lib/utils/request.js
CHANGED
|
@@ -8,11 +8,11 @@ const TOKEN_KEY = 'X-Auth-Token';
|
|
|
8
8
|
const ID_KEY = 'X-Auth-Id';
|
|
9
9
|
const REST_KEY = 'Login-Rest-Info';
|
|
10
10
|
const qsData = qs.parse(window.location.search.slice(1));
|
|
11
|
-
const { token, userId, rest } = qsData;
|
|
11
|
+
const { token, userId, ...rest } = qsData;
|
|
12
12
|
|
|
13
13
|
token && ls.set(TOKEN_KEY, token);
|
|
14
14
|
userId && ls.set(ID_KEY, userId);
|
|
15
|
-
rest && ls.set(REST_KEY, rest);
|
|
15
|
+
rest && ls.set(REST_KEY, JSON.stringify(rest));
|
|
16
16
|
|
|
17
17
|
// const codeMessage = {
|
|
18
18
|
// 200: '服务器成功返回请求的数据。',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeeyoon/library",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "宜云前端组件库和通用服务",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "wangmeng",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"start": "
|
|
16
|
+
"start": "umi dev",
|
|
17
17
|
"build": "umi build",
|
|
18
18
|
"test": "umi test",
|
|
19
19
|
"lint": "eslint {src,mock,tests}/**/*.{js,jsx} --fix",
|
package/src/pages/index.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import Header from '../../lib/components/Header/';
|
|
3
|
+
import TenantSelector from '../../lib/components/TenantSelector/';
|
|
3
4
|
|
|
4
5
|
// eslint-disable-next-line react/display-name
|
|
5
6
|
export default function () {
|
|
6
7
|
return (
|
|
7
8
|
// <Header
|
|
8
9
|
// productName="collab"
|
|
9
|
-
//
|
|
10
|
-
// token="
|
|
10
|
+
// tenantId="053a033a063711ecb0c00c42a1ff8370"
|
|
11
|
+
// token="YTI4ZjUwN2FjYjY0NGQ2NWE0NDZhMzdkN2M2NzRhMWY1NjE2MzI0NjQ5MzQzNjg="
|
|
12
|
+
// avatar="https://demo-yeeyoon-fm.oss-cn-zhangjiakou.aliyuncs.com/userCenter/userAvatar/user_avatar2.png"
|
|
13
|
+
// userName="王甍"
|
|
11
14
|
// />
|
|
12
|
-
<
|
|
15
|
+
<TenantSelector
|
|
16
|
+
tenantId="14bfb5d71d1011eca9820c42a1f6bf88"
|
|
17
|
+
tenantIdChangeCb={(id) => console.log(id)}
|
|
18
|
+
/>
|
|
13
19
|
);
|
|
14
20
|
}
|