yuang-framework-ui-common 1.0.43 → 1.0.44
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,
|
package/lib/utils/urlUtils.ts
CHANGED
@@ -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
|
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
|
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
|
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 {
|
89
|
+
export { getParameter, getParameterMap, removeParameter, getBaseUrl };
|