@yeeyoon/library 1.7.9 → 1.8.3

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.
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1631872777872" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3042" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M621.4144 214.528a351.9488 351.9488 0 0 0-288.7168-98.304h-0.256C170.752 135.7824 40.96 268.8 22.272 433.5616l49.5616 5.7856L0 628.5312l49.408-7.8848c43.0592 101.0176 130.3552 177.92 236.2368 206.1824 23.6032 8.0384 48.8448 12.288 74.6496 12.288h421.632c135.1168 0 244.5312-112.7424 242.0224-251.1872v-0.1024a240.2304 240.2304 0 0 0-45.5168-136.704 236.6976 236.6976 0 0 0-39.4752-43.52 248.6784 248.6784 0 0 0-163.4816-61.3376v49.4592l-96.8192-176.128-21.1968 36.2496a384.1024 384.1024 0 0 0-35.6864-41.0112l-0.2048-0.1536-0.1536-0.2048zM152.576 604.0064l43.9808-7.0144-124.7744-157.696 49.6128 5.8368C134.7584 327.168 228.352 231.3216 344.064 217.2416a253.2864 253.2864 0 0 1 208.0256 70.4512c19.456 19.456 35.9424 41.3696 48.5376 65.28l-23.7568 40.6016 198.6048 3.072V448c37.2736 0 72.192 13.824 98.7136 37.0688l0.256 0.256 0.3072 0.2048c8.4992 7.2704 16.1792 15.7184 22.8864 25.2416l0.2048 0.256 0.1536 0.256c6.6048 9.1136 11.776 18.1248 15.36 27.136l0.2048 0.4096 0.1536 0.4096c6.4 15.1552 10.0864 32.1024 10.4448 50.6368 1.4848 81.2544-62.72 147.5072-142.2336 147.5072H360.2944c-15.4624 0-30.464-2.6112-44.2368-7.424l-1.8432-0.6656-1.8944-0.512a258.3552 258.3552 0 0 1-159.6928-124.7232z" fill="#3ED09C" p-id="3043"></path></svg>
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Card, Button, message, Image, Row, Col } from 'antd';
4
4
 
@@ -6,8 +6,7 @@ import { fetchSystemToken } from '../../service';
6
6
 
7
7
  const PlatformModal = (props) => {
8
8
  const { platforms, redirectUrl } = props;
9
- const [plat, setPlat] = useState({});
10
- const enterProductDetail = (token, userInfo) => {
9
+ const enterProductDetail = (token, userInfo, plat) => {
11
10
  if (redirectUrl) {
12
11
  window.open(`${redirectUrl}?token=${token}&userId=${userInfo.userId}`);
13
12
  } else if (plat.forwardDomainName) {
@@ -22,12 +21,11 @@ const PlatformModal = (props) => {
22
21
  }
23
22
  };
24
23
  const getSystemToken = async (item) => {
25
- setPlat(item);
26
24
  const resp = await fetchSystemToken({ platformId: item.id });
27
25
  const { success, data } = resp;
28
26
  if (success) {
29
27
  const { token, ...rest } = data;
30
- enterProductDetail(token, rest);
28
+ enterProductDetail(token, rest, item);
31
29
  }
32
30
  };
33
31
  return (
@@ -1,21 +1,54 @@
1
- import React, { useState } from 'react';
2
- import { Menu, Image } from 'antd';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Menu, Image, Modal } from 'antd';
3
3
  import { AppstoreOutlined } from '@ant-design/icons';
4
4
  import PropTypes from 'prop-types';
5
+ import PlatformModal from '../PlatformModal';
6
+ import { getCollabRedirectUrl } from '../../env';
7
+ import ls from 'local-storage';
8
+ import styles from './index.less';
5
9
 
6
10
  const { SubMenu } = Menu;
7
11
 
8
12
  const ProductListMenu = (props) => {
9
13
  const { productList, recommendProductList } = props;
10
14
  const [openKeys] = useState(['sub1', 'sub2']);
15
+ const [platModal, setPlatModal] = useState(false);
16
+ const [platforms, setPlatforms] = useState([]);
17
+ const [newProductList, setNewProductList] = useState([]);
18
+ useEffect(() => {
19
+ setNewProductList([
20
+ {
21
+ code: 200000729,
22
+ description: '团队协作,任务分配一站式敏捷开发',
23
+ domainName: null,
24
+ icon:
25
+ 'https://demo-yeeyoon-fm.oss-cn-zhangjiakou.aliyuncs.com/userCenter/productLogo/yiyunxietong.png',
26
+ id: '9f4f6e1a063711ecb0c00c42a1ff8370',
27
+ isClose: 0,
28
+ level: 1,
29
+ name: '宜云协同',
30
+ parentId: null,
31
+ tenants: null,
32
+ },
33
+ ...productList,
34
+ ]);
35
+ }, [productList]);
36
+ const enterDetail = (item) => {
37
+ if (item.code == 200000729) {
38
+ window.open(`${getCollabRedirectUrl()}?token=${ls.get('X-Auth-Token')}`);
39
+ } else {
40
+ setPlatModal(true);
41
+ setPlatforms(item.platforms);
42
+ }
43
+ };
11
44
  return (
12
- <>
45
+ <div className={styles['product-menu']}>
13
46
  <Menu mode="inline" openKeys={openKeys} style={{ width: 256 }}>
14
47
  <SubMenu key="sub1" icon={<AppstoreOutlined />} title="我的产品">
15
- {productList.length ? (
16
- productList.map((item, index) => {
48
+ {newProductList.length ? (
49
+ newProductList.map((item) => {
17
50
  return (
18
- <Menu.Item key={index}>
51
+ <Menu.Item key={item.code} onClick={() => enterDetail(item)}>
19
52
  <div style={{ display: 'flex', alignItems: 'center' }}>
20
53
  <Image
21
54
  src={item.icon}
@@ -37,9 +70,9 @@ const ProductListMenu = (props) => {
37
70
  </SubMenu>
38
71
  <SubMenu key="sub2" icon={<AppstoreOutlined />} title="推荐产品">
39
72
  {recommendProductList.length ? (
40
- recommendProductList.map((item, index) => {
73
+ recommendProductList.map((item) => {
41
74
  return (
42
- <Menu.Item key={index}>
75
+ <Menu.Item key={item.code}>
43
76
  <div style={{ display: 'flex', alignItems: 'center' }}>
44
77
  <Image
45
78
  src={item.icon}
@@ -60,7 +93,15 @@ const ProductListMenu = (props) => {
60
93
  )}
61
94
  </SubMenu>
62
95
  </Menu>
63
- </>
96
+ <Modal
97
+ visible={platModal}
98
+ title="请选择平台"
99
+ footer={null}
100
+ onCancel={() => setPlatModal(false)}
101
+ >
102
+ <PlatformModal platforms={platforms} />
103
+ </Modal>
104
+ </div>
64
105
  );
65
106
  };
66
107
 
@@ -0,0 +1,7 @@
1
+ .product-menu {
2
+ :global {
3
+ .ant-menu-submenu-arrow {
4
+ display: none;
5
+ }
6
+ }
7
+ }
@@ -87,3 +87,17 @@ export function getOfficialSiteRedirectUrl(sysName) {
87
87
  }
88
88
  window.location.href = url;
89
89
  }
90
+
91
+ export function getCollabRedirectUrl() {
92
+ switch (host) {
93
+ case 'localhost:8003':
94
+ case 'localhost:8000':
95
+ case 'testing-profile.yeeyoon.com':
96
+ return 'https://testing-collab.yeeyoon.com';
97
+ case 'staging-profile.yeeyoon.com':
98
+ return 'https://staging-collab.yeeyoon.com';
99
+ case 'profile.yeeyoon.com':
100
+ default:
101
+ return 'https://collab.yeeyoon.com';
102
+ }
103
+ }
@@ -14,7 +14,12 @@ import Notification from '../Notification/recent';
14
14
  import ProductListMenu from './components/ProductListMenu/';
15
15
  import PlatformModal from './components/PlatformModal/';
16
16
 
17
- import { fetchUserInfo, fetchProductList, logout } from './service';
17
+ import {
18
+ fetchSystemToken,
19
+ fetchUserInfo,
20
+ fetchProductList,
21
+ logout,
22
+ } from './service';
18
23
  import {
19
24
  getProfileRedirectUrl,
20
25
  getIamRedirectUrl,
@@ -23,6 +28,7 @@ import {
23
28
 
24
29
  import LogoProfile from './assets/profile.svg';
25
30
  import LogoCollab from './assets/collab.svg';
31
+ import LogoBpm from './assets/bpm.svg';
26
32
 
27
33
  import styles from './index.less';
28
34
 
@@ -34,6 +40,7 @@ const Header = (props) => {
34
40
  const { token, tenantId = '', productName = 'profile' } = props;
35
41
  const [platforms, setPlatforms] = useState([]);
36
42
  const [userInfo, setUserInfo] = useState(null);
43
+ const [systemUserInfo, setSystemUserInfo] = useState(null);
37
44
  const [tenants, setTenants] = useState([]);
38
45
  const [userId, setUserId] = useState([]);
39
46
  const [productListMenuDrawerShow, setProductListMenuDrawerShow] =
@@ -52,7 +59,7 @@ const Header = (props) => {
52
59
  )}?token=${token}`;
53
60
  }}
54
61
  >
55
- 个人资料
62
+ 个人中心
56
63
  </Menu.Item>
57
64
  <Menu.Item
58
65
  icon={<SettingOutlined />}
@@ -70,12 +77,13 @@ const Header = (props) => {
70
77
  doLogout(userId);
71
78
  }}
72
79
  >
73
- 登出
80
+ 退出登录
74
81
  </Menu.Item>
75
82
  </Menu>
76
83
  );
77
84
 
78
85
  useEffect(() => {
86
+ getCySystemToken();
79
87
  getUserInfo();
80
88
  }, []);
81
89
 
@@ -84,8 +92,10 @@ const Header = (props) => {
84
92
  const tId = tenantId === '' ? tenants[0].id : tenantId;
85
93
  return item.id === tId;
86
94
  });
87
- currentProduct = tenant.applications;
88
- leftProduct = _xorBy(allProduct, currentProduct, 'id');
95
+ if (tenant.length) {
96
+ currentProduct = tenant[0].applications;
97
+ leftProduct = _xorBy(allProduct, currentProduct, 'id');
98
+ }
89
99
  }, [tenantId]);
90
100
 
91
101
  const backToIam = () => {
@@ -94,6 +104,17 @@ const Header = (props) => {
94
104
  }`;
95
105
  };
96
106
 
107
+ const getCySystemToken = async () => {
108
+ const resp = await fetchSystemToken({
109
+ platformId: 'f12a71b6063611ecb0c00c42a1ff8370',
110
+ });
111
+ const { success, data } = resp;
112
+ if (success) {
113
+ const { token, userId } = data;
114
+ setSystemUserInfo({ token, userId });
115
+ }
116
+ };
117
+
97
118
  const getUserInfo = async () => {
98
119
  const resp = await fetchUserInfo();
99
120
  const { success, data } = resp;
@@ -110,7 +131,7 @@ const Header = (props) => {
110
131
  getProductList(id);
111
132
  } else {
112
133
  setTimeout(() => {
113
- backToIam();
134
+ // backToIam();
114
135
  }, 4500);
115
136
  }
116
137
  };
@@ -143,6 +164,11 @@ const Header = (props) => {
143
164
  logo: LogoCollab,
144
165
  name: '宜云协同',
145
166
  };
167
+ case 'bpm':
168
+ return {
169
+ logo: LogoBpm,
170
+ name: '智慧项目',
171
+ };
146
172
  }
147
173
  };
148
174
 
@@ -150,12 +176,14 @@ const Header = (props) => {
150
176
  <>
151
177
  <div className={styles['comp-header']}>
152
178
  <div className={styles['comp-header__left-content']}>
153
- <MoreOutlined
154
- style={{ fontSize: '24px', cursor: 'pointer' }}
155
- onClick={() => {
156
- setProductListMenuDrawerShow(true);
157
- }}
158
- />
179
+ <Tooltip title="更多产品">
180
+ <MoreOutlined
181
+ style={{ fontSize: '24px', cursor: 'pointer' }}
182
+ onClick={() => {
183
+ setProductListMenuDrawerShow(true);
184
+ }}
185
+ />
186
+ </Tooltip>
159
187
  <img
160
188
  src={getSysBrandConfig().logo}
161
189
  className={styles['comp-header__logo']}
@@ -189,13 +217,16 @@ const Header = (props) => {
189
217
  }}
190
218
  />
191
219
  </Tooltip>
192
- <Notification
193
- showLabel={false}
194
- customStyles={{
195
- icon: { height: '62px', display: 'flex' },
196
- list: { top: '44px' },
197
- }}
198
- />
220
+ {systemUserInfo && (
221
+ <Notification
222
+ showLabel={false}
223
+ customStyles={{
224
+ icon: { height: '62px', display: 'flex' },
225
+ list: { top: '44px' },
226
+ }}
227
+ userInfo={systemUserInfo}
228
+ />
229
+ )}
199
230
  <Tooltip title="控制台" className={styles['comp-header__icon']}>
200
231
  <FundProjectionScreenOutlined
201
232
  style={{ fontSize: '20px', color: 'rgba(0, 0, 0, .85)' }}
@@ -22,16 +22,19 @@ let messageList = [];
22
22
  let initTotalMsgCount = 0;
23
23
 
24
24
  const RecentNotification = (props) => {
25
- const { showLabel = true, customStyles = {} } = props;
25
+ const { showLabel = true, customStyles = {}, userInfo = {} } = props;
26
26
  const [messageCount, setMessageCount] = useState(0);
27
27
  const [msgList, setMsgList] = useState([]);
28
28
  const [msgListShow, setMsgListShow] = useState(false);
29
29
 
30
30
  useEffect(async () => {
31
- const response = await queryLatestMessageList({
32
- current_page: 1,
33
- each_page: 5,
34
- });
31
+ const response = await queryLatestMessageList(
32
+ {
33
+ current_page: 1,
34
+ each_page: 5,
35
+ },
36
+ userInfo
37
+ );
35
38
  const { data, total_data } = response;
36
39
  messageList = data || [];
37
40
  setMsgList([...messageList]);
@@ -176,6 +179,7 @@ const RecentNotification = (props) => {
176
179
  RecentNotification.propTypes = {
177
180
  showLabel: PropTypes.bool,
178
181
  customStyles: PropTypes.object,
182
+ userInfo: PropTypes.object,
179
183
  };
180
184
 
181
185
  export default RecentNotification;
@@ -1,9 +1,17 @@
1
1
  import request from '../../utils/request';
2
2
  import { getApiHost } from './env';
3
3
 
4
- export async function queryLatestMessageList(params) {
5
- return request('/v1/notification', {
4
+ export async function queryLatestMessageList(params, userInfo) {
5
+ let data = {
6
6
  prefix: getApiHost(),
7
7
  params,
8
- });
8
+ };
9
+ if (userInfo) {
10
+ const { token, userId } = userInfo;
11
+ data.headers = {
12
+ 'X-Auth-Token': token,
13
+ 'X-Auth-Id': userId,
14
+ };
15
+ }
16
+ return request('/v1/notification', data);
9
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "1.7.9",
3
+ "version": "1.8.3",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -1,7 +1,14 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import Header from '../../lib/components/Header/';
3
3
 
4
4
  // eslint-disable-next-line react/display-name
5
5
  export default function () {
6
- return <Header productName="collab" />;
6
+ const [tenantId, setTenantId] = useState('');
7
+ useEffect(() => {
8
+ setTimeout(() => {
9
+ setTenantId('053a033a063711ecb0c00c42a1ff8370');
10
+ // setTenantId('f12a71b6063611ecb0c00c42a1ff8370');
11
+ }, 3000);
12
+ }, []);
13
+ return <Header productName="bpm" tenantId={tenantId} />;
7
14
  }