yuang-framework-ui-common 1.0.96 → 1.0.97
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/utils/ssoUtils.ts +6 -12
- package/package.json +1 -1
- package/src/router/index.ts +2 -2
package/lib/utils/ssoUtils.ts
CHANGED
|
@@ -101,11 +101,11 @@ const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
|
|
101
101
|
// }
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* 处理sso认证
|
|
105
105
|
* @param to
|
|
106
106
|
* @param from
|
|
107
107
|
*/
|
|
108
|
-
const
|
|
108
|
+
const handleSsoAuth = (to : any, from : any) => {
|
|
109
109
|
from;
|
|
110
110
|
return new Promise((resolve, reject) => {
|
|
111
111
|
// 已登录,直接放行
|
|
@@ -124,19 +124,13 @@ const handleRouterGuardSsoAuth = (to : any, from : any) => {
|
|
|
124
124
|
return resolve({result: false});
|
|
125
125
|
}
|
|
126
126
|
try {
|
|
127
|
-
// 有认证码,请求获取 AccessToken(try/catch 捕获所有异常)
|
|
128
127
|
http.get(`/sso-api/client/sso-auth/getSsoAccessToken`, { params: { ssoAuthCode } }).then(res =>{
|
|
129
128
|
setSsoAccessToken(res.data.data);
|
|
130
129
|
// 处理重定向路径
|
|
131
|
-
let
|
|
132
|
-
|
|
133
|
-
ssoRedirectRoutePath = removeParameter('ssoAuthCode', ssoRedirectRoutePath);
|
|
134
|
-
// 无权限页重定向为登录成功页,避免切换账号误解
|
|
135
|
-
if (ssoRedirectRoutePath === '/sso/client/sso-login/sso-login-no-privilege') {
|
|
136
|
-
ssoRedirectRoutePath = '/sso/client/sso-login/sso-login-success';
|
|
137
|
-
}
|
|
130
|
+
let fullPath = to.fullPath;
|
|
131
|
+
fullPath = removeParameter('ssoAuthCode', fullPath);
|
|
138
132
|
// 返回重定向路径
|
|
139
|
-
return resolve({result:
|
|
133
|
+
return resolve({result: true, path: fullPath });
|
|
140
134
|
});
|
|
141
135
|
} catch (error) {
|
|
142
136
|
console.error('SSO 获取 AccessToken 失败:', error);
|
|
@@ -264,7 +258,7 @@ export {
|
|
|
264
258
|
getSsoAuthUrl,
|
|
265
259
|
getSsoLogoutUrl,
|
|
266
260
|
// getSsoAuthRoutePath,
|
|
267
|
-
|
|
261
|
+
handleSsoAuth,
|
|
268
262
|
|
|
269
263
|
getSsoEncrypt,
|
|
270
264
|
getSsoEncryptList,
|
package/package.json
CHANGED
package/src/router/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {createRouter, createWebHistory} from 'vue-router'
|
|
2
2
|
import {getExceptionRoutes} from '../../lib/utils/routerUtils'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { handleSsoAuth } from '../../lib/utils/ssoUtils';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const router = createRouter({
|
|
@@ -69,7 +69,7 @@ const router = createRouter({
|
|
|
69
69
|
|
|
70
70
|
/* 路由守卫 */
|
|
71
71
|
router.beforeEach(async (to, from) => {
|
|
72
|
-
let ssoAuthResult = await
|
|
72
|
+
let ssoAuthResult = await handleSsoAuth(to, from);
|
|
73
73
|
return ssoAuthResult.result;
|
|
74
74
|
});
|
|
75
75
|
|