yuang-framework-ui-common 1.0.4 → 1.0.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/config/http.ts +1 -1
- package/lib/utils/ssoUtils.ts +32 -5
- package/package.json +1 -1
package/lib/config/http.ts
CHANGED
package/lib/utils/ssoUtils.ts
CHANGED
@@ -3,12 +3,38 @@
|
|
3
3
|
|
4
4
|
import Cookies from 'js-cookie'
|
5
5
|
|
6
|
-
const getSsoLoginUrl =
|
7
|
-
|
6
|
+
const getSsoLoginUrl = (redirectUrl = '') => {
|
7
|
+
let ssoLoginUrl = (window as any).fullBaseUrl + '/sso-api/server/sso/login';
|
8
|
+
if (!redirectUrl) {
|
9
|
+
ssoLoginUrl += `?redirectUrl=${encodeURIComponent(window.location.href)}`;
|
10
|
+
} else if (redirectUrl) {
|
11
|
+
ssoLoginUrl += `?redirectUrl=${encodeURIComponent(redirectUrl)}`;
|
12
|
+
}
|
13
|
+
return ssoLoginUrl;
|
8
14
|
}
|
9
15
|
|
10
|
-
const getSsoLogoutUrl =
|
11
|
-
|
16
|
+
const getSsoLogoutUrl = (redirectUrl = '') => {
|
17
|
+
let ssoLogoutUrl = (window as any).fullBaseUrl + '/sso-api/server/sso/logout';
|
18
|
+
if (!redirectUrl) {
|
19
|
+
ssoLogoutUrl += `?redirectUrl=${encodeURIComponent(window.location.href)}`;
|
20
|
+
} else if (redirectUrl) {
|
21
|
+
ssoLogoutUrl += `?redirectUrl=${encodeURIComponent(redirectUrl)}`;
|
22
|
+
}
|
23
|
+
return ssoLogoutUrl;
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* 获取重定向路由路径
|
28
|
+
* @param redirectRoutePath
|
29
|
+
*/
|
30
|
+
const getSsoLoginRoutePath = (redirectRoutePath = '') => {
|
31
|
+
let ssoLoginRoutePath = '/sso/login';
|
32
|
+
if (!redirectRoutePath) {
|
33
|
+
ssoLoginRoutePath += `?redirectRoutePath=${encodeURIComponent('/sso/login-success')}`;
|
34
|
+
} else if (redirectRoutePath) {
|
35
|
+
ssoLoginRoutePath += `?redirectRoutePath=${encodeURIComponent(redirectRoutePath)}`;
|
36
|
+
}
|
37
|
+
return ssoLoginRoutePath;
|
12
38
|
}
|
13
39
|
|
14
40
|
|
@@ -48,13 +74,14 @@ const clearSsoAccessToken = () => {
|
|
48
74
|
|
49
75
|
const logoutSso = () => {
|
50
76
|
clearSsoAccessToken();
|
51
|
-
window.location.href =
|
77
|
+
window.location.href = getSsoLogoutUrl();
|
52
78
|
}
|
53
79
|
|
54
80
|
|
55
81
|
export {
|
56
82
|
getSsoLoginUrl,
|
57
83
|
getSsoLogoutUrl,
|
84
|
+
getSsoLoginRoutePath,
|
58
85
|
|
59
86
|
getSsoAccessToken,
|
60
87
|
setSsoAccessToken,
|