yuang-framework-ui-common 1.0.31 → 1.0.33
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/config/httpConfig.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import axios from "axios"
|
2
|
+
import { useRouter } from 'vue-router';
|
3
|
+
|
2
4
|
import type { AxiosResponse } from 'axios';
|
3
5
|
|
4
6
|
import { showErrorMessage } from '../utils/messageUtils';
|
@@ -10,6 +12,8 @@ import { clearGatewayConfig, initGatewayConfig, getGatewayConfigUrl } from '../c
|
|
10
12
|
|
11
13
|
import { getLocalStorageItem } from '../utils/storageUtils'
|
12
14
|
|
15
|
+
const router = useRouter();
|
16
|
+
|
13
17
|
const messageMap = {
|
14
18
|
requestError: '请求异常',
|
15
19
|
responseSturctError: '响应结构错误',
|
@@ -59,24 +63,27 @@ http.interceptors.response.use(async (res: any) => {
|
|
59
63
|
}
|
60
64
|
});
|
61
65
|
return Promise.reject(new Error(res?.data?.message));
|
62
|
-
} else if (res?.data?.statusCode ===
|
66
|
+
} else if (res?.data?.statusCode === 500822001) {
|
63
67
|
clearGatewayConfig();
|
64
68
|
showErrorMessage(messageMap.requestError || messageMap.requestError);
|
65
69
|
return Promise.reject(new Error(res?.data?.message));
|
66
|
-
} else if (res?.data?.statusCode ===
|
70
|
+
} else if (res?.data?.statusCode === 500815001) {
|
67
71
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
68
72
|
clearSsoAccessToken();
|
69
73
|
window.location.href = getSsoLoginUrl() || '';
|
70
74
|
return Promise.reject(new Error(res?.data?.message));
|
71
|
-
} else if (res?.data?.statusCode ===
|
75
|
+
} else if (res?.data?.statusCode === 500815005) {
|
72
76
|
await refreshSsoAccessToken(res);
|
73
77
|
// 重发请求
|
74
78
|
return axios.request(res.config);
|
75
|
-
} else if (res?.data?.statusCode ===
|
79
|
+
} else if (res?.data?.statusCode === 500815006) {
|
80
|
+
const fullPath = router.currentRoute.value.fullPath;
|
81
|
+
router.push(`/sso/login/index?redirectRoutePath=${encodeURIComponent(fullPath)}`);
|
82
|
+
return;
|
83
|
+
} else if (res?.data?.statusCode === 500815003) {
|
76
84
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
77
85
|
return Promise.reject(new Error(res?.data?.message));
|
78
86
|
}
|
79
|
-
|
80
87
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
81
88
|
return Promise.reject(new Error(res?.data?.message));
|
82
89
|
}
|
@@ -88,7 +95,7 @@ http.interceptors.response.use(async (res: any) => {
|
|
88
95
|
if (statusCode !== 200) {
|
89
96
|
errorMessage = message;
|
90
97
|
}
|
91
|
-
|
98
|
+
errorMessage = errorMessage || messageMap.requestError
|
92
99
|
} else {
|
93
100
|
errorMessage = error?.message || messageMap.requestError;
|
94
101
|
}
|
package/package.json
CHANGED
@@ -22,9 +22,8 @@
|
|
22
22
|
|
23
23
|
proxy.$http.get('/sso-api/client/auth/getSsoAccessToken', { params: { code: code } }).then((res: any) => {
|
24
24
|
setSsoAccessToken(res.data.data);
|
25
|
-
let redirectRoutePath = router.currentRoute.value.query.redirectRoutePath
|
26
|
-
redirectRoutePath =
|
27
|
-
|
25
|
+
let redirectRoutePath = router.currentRoute.value.query.redirectRoutePath as string;
|
26
|
+
redirectRoutePath = decodeURIComponent(redirectRoutePath) || ('/sso/login/login-success' as any);
|
28
27
|
router.push(redirectRoutePath);
|
29
28
|
});
|
30
29
|
});
|