chore:1.0.14
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tiesheng/npm-tool",
|
"name": "@tiesheng/npm-tool",
|
||||||
"version": "1.0.13",
|
"version": "1.0.14",
|
||||||
"description": "npm tool package",
|
"description": "npm tool package",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -99,9 +99,7 @@ async function req(url, options) {
|
|||||||
let data = res.data;
|
let data = res.data;
|
||||||
if (res.encrypt) {
|
if (res.encrypt) {
|
||||||
data = crypto.decrypt(data);
|
data = crypto.decrypt(data);
|
||||||
if (!Common.isEmpty(data)) {
|
data = Common.parseJSON(data, data);
|
||||||
data = Common.parseJSON(data, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resolve({data, recordsTotal: res.recordsTotal})
|
resolve({data, recordsTotal: res.recordsTotal})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
* 获取Url中的参数
|
* 获取Url中的参数
|
||||||
*/
|
*/
|
||||||
const getParamFormUrl = (key, host) => {
|
const getParamFormUrl = (key, host) => {
|
||||||
let arr;
|
let arr;
|
||||||
let reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)');
|
let reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)');
|
||||||
try {
|
try {
|
||||||
let testHost = window.location.href;
|
let testHost = window.location.href;
|
||||||
if (host) {
|
if (host) {
|
||||||
testHost = host;
|
testHost = host;
|
||||||
|
}
|
||||||
|
if ((arr = testHost.split('?')[1].match(reg))) {
|
||||||
|
return decodeURI(arr[2]);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
}
|
}
|
||||||
if ((arr = testHost.split('?')[1].match(reg))) {
|
return '';
|
||||||
return decodeURI(arr[2]);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ const getParamFormUrl = (key, host) => {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
const isEmpty = (value) => {
|
const isEmpty = (value) => {
|
||||||
return value === undefined || value === null || value === '';
|
return value === undefined || value === null || value === '';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,15 +32,12 @@ const isEmpty = (value) => {
|
|||||||
* @param def
|
* @param def
|
||||||
*/
|
*/
|
||||||
const parseJSON = (value, def = {}) => {
|
const parseJSON = (value, def = {}) => {
|
||||||
let obj;
|
let obj = def;
|
||||||
try {
|
try {
|
||||||
obj = JSON.parse(value);
|
obj = JSON.parse(value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
if (!obj) {
|
return obj;
|
||||||
obj = def;
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,10 +46,10 @@ const parseJSON = (value, def = {}) => {
|
|||||||
* @param seq
|
* @param seq
|
||||||
*/
|
*/
|
||||||
const split = (obj, seq = ',') => {
|
const split = (obj, seq = ',') => {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
return obj.split(seq);
|
return obj.split(seq);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +58,7 @@ const split = (obj, seq = ',') => {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
const isDevelopment = () => {
|
const isDevelopment = () => {
|
||||||
return process.env.NODE_ENV === 'development';
|
return process.env.NODE_ENV === 'development';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +69,7 @@ const isDevelopment = () => {
|
|||||||
* @param s2
|
* @param s2
|
||||||
*/
|
*/
|
||||||
const replaceAll = (string, s1, 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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
const endWith = (string = '', endStr) => {
|
const endWith = (string = '', endStr) => {
|
||||||
let d = string.length - endStr.length;
|
let d = string.length - endStr.length;
|
||||||
return d >= 0 && string.lastIndexOf(endStr) == d;
|
return d >= 0 && string.lastIndexOf(endStr) == d;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getParamFormUrl,
|
getParamFormUrl,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
parseJSON,
|
parseJSON,
|
||||||
split,
|
split,
|
||||||
isDevelopment,
|
isDevelopment,
|
||||||
replaceAll,
|
replaceAll,
|
||||||
endWith,
|
endWith,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user