chore:1.0.14
This commit is contained in:
@@ -2,19 +2,19 @@
|
||||
* 获取Url中的参数
|
||||
*/
|
||||
const getParamFormUrl = (key, host) => {
|
||||
let arr;
|
||||
let reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)');
|
||||
try {
|
||||
let testHost = window.location.href;
|
||||
if (host) {
|
||||
testHost = host;
|
||||
let arr;
|
||||
let reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)');
|
||||
try {
|
||||
let testHost = window.location.href;
|
||||
if (host) {
|
||||
testHost = host;
|
||||
}
|
||||
if ((arr = testHost.split('?')[1].match(reg))) {
|
||||
return decodeURI(arr[2]);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
if ((arr = testHost.split('?')[1].match(reg))) {
|
||||
return decodeURI(arr[2]);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
return '';
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ const getParamFormUrl = (key, host) => {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isEmpty = (value) => {
|
||||
return value === undefined || value === null || value === '';
|
||||
return value === undefined || value === null || value === '';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -32,15 +32,12 @@ const isEmpty = (value) => {
|
||||
* @param def
|
||||
*/
|
||||
const parseJSON = (value, def = {}) => {
|
||||
let obj;
|
||||
try {
|
||||
obj = JSON.parse(value);
|
||||
} catch (e) {
|
||||
}
|
||||
if (!obj) {
|
||||
obj = def;
|
||||
}
|
||||
return obj;
|
||||
let obj = def;
|
||||
try {
|
||||
obj = JSON.parse(value);
|
||||
} catch (e) {
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -49,10 +46,10 @@ const parseJSON = (value, def = {}) => {
|
||||
* @param seq
|
||||
*/
|
||||
const split = (obj, seq = ',') => {
|
||||
if (obj) {
|
||||
return obj.split(seq);
|
||||
}
|
||||
return [];
|
||||
if (obj) {
|
||||
return obj.split(seq);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -61,7 +58,7 @@ const split = (obj, seq = ',') => {
|
||||
* @param url
|
||||
*/
|
||||
const isDevelopment = () => {
|
||||
return process.env.NODE_ENV === 'development';
|
||||
return process.env.NODE_ENV === 'development';
|
||||
};
|
||||
|
||||
|
||||
@@ -72,7 +69,7 @@ const isDevelopment = () => {
|
||||
* @param s2
|
||||
*/
|
||||
const replaceAll = (string, s1, s2) => {
|
||||
return string.replace(new RegExp(s1, 'gm'), s2);
|
||||
return string.replace(new RegExp(s1, 'gm'), s2);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -82,16 +79,16 @@ const replaceAll = (string, s1, s2) => {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const endWith = (string = '', endStr) => {
|
||||
let d = string.length - endStr.length;
|
||||
return d >= 0 && string.lastIndexOf(endStr) == d;
|
||||
let d = string.length - endStr.length;
|
||||
return d >= 0 && string.lastIndexOf(endStr) == d;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getParamFormUrl,
|
||||
isEmpty,
|
||||
parseJSON,
|
||||
split,
|
||||
isDevelopment,
|
||||
replaceAll,
|
||||
endWith,
|
||||
getParamFormUrl,
|
||||
isEmpty,
|
||||
parseJSON,
|
||||
split,
|
||||
isDevelopment,
|
||||
replaceAll,
|
||||
endWith,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user