chore:1.0.14
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tiesheng/npm-tool",
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.14",
|
||||
"description": "npm tool package",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -99,9 +99,7 @@ async function req(url, options) {
|
||||
let data = res.data;
|
||||
if (res.encrypt) {
|
||||
data = crypto.decrypt(data);
|
||||
if (!Common.isEmpty(data)) {
|
||||
data = Common.parseJSON(data, data);
|
||||
}
|
||||
data = Common.parseJSON(data, data);
|
||||
}
|
||||
resolve({data, recordsTotal: res.recordsTotal})
|
||||
} else {
|
||||
|
||||
@@ -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