yuang-framework-ui-common 1.0.82 → 1.0.84
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
@@ -86,7 +86,8 @@ http.interceptors.response.use(async (res: any) => {
|
|
86
86
|
}
|
87
87
|
return http.request(res.config);
|
88
88
|
} else if (res?.data?.statusCode === 500815001) {
|
89
|
-
|
89
|
+
// 会提示消息:未登录或已超时,但是马上跳转到登录页面,体验不好,所以去掉提示消息
|
90
|
+
// showErrorMessage(res?.data?.message || messageMap.requestError);
|
90
91
|
clearSsoAccessToken();
|
91
92
|
window.location.href = getSsoLoginUrl() || '';
|
92
93
|
return Promise.reject(new Error(res?.data?.message));
|
package/lib/utils/ssoUtils.ts
CHANGED
@@ -6,6 +6,10 @@ import { getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem } from
|
|
6
6
|
import { application } from '../config/applicationConfig';
|
7
7
|
|
8
8
|
|
9
|
+
/**
|
10
|
+
* 获取sso登录地址
|
11
|
+
* @param ssoRedirectUrl
|
12
|
+
*/
|
9
13
|
const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
10
14
|
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
11
15
|
if (!gatewayServerBaseUrl) {
|
@@ -23,6 +27,31 @@ const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
|
23
27
|
return ssoLoginUrl;
|
24
28
|
}
|
25
29
|
|
30
|
+
/**
|
31
|
+
* 获取sso认证地址
|
32
|
+
* @param ssoRedirectUrl
|
33
|
+
*/
|
34
|
+
const getSsoAuthUrl = (ssoRedirectUrl = '') => {
|
35
|
+
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
36
|
+
if (!gatewayServerBaseUrl) {
|
37
|
+
throw new Error('参数[gatewayServerBaseUrl]为空');
|
38
|
+
}
|
39
|
+
if (!isFullUrl(gatewayServerBaseUrl)) {
|
40
|
+
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
41
|
+
}
|
42
|
+
let ssoAuthUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/auth`;
|
43
|
+
if (!ssoRedirectUrl) {
|
44
|
+
ssoAuthUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
45
|
+
} else {
|
46
|
+
ssoAuthUrl += `?ssoRedirectUrl=${encodeURIComponent(ssoRedirectUrl)}`;
|
47
|
+
}
|
48
|
+
return ssoAuthUrl;
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* 获取sso注销地址
|
53
|
+
* @param ssoRedirectUrl
|
54
|
+
*/
|
26
55
|
const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
27
56
|
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
28
57
|
if (!gatewayServerBaseUrl) {
|
@@ -169,6 +198,7 @@ const logoutSso = () => {
|
|
169
198
|
|
170
199
|
export {
|
171
200
|
getSsoLoginUrl,
|
201
|
+
getSsoAuthUrl,
|
172
202
|
getSsoLogoutUrl,
|
173
203
|
getSsoAuthRoutePath,
|
174
204
|
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
import { useRouter } from 'vue-router';
|
8
8
|
|
9
9
|
import { application } from '../../../../lib/config/applicationConfig';
|
10
|
-
import {
|
10
|
+
import { getSsoAuthUrl, setSsoAccessToken } from '../../../../lib/utils/ssoUtils';
|
11
11
|
import { removeParameter } from '../../../../lib/utils/urlUtils';
|
12
12
|
import { http } from '../../../../lib/config/httpConfig';
|
13
13
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
onMounted(() => {
|
19
19
|
const ssoAuthCode = router.currentRoute.value.query.ssoAuthCode;
|
20
20
|
if (!ssoAuthCode) {
|
21
|
-
window.location.href =
|
21
|
+
window.location.href = getSsoAuthUrl(window.location.href) || '';
|
22
22
|
// 这里一定要return,不return还是会继续执行下面的代码
|
23
23
|
return;
|
24
24
|
}
|