yuang-framework-ui-common 1.0.43 → 1.0.45

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.
@@ -4,12 +4,12 @@ import { ElMessageBox } from 'element-plus/es';
4
4
 
5
5
 
6
6
 
7
- const alertMessageBox = ({title, message, confirmButtonText, callback}) => {
7
+ const alertMessageBox = ({title, message, confirmButtonText, callback}: {title: string, message: string, confirmButtonText: string, callback: (param:string)=>{}}) => {
8
8
  if(isPc()) {
9
9
  ElMessageBox.close();
10
10
  ElMessageBox.alert(message, title, {
11
11
  confirmButtonText: confirmButtonText,
12
- callback: (action) => {
12
+ callback: (action: string) => {
13
13
  callback && callback(action);
14
14
  },
15
15
  type: 'warning',
@@ -4,28 +4,28 @@ import {ElMessage} from 'element-plus'
4
4
  import {showNotify} from 'vant';
5
5
 
6
6
 
7
- const showSuccessMessage = (message) => {
7
+ const showSuccessMessage = (message: string) => {
8
8
  showMessage({
9
9
  type: 'success',
10
10
  message: message,
11
11
  });
12
12
  }
13
13
 
14
- const showWarningMessage = (message) => {
14
+ const showWarningMessage = (message: string) => {
15
15
  showMessage({
16
16
  type: 'warning',
17
17
  message: message,
18
18
  });
19
19
  }
20
20
 
21
- const showInfoMessage = (message) => {
21
+ const showInfoMessage = (message: string) => {
22
22
  showMessage({
23
23
  type: 'info',
24
24
  message: message,
25
25
  });
26
26
  }
27
27
 
28
- const showErrorMessage = (message) => {
28
+ const showErrorMessage = (message: string) => {
29
29
  showMessage({
30
30
  type: 'error',
31
31
  message: message,
@@ -37,7 +37,7 @@ const showErrorMessage = (message) => {
37
37
  * @param type 'success' | 'warning' | 'info' | 'error'
38
38
  * @param message
39
39
  */
40
- const showMessage = ({type, message}) => {
40
+ const showMessage = ({type, message}: {type: any, message: any}) => {
41
41
  if (isPc()) {
42
42
  ElMessage({
43
43
  type: type,
@@ -33,17 +33,17 @@ const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
33
33
  }
34
34
 
35
35
  /**
36
- * 获取sso登录路由路径
36
+ * 获取sso认证路由路径
37
37
  * @param ssoRedirectRoutePath
38
38
  */
39
- const getSsoLoginRoutePath = (ssoRedirectRoutePath = '') => {
40
- let ssoLoginRoutePath = '/sso/login/index';
39
+ const getSsoAuthRoutePath = (ssoRedirectRoutePath = '') => {
40
+ let ssoAuthRoutePath = '/sso/auth/index';
41
41
  if (!ssoRedirectRoutePath) {
42
- ssoLoginRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent('/sso/login/login-success')}`;
42
+ ssoAuthRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent('/sso/auth/auth-success')}`;
43
43
  } else {
44
- ssoLoginRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent(ssoRedirectRoutePath)}`;
44
+ ssoAuthRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent(ssoRedirectRoutePath)}`;
45
45
  }
46
- return ssoLoginRoutePath;
46
+ return ssoAuthRoutePath;
47
47
  }
48
48
 
49
49
  /**
@@ -160,7 +160,7 @@ const logoutSso = () => {
160
160
  export {
161
161
  getSsoLoginUrl,
162
162
  getSsoLogoutUrl,
163
- getSsoLoginRoutePath,
163
+ getSsoAuthRoutePath,
164
164
 
165
165
  getSsoEncrypt,
166
166
  getSsoEncryptList,
@@ -1,44 +1,11 @@
1
1
 
2
- /**
3
- * 删除url中的指定参数
4
- * @param url
5
- * @param parameter
6
- * @return {string}
7
- */
8
- const removeUrlParameter = (url: string, parameter: string) => {
9
- if (!url) {
10
- return console.error('参数[url]为空');
11
- }
12
- if (!parameter) {
13
- return console.error('参数[parameter]为空');
14
- }
15
- let urlObj;
16
- let isFullUrl = url.startsWith('http');
17
- if (isFullUrl) {
18
- urlObj = new URL(url);
19
- } else {
20
- urlObj = new URL(url, window.location.origin);
21
- }
22
- urlObj.searchParams.delete(parameter);
23
- let result = urlObj.pathname + urlObj.search;
24
- if (url.includes('#')) {
25
- result += '#' + url.split('#')[1];
26
- }
27
- if (isFullUrl) {
28
- result = urlObj.origin + result;
29
- }
30
- return result;
31
- };
32
-
33
-
34
-
35
2
  /**
36
3
  * 获取url的参数
37
4
  * @param name 参数名
38
5
  * @param url,如果不传递,就使用当前url
39
6
  * @returns {string|null}
40
7
  */
41
- const getParameter = (name: string, url: string) => {
8
+ const getParameter = (name: string, url?: string) => {
42
9
  url = url || window.location.search;
43
10
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
44
11
  var r = url.substr(1).match(reg);
@@ -51,7 +18,7 @@ const getParameter = (name: string, url: string) => {
51
18
  * @param url,如果不传递,就使用当前url
52
19
  * @returns {map|null}
53
20
  */
54
- const getParameterMap = (url: string) => {
21
+ const getParameterMap = (url?: string) => {
55
22
  url = url || window.location.search;
56
23
 
57
24
  let arrObj = url.split("?") as any;
@@ -66,13 +33,42 @@ const getParameterMap = (url: string) => {
66
33
  return params;
67
34
  }
68
35
 
36
+ /**
37
+ * 删除url中的指定参数
38
+ * @param url,如果不传递,就使用当前url
39
+ * @param parameter
40
+ * @return {string}
41
+ */
42
+ const removeParameter = (name: string, url?: string) => {
43
+ if (!name) {
44
+ return console.error('参数[name]为空');
45
+ }
46
+ url = url || location.href;
47
+ let urlObj;
48
+ let isFullUrl = url.startsWith('http');
49
+ if (isFullUrl) {
50
+ urlObj = new URL(url);
51
+ } else {
52
+ urlObj = new URL(url, window.location.origin);
53
+ }
54
+ urlObj.searchParams.delete(name);
55
+ let result = urlObj.pathname + urlObj.search;
56
+ if (url.includes('#')) {
57
+ result += '#' + url.split('#')[1];
58
+ }
59
+ if (isFullUrl) {
60
+ result = urlObj.origin + result;
61
+ }
62
+ return result;
63
+ };
64
+
69
65
 
70
66
  /**
71
67
  * 获取平台基础url
72
- * @param url
68
+ * @param url,如果不传递,就使用当前url
73
69
  * @returns {string}
74
70
  */
75
- const getBaseUrl = (url: string) => {
71
+ const getBaseUrl = (url?: string) => {
76
72
  url = url || location.href;
77
73
  let arr = url.split('/');
78
74
  if (arr.length > 3) {
@@ -90,4 +86,4 @@ const getBaseUrl = (url: string) => {
90
86
  }
91
87
  };
92
88
 
93
- export { removeUrlParameter, getParameter, getParameterMap, getBaseUrl };
89
+ export { getParameter, getParameterMap, removeParameter, getBaseUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  import {createRouter, createWebHistory} from 'vue-router'
2
2
  import {getExceptionRoutes} from '../../lib/utils/vueRouterUtils'
3
3
 
4
- import { getSsoAccessToken, getSsoLoginRoutePath } from '../../lib/utils/ssoUtils';
4
+ import { getSsoAccessToken, getSsoAuthRoutePath } from '../../lib/utils/ssoUtils';
5
5
 
6
6
 
7
7
  const router = createRouter({
@@ -53,7 +53,7 @@ const router = createRouter({
53
53
  router.beforeEach(async (to) => {
54
54
  if (!getSsoAccessToken()) {
55
55
  if (!to.meta?.isAnonymous) {
56
- return getSsoLoginRoutePath(to.fullPath);
56
+ return getSsoAuthRoutePath(to.fullPath);
57
57
  }
58
58
  return;
59
59
  }
@@ -7,7 +7,7 @@
7
7
  import { useRouter } from 'vue-router';
8
8
 
9
9
  import { getSsoLoginUrl, setSsoAccessToken } from '../../../../lib/utils/ssoUtils';
10
- import { removeUrlParameter } from '../../../../lib/utils/urlUtils';
10
+ import { removeParameter } from '../../../../lib/utils/urlUtils';
11
11
 
12
12
  const router = useRouter();
13
13
 
@@ -25,7 +25,7 @@
25
25
  setSsoAccessToken(res.data.data);
26
26
  let ssoRedirectRoutePath = router.currentRoute.value.query.ssoRedirectRoutePath as string;
27
27
  ssoRedirectRoutePath = (ssoRedirectRoutePath && decodeURIComponent(ssoRedirectRoutePath)) || ('/sso/login/login-success' as any);
28
- ssoRedirectRoutePath = removeUrlParameter(ssoRedirectRoutePath, 'ssoAuthCode');
28
+ ssoRedirectRoutePath = removeParameter('ssoAuthCode', ssoRedirectRoutePath) || '';
29
29
  router.push(ssoRedirectRoutePath);
30
30
  });
31
31
  });