yuang-framework-ui-common 1.0.39 → 1.0.41
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 +1 -1
- package/lib/utils/objectUtils.ts +9 -1
- package/lib/utils/ssoUtils.ts +25 -25
- package/package.json +2 -1
- package/src/views/sso/login/index.vue +6 -6
- package/lib/.DS_Store +0 -0
- package/src/.DS_Store +0 -0
- package/src/views/example/.DS_Store +0 -0
package/lib/config/httpConfig.ts
CHANGED
@@ -78,7 +78,7 @@ http.interceptors.response.use(async (res: any) => {
|
|
78
78
|
return axios.request(res.config);
|
79
79
|
} else if (res?.data?.statusCode === 500815006) {
|
80
80
|
const fullPath = router.currentRoute.value.fullPath;
|
81
|
-
router.push(`/sso/login/index?
|
81
|
+
router.push(`/sso/login/index?ssoRedirectRoutePath=${encodeURIComponent(fullPath)}`);
|
82
82
|
return;
|
83
83
|
} else if (res?.data?.statusCode === 500815003) {
|
84
84
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
package/lib/utils/objectUtils.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import safeStringify from 'safe-stringify';
|
1
2
|
|
2
3
|
/**
|
3
4
|
* 浅度克隆对象
|
@@ -15,7 +16,9 @@ const shallowClone = (obj) => {
|
|
15
16
|
* @returns {{}|*}
|
16
17
|
*/
|
17
18
|
const deepClone = (obj) => {
|
18
|
-
|
19
|
+
/*
|
20
|
+
约到允许依赖就没法了,报错:Maximum call stack size exceeded
|
21
|
+
let result;
|
19
22
|
const type = typeOf(obj);
|
20
23
|
if (type === 'Object') result = {};
|
21
24
|
else if (type === 'Array') result = [];
|
@@ -26,6 +29,11 @@ const deepClone = (obj) => {
|
|
26
29
|
else result[key] = obj[key];
|
27
30
|
});
|
28
31
|
return result;
|
32
|
+
*/
|
33
|
+
if(!obj){
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
return JSON.parse(safeStringify(obj));
|
29
37
|
}
|
30
38
|
/**
|
31
39
|
* 获取变量类型
|
package/lib/utils/ssoUtils.ts
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
import Cookies from 'js-cookie'
|
2
|
-
import {getAesRandomKey, aesEncrypt} from './aesUtils';
|
3
|
-
import {rsaEncrypt} from './rsaUtils';
|
4
|
-
import {getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem} from './storageUtils';
|
2
|
+
import { getAesRandomKey, aesEncrypt } from './aesUtils';
|
3
|
+
import { rsaEncrypt } from './rsaUtils';
|
4
|
+
import { getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem } from './storageUtils';
|
5
5
|
|
6
6
|
|
7
|
-
const getSsoLoginUrl = (
|
7
|
+
const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
8
8
|
let apiFullBaseUrl = (window as any).$config?.apiFullBaseUrl;
|
9
|
-
if(!apiFullBaseUrl) {
|
9
|
+
if (!apiFullBaseUrl) {
|
10
10
|
throw new Error('参数[apiFullBaseUrl]为空');
|
11
11
|
}
|
12
12
|
let ssoLoginUrl = `${apiFullBaseUrl}/sso-api/server/sso/login`;
|
13
|
-
if (!
|
14
|
-
ssoLoginUrl += `?
|
13
|
+
if (!ssoRedirectUrl) {
|
14
|
+
ssoLoginUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
15
15
|
} else {
|
16
|
-
ssoLoginUrl += `?
|
16
|
+
ssoLoginUrl += `?ssoRedirectUrl=${encodeURIComponent(ssoRedirectUrl)}`;
|
17
17
|
}
|
18
18
|
return ssoLoginUrl;
|
19
19
|
}
|
20
20
|
|
21
|
-
const getSsoLogoutUrl = (
|
21
|
+
const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
22
22
|
let apiFullBaseUrl = (window as any).$config?.apiFullBaseUrl;
|
23
|
-
if(!apiFullBaseUrl) {
|
23
|
+
if (!apiFullBaseUrl) {
|
24
24
|
throw new Error('参数[apiFullBaseUrl]为空');
|
25
25
|
}
|
26
26
|
let ssoLogoutUrl = `${apiFullBaseUrl}/sso-api/server/sso/logout`;
|
27
|
-
if (!
|
28
|
-
ssoLogoutUrl += `?
|
29
|
-
} else if (
|
30
|
-
ssoLogoutUrl += `?
|
27
|
+
if (!ssoRedirectUrl) {
|
28
|
+
ssoLogoutUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
29
|
+
} else if (ssoRedirectUrl) {
|
30
|
+
ssoLogoutUrl += `?ssoRedirectUrl=${encodeURIComponent(ssoRedirectUrl)}`;
|
31
31
|
}
|
32
32
|
return ssoLogoutUrl;
|
33
33
|
}
|
34
34
|
|
35
35
|
/**
|
36
36
|
* 获取sso登录路由路径
|
37
|
-
* @param
|
37
|
+
* @param ssoRedirectRoutePath
|
38
38
|
*/
|
39
|
-
const getSsoLoginRoutePath = (
|
39
|
+
const getSsoLoginRoutePath = (ssoRedirectRoutePath = '') => {
|
40
40
|
let ssoLoginRoutePath = '/sso/login/index';
|
41
|
-
if (!
|
42
|
-
ssoLoginRoutePath += `?
|
41
|
+
if (!ssoRedirectRoutePath) {
|
42
|
+
ssoLoginRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent('/sso/login/login-success')}`;
|
43
43
|
} else {
|
44
|
-
ssoLoginRoutePath += `?
|
44
|
+
ssoLoginRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent(ssoRedirectRoutePath)}`;
|
45
45
|
}
|
46
46
|
return ssoLoginRoutePath;
|
47
47
|
}
|
@@ -59,7 +59,7 @@ const getSsoEncrypt = (password = '') => {
|
|
59
59
|
// 使用AES16位的密钥将请求报文加密(使用的是加密前的aes密钥)
|
60
60
|
const encryptPassword = aesEncrypt(aesKey, password);
|
61
61
|
|
62
|
-
return {encryptPassword, rsaAesKey};
|
62
|
+
return { encryptPassword, rsaAesKey };
|
63
63
|
}
|
64
64
|
|
65
65
|
/**
|
@@ -78,7 +78,7 @@ const getSsoEncryptList = (passwordList = []) => {
|
|
78
78
|
encryptPasswordList[i] = aesEncrypt(aesKey, passwordList[i]);
|
79
79
|
}
|
80
80
|
|
81
|
-
return {encryptPasswordList, rsaAesKey};
|
81
|
+
return { encryptPasswordList, rsaAesKey };
|
82
82
|
}
|
83
83
|
|
84
84
|
|
@@ -99,16 +99,16 @@ const getSsoAccessToken = () => {
|
|
99
99
|
|
100
100
|
|
101
101
|
const setSsoAccessToken = (param: any) => {
|
102
|
-
if(!param.ssoAccessToken) {
|
102
|
+
if (!param.ssoAccessToken) {
|
103
103
|
throw new Error('参数[ssoAccessToken]为空');
|
104
104
|
}
|
105
|
-
if(!param.ssoExpiresIn) {
|
105
|
+
if (!param.ssoExpiresIn) {
|
106
106
|
throw new Error('参数[ssoExpiresIn]为空');
|
107
107
|
}
|
108
|
-
if(!param.ssoRefreshToken) {
|
108
|
+
if (!param.ssoRefreshToken) {
|
109
109
|
throw new Error('参数[ssoRefreshToken]为空');
|
110
110
|
}
|
111
|
-
if(!param.ssoRefreshExpiresIn) {
|
111
|
+
if (!param.ssoRefreshExpiresIn) {
|
112
112
|
throw new Error('参数[ssoRefreshExpiresIn]为空');
|
113
113
|
}
|
114
114
|
Cookies.set(ssoAccessTokenCookieKey, param.ssoAccessToken);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "yuang-framework-ui-common",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.41",
|
4
4
|
"private": false,
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
@@ -35,6 +35,7 @@
|
|
35
35
|
"lodash": "^4.17.21",
|
36
36
|
"moment": "^2.30.1",
|
37
37
|
"pinia": "^2.1.7",
|
38
|
+
"safe-stringify": "^1.1.1",
|
38
39
|
"vant": "^4.9.8",
|
39
40
|
"vue": "^3.4.29",
|
40
41
|
"vue-router": "^4.3.3"
|
@@ -13,18 +13,18 @@
|
|
13
13
|
const { proxy } = getCurrentInstance() as any;
|
14
14
|
|
15
15
|
onMounted(() => {
|
16
|
-
const
|
17
|
-
if (!
|
16
|
+
const ssoAuthCode = router.currentRoute.value.query.ssoAuthCode;
|
17
|
+
if (!ssoAuthCode) {
|
18
18
|
window.location.href = getSsoLoginUrl(window.location.href) || '';
|
19
19
|
// 这里一定要return,不return还是会继续执行下面的代码
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
|
23
|
-
proxy.$http.get('/sso-api/client/sso-auth/getSsoAccessToken', { params: {
|
23
|
+
proxy.$http.get('/sso-api/client/sso-auth/getSsoAccessToken', { params: { ssoAuthCode: ssoAuthCode } }).then((res: any) => {
|
24
24
|
setSsoAccessToken(res.data.data);
|
25
|
-
let
|
26
|
-
|
27
|
-
router.push(
|
25
|
+
let ssoRedirectRoutePath = router.currentRoute.value.query.ssoRedirectRoutePath as string;
|
26
|
+
ssoRedirectRoutePath = (ssoRedirectRoutePath && decodeURIComponent(ssoRedirectRoutePath)) || ('/sso/login/login-success' as any);
|
27
|
+
router.push(ssoRedirectRoutePath);
|
28
28
|
});
|
29
29
|
});
|
30
30
|
|
package/lib/.DS_Store
DELETED
Binary file
|
package/src/.DS_Store
DELETED
Binary file
|
Binary file
|