yuang-framework-ui-common 1.0.25 → 1.0.27

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.
@@ -51,19 +51,19 @@ http.interceptors.response.use((res) => {
51
51
  callback: (action: string) => {
52
52
  if (action === 'confirm') {
53
53
  clearSsoAccessToken();
54
- location.href = getSsoLoginUrl();
54
+ window.location.href = getSsoLoginUrl() || '';
55
55
  }
56
56
  }
57
57
  });
58
58
  return Promise.reject(new Error(res?.data?.message));
59
59
  } else if (res?.data?.statusCode === 822001) {
60
60
  clearGatewayConfig();
61
- showErrorMessage(messageMap.requestError);
61
+ showErrorMessage(messageMap.requestError || messageMap.requestError);
62
62
  return Promise.reject(new Error(res?.data?.message));
63
63
  } else if (res?.data?.statusCode === 815001) {
64
- showErrorMessage(res?.data?.message);
64
+ showErrorMessage(res?.data?.message || messageMap.requestError);
65
65
  clearSsoAccessToken();
66
- location.href = getSsoLoginUrl();
66
+ window.location.href = getSsoLoginUrl() || '';
67
67
  return Promise.reject(new Error(res?.data?.message));
68
68
  } else if (res?.data?.statusCode === 815002) {
69
69
  axios.get('/sso-api/client/auth/getSsoRefreshToken').then(res => {
@@ -72,7 +72,7 @@ http.interceptors.response.use((res) => {
72
72
  return axios.request(res.config);
73
73
  })
74
74
  } else if (res?.data?.statusCode === 815003) {
75
- showErrorMessage(res?.data?.message);
75
+ showErrorMessage(res?.data?.message || messageMap.requestError);
76
76
  return Promise.reject(new Error(res?.data?.message));
77
77
  }
78
78
 
@@ -87,6 +87,7 @@ http.interceptors.response.use((res) => {
87
87
  if (statusCode !== 200) {
88
88
  errorMessage = message;
89
89
  }
90
+ errorMessage = errorMessage || messageMap.requestError
90
91
  } else {
91
92
  errorMessage = error?.message || messageMap.requestError;
92
93
  }
@@ -12,7 +12,7 @@ import 'vant/lib/index.css';
12
12
  import {http} from './httpConfig';
13
13
  import moment from 'moment';
14
14
 
15
- const initConfig = (app: any) => {
15
+ const initConfig = (app: any, config: any) => {
16
16
  app.config.globalProperties.$http = http;
17
17
  app.config.globalProperties.$moment = moment;
18
18
 
@@ -22,7 +22,10 @@ const initConfig = (app: any) => {
22
22
  } else {
23
23
  app.use(vant);
24
24
  }
25
-
25
+ if(config?.apiBaseUrl) {
26
+ http.defaults.baseURL = config?.apiBaseUrl;
27
+ }
28
+ (window as any).$config = Object.freeze(config);
26
29
  }
27
30
 
28
31
  export {initConfig} ;
@@ -5,7 +5,12 @@ import {getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem} from '
5
5
 
6
6
 
7
7
  const getSsoLoginUrl = (redirectUrl = '') => {
8
- let ssoLoginUrl = ((window as any).$config?.apiFullBaseUrl ?? '') + '/sso-api/server/sso/login';
8
+ let apiFullBaseUrl = (window as any).$config?.apiFullBaseUrl;
9
+ if(!apiFullBaseUrl) {
10
+ console.error('参数[apiFullBaseUrl]为空');
11
+ return;
12
+ }
13
+ let ssoLoginUrl = `${apiFullBaseUrl}/sso-api/server/sso/login`;
9
14
  if (!redirectUrl) {
10
15
  ssoLoginUrl += `?redirectUrl=${encodeURIComponent(window.location.href)}`;
11
16
  } else {
@@ -15,7 +20,12 @@ const getSsoLoginUrl = (redirectUrl = '') => {
15
20
  }
16
21
 
17
22
  const getSsoLogoutUrl = (redirectUrl = '') => {
18
- let ssoLogoutUrl = ((window as any).$config?.apiFullBaseUrl ?? '') + '/sso-api/server/sso/logout';
23
+ let apiFullBaseUrl = (window as any).$config?.apiFullBaseUrl;
24
+ if(!apiFullBaseUrl) {
25
+ console.error('参数[apiFullBaseUrl]为空');
26
+ return;
27
+ }
28
+ let ssoLogoutUrl = `${apiFullBaseUrl}/sso-api/server/sso/logout`;
19
29
  if (!redirectUrl) {
20
30
  ssoLogoutUrl += `?redirectUrl=${encodeURIComponent(window.location.href)}`;
21
31
  } else if (redirectUrl) {
@@ -54,6 +64,25 @@ const getSsoEncrypt = (password = '') => {
54
64
  return {encryptPassword, rsaAesKey};
55
65
  }
56
66
 
67
+ /**
68
+ * 获取sso加密参数列表
69
+ * @param password
70
+ */
71
+ const getSsoEncryptList = (passwordList = []) => {
72
+ let gatewayPublicKey = getLocalStorageItem('gatewayPublicKey');
73
+ // 每次请求生成aeskey
74
+ let aesKey = getAesRandomKey();
75
+ // 用登陆后后端生成并返回给前端的的RSA密钥对的公钥将AES16位密钥进行加密
76
+ const rsaAesKey = rsaEncrypt(gatewayPublicKey, aesKey);
77
+ // 使用AES16位的密钥将请求报文加密(使用的是加密前的aes密钥)
78
+ const encryptPasswordList = [];
79
+ for (let i = 0; i < passwordList.length; i++) {
80
+ encryptPasswordList[i] = aesEncrypt(aesKey, passwordList[i]);
81
+ }
82
+
83
+ return {encryptPasswordList, rsaAesKey};
84
+ }
85
+
57
86
 
58
87
  const ssoAccessTokenCookieKey: string = 'Sso-Access-Token';
59
88
  const ssoAccessTokenLocalKey: string = 'ssoAccessToken';
@@ -91,7 +120,7 @@ const clearSsoAccessToken = () => {
91
120
 
92
121
  const logoutSso = () => {
93
122
  clearSsoAccessToken();
94
- window.location.href = getSsoLogoutUrl();
123
+ window.location.href = getSsoLogoutUrl() || '';
95
124
  }
96
125
 
97
126
 
@@ -101,6 +130,7 @@ export {
101
130
  getSsoLoginRoutePath,
102
131
 
103
132
  getSsoEncrypt,
133
+ getSsoEncryptList,
104
134
 
105
135
  getSsoAccessToken,
106
136
  setSsoAccessToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {