@yeeyoon/library 2.9.7 → 3.0.2

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.
@@ -22,16 +22,7 @@ const ProductListMenu = (props) => {
22
22
  let _link = document.createElement('a');
23
23
  let link = document.body.appendChild(_link);
24
24
  link.setAttribute('target', '_blank');
25
- if (item.code == 200000729) {
26
- link.setAttribute(
27
- 'href',
28
- `${getCollabRedirectUrl()}?token=${ls.get(
29
- 'X-Auth-Token'
30
- )}&tenantId=${tenantId}`
31
- );
32
- link.click();
33
- return;
34
- } else if (item.platforms.length > 1) {
25
+ if (item.platforms.length > 1) {
35
26
  setPlatModal(true);
36
27
  setPlatforms(item.platforms);
37
28
  } else if (item.platforms.length == 1) {
@@ -60,6 +60,7 @@ const Header = (props) => {
60
60
  avatar,
61
61
  userName,
62
62
  slot = <></>,
63
+ handleException,
63
64
  } = props;
64
65
  const [platforms, setPlatforms] = useState([]);
65
66
  const [userInfo, setUserInfo] = useState(null);
@@ -151,6 +152,10 @@ const Header = (props) => {
151
152
  const { success, data } = resp;
152
153
  if (success) {
153
154
  const { platforms, tenants, id, name } = data;
155
+ if (!platforms.length || !tenants.length) {
156
+ handleException && handleException();
157
+ }
158
+
154
159
  ls.set('X-Auth-Username', name);
155
160
  ls.set('X-Auth-Userid', id);
156
161
  // if (platforms.filter((item) => item.id === CY_PLATFORM_ID).length) {
@@ -177,6 +182,9 @@ const Header = (props) => {
177
182
  allProduct = data;
178
183
  leftProduct = _xorBy(allProduct, currentProduct, 'id');
179
184
  }
185
+ if (!data.filter((item) => item.code === 200000728).length) {
186
+ handleException && handleException();
187
+ }
180
188
  };
181
189
 
182
190
  const doLogout = async (userId) => {
@@ -339,6 +347,7 @@ Header.propTypes = {
339
347
  avatar: PropTypes.string,
340
348
  userName: PropTypes.string,
341
349
  slot: PropTypes.node,
350
+ handleException: PropTypes.func,
342
351
  };
343
352
 
344
353
  export default Header;
@@ -4,6 +4,8 @@ import qs from 'qs';
4
4
  import ls from 'local-storage';
5
5
  import { notification } from 'antd';
6
6
 
7
+ import { HOST_IAM } from '../config/env';
8
+
7
9
  const TOKEN_KEY = 'X-Auth-Token';
8
10
  const ID_KEY = 'X-Auth-Id';
9
11
  const REST_KEY = 'Login-Rest-Info';
@@ -40,6 +42,11 @@ rest && ls.set(REST_KEY, JSON.stringify(rest));
40
42
  // };
41
43
  /** 异常处理程序 */
42
44
 
45
+ const backToIam = () => {
46
+ const { origin, pathname } = window.location;
47
+ window.location.href = `${HOST_IAM}?redirect=${origin}${pathname}`;
48
+ };
49
+
43
50
  const errorHandler = (error) => {
44
51
  const { response } = error;
45
52
 
@@ -78,7 +85,10 @@ request.interceptors.response.use(async (response) => {
78
85
  if (code !== 200 && code !== 201 && !success) {
79
86
  m !== '操作过于频繁' &&
80
87
  m.indexOf('存在重复的物资') < 0 &&
81
- notification.error({ message: m });
88
+ notification.error({
89
+ message: m,
90
+ maxCount: 1,
91
+ });
82
92
  if (
83
93
  code === 401 ||
84
94
  code === 402 ||
@@ -86,6 +96,9 @@ request.interceptors.response.use(async (response) => {
86
96
  m === 'token不一致'
87
97
  ) {
88
98
  window.top.postMessage('tcTokenExpired', '*'); // 通知宿主窗口
99
+ setTimeout(() => {
100
+ backToIam();
101
+ }, 1000);
89
102
  }
90
103
  return resp;
91
104
  } else if (success && (!code || code === 200)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "2.9.7",
3
+ "version": "3.0.2",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {