@wzyjs/types 0.0.28
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.
- package/dist/cjs/common/index.d.ts +6 -0
- package/dist/cjs/common/tools/index.d.ts +4 -0
- package/dist/cjs/common/tools/number.d.ts +3 -0
- package/dist/cjs/common/tools/number.js +34 -0
- package/dist/cjs/common/tools/object.d.ts +10 -0
- package/dist/cjs/common/tools/object.js +43 -0
- package/dist/cjs/common/tools/other.d.ts +26 -0
- package/dist/cjs/common/tools/other.js +112 -0
- package/dist/cjs/common/tools/string.d.ts +16 -0
- package/dist/cjs/common/tools/string.js +137 -0
- package/dist/cjs/common/types/index.d.ts +20 -0
- package/dist/cjs/fe/dayjs.d.ts +4 -0
- package/dist/cjs/fe/element.d.ts +9 -0
- package/dist/cjs/fe/index.d.ts +20 -0
- package/dist/cjs/fe/middlewares/error.d.ts +3 -0
- package/dist/cjs/fe/middlewares/index.d.ts +1 -0
- package/dist/cjs/fe/other.d.ts +1 -0
- package/dist/cjs/fe/style.d.ts +10 -0
- package/dist/cjs/index_all.d.ts +3 -0
- package/dist/cjs/index_fe.d.ts +2 -0
- package/dist/cjs/index_rd.d.ts +2 -0
- package/dist/cjs/index_rd.js +141 -0
- package/dist/cjs/rd/database/Collection.d.ts +22 -0
- package/dist/cjs/rd/database/Collection.js +202 -0
- package/dist/cjs/rd/database/Database.d.ts +10 -0
- package/dist/cjs/rd/database/Database.js +25 -0
- package/dist/cjs/rd/database/index.d.ts +2 -0
- package/dist/cjs/rd/database/types.d.ts +151 -0
- package/dist/cjs/rd/database/types.js +25 -0
- package/dist/cjs/rd/database/utils.d.ts +3 -0
- package/dist/cjs/rd/database/utils.js +30 -0
- package/dist/cjs/rd/index.d.ts +3 -0
- package/dist/cjs/rd/jsonFile/index.d.ts +6 -0
- package/dist/cjs/rd/jsonFile/index.js +29 -0
- package/dist/cjs/rd/mail/index.d.ts +1 -0
- package/dist/cjs/rd/mail/index.js +31 -0
- package/dist/cjs/rd/middlewares/index.d.ts +1 -0
- package/dist/cjs/rd/middlewares/logger.d.ts +1 -0
- package/dist/esm/common/index.d.ts +6 -0
- package/dist/esm/common/tools/index.d.ts +4 -0
- package/dist/esm/common/tools/number.d.ts +3 -0
- package/dist/esm/common/tools/number.js +30 -0
- package/dist/esm/common/tools/object.d.ts +10 -0
- package/dist/esm/common/tools/object.js +39 -0
- package/dist/esm/common/tools/other.d.ts +26 -0
- package/dist/esm/common/tools/other.js +106 -0
- package/dist/esm/common/tools/string.d.ts +16 -0
- package/dist/esm/common/tools/string.js +120 -0
- package/dist/esm/common/types/index.d.ts +20 -0
- package/dist/esm/fe/dayjs.d.ts +4 -0
- package/dist/esm/fe/dayjs.js +18 -0
- package/dist/esm/fe/element.d.ts +9 -0
- package/dist/esm/fe/element.js +36 -0
- package/dist/esm/fe/index.d.ts +20 -0
- package/dist/esm/fe/index.js +16 -0
- package/dist/esm/fe/middlewares/error.d.ts +3 -0
- package/dist/esm/fe/middlewares/error.js +22 -0
- package/dist/esm/fe/middlewares/index.d.ts +1 -0
- package/dist/esm/fe/other.d.ts +1 -0
- package/dist/esm/fe/other.js +10 -0
- package/dist/esm/fe/style.d.ts +10 -0
- package/dist/esm/fe/style.js +45 -0
- package/dist/esm/index_all.d.ts +3 -0
- package/dist/esm/index_fe.d.ts +2 -0
- package/dist/esm/index_fe.js +19 -0
- package/dist/esm/index_rd.d.ts +2 -0
- package/dist/esm/rd/database/Collection.d.ts +22 -0
- package/dist/esm/rd/database/Database.d.ts +10 -0
- package/dist/esm/rd/database/index.d.ts +2 -0
- package/dist/esm/rd/database/types.d.ts +151 -0
- package/dist/esm/rd/database/utils.d.ts +3 -0
- package/dist/esm/rd/index.d.ts +3 -0
- package/dist/esm/rd/jsonFile/index.d.ts +6 -0
- package/dist/esm/rd/mail/index.d.ts +1 -0
- package/index.ts +40 -0
- package/package.json +16 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop } from 'lodash';
|
|
2
|
+
export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop, };
|
|
3
|
+
export * as consola from 'consola';
|
|
4
|
+
export * from './tools';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { default as _ } from 'lodash';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 取指定范围内的随机数
|
|
4
|
+
const getRandomNum = (min, max) => {
|
|
5
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
6
|
+
};
|
|
7
|
+
// 指定小数点的位数
|
|
8
|
+
const limitDecimals = (v, num = 2, isForce) => {
|
|
9
|
+
let value = parseFloat(v);
|
|
10
|
+
if (isNaN(value)) {
|
|
11
|
+
if (isForce) {
|
|
12
|
+
value = 0;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return value.toFixed(num).toString();
|
|
19
|
+
};
|
|
20
|
+
// 转换成更易读的尺寸单位
|
|
21
|
+
const getFileSize = (size) => {
|
|
22
|
+
let d = 'G';
|
|
23
|
+
let s = size / 1024 / 1024 / 1024;
|
|
24
|
+
if (s < 1) {
|
|
25
|
+
d = 'M';
|
|
26
|
+
s *= 1024;
|
|
27
|
+
}
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
return `${(s.toFixed(1) / 1).toString()}${d}`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getFileSize = getFileSize;
|
|
33
|
+
exports.getRandomNum = getRandomNum;
|
|
34
|
+
exports.limitDecimals = limitDecimals;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const findItem: <I>(list: I[], attr: keyof I, value?: I[keyof I] | undefined) => I | undefined;
|
|
2
|
+
export declare const filterParams: (params: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}) => {};
|
|
5
|
+
export declare const watch: {
|
|
6
|
+
observe(obj: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}, key: string, watchFun: (value: any, val: any) => undefined): void;
|
|
9
|
+
setWatcher(data?: {}, watch?: {}): void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 判断是否有包含指定属性的对象,第三个参数可以指定具体的值
|
|
4
|
+
const findItem = (list, attr, value) => {
|
|
5
|
+
return list.find((item) => value === undefined ? item[attr] : item[attr] === value);
|
|
6
|
+
};
|
|
7
|
+
// 过滤对象中为undefined的属性
|
|
8
|
+
const filterParams = (params) => {
|
|
9
|
+
return Object.entries(params || {}).reduce((obj, [key, value]) => {
|
|
10
|
+
if (value !== undefined) {
|
|
11
|
+
obj[key] = value;
|
|
12
|
+
}
|
|
13
|
+
return obj;
|
|
14
|
+
}, {});
|
|
15
|
+
};
|
|
16
|
+
// 监听属性
|
|
17
|
+
const watch = {
|
|
18
|
+
observe(obj, key, watchFun) {
|
|
19
|
+
// 给该属性设默认值
|
|
20
|
+
const val = obj[key];
|
|
21
|
+
Object.defineProperty(obj, key, {
|
|
22
|
+
configurable: true,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
set(value) {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
// 赋值(set)时,调用对应函数
|
|
27
|
+
watchFun(value, val);
|
|
28
|
+
},
|
|
29
|
+
get() {
|
|
30
|
+
return val;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
setWatcher(data = {}, watch = {}) {
|
|
35
|
+
Object.keys(watch).forEach(v => {
|
|
36
|
+
this.observe(data, v, watch[v]); // 监听data内的v属性,传入watch内对应函数以调用
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.filterParams = filterParams;
|
|
42
|
+
exports.findItem = findItem;
|
|
43
|
+
exports.watch = watch;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
|
|
2
|
+
export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
|
|
3
|
+
page: {
|
|
4
|
+
size?: number | undefined;
|
|
5
|
+
current?: number | undefined;
|
|
6
|
+
};
|
|
7
|
+
where: KeyValue<string, string | number | boolean | RegExp>;
|
|
8
|
+
order?: OrderParams<string> | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[]>;
|
|
14
|
+
export declare const executePromise: (promise: Promise<any>) => Promise<{
|
|
15
|
+
result: any;
|
|
16
|
+
time: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const locationFn: {
|
|
19
|
+
url2Params: (url?: string) => {};
|
|
20
|
+
params2Url: (params: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}) => string;
|
|
23
|
+
setUrlParams: (key: string, value: any, keepName: string) => void;
|
|
24
|
+
urlGetPath: (url?: string) => string;
|
|
25
|
+
};
|
|
26
|
+
export declare const delay: (time?: number) => Promise<unknown>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lodash = require('lodash');
|
|
4
|
+
|
|
5
|
+
// 处理 ProComponents 中 ProTable 参数中的 page 和 where 和 sort
|
|
6
|
+
const handleParams = (params, sort) => {
|
|
7
|
+
if (!params) {
|
|
8
|
+
return {
|
|
9
|
+
page: {},
|
|
10
|
+
where: {},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const { current, pageSize, ...other } = params;
|
|
14
|
+
return {
|
|
15
|
+
page: {
|
|
16
|
+
current: current || 1,
|
|
17
|
+
size: pageSize || 10,
|
|
18
|
+
},
|
|
19
|
+
where: Object.entries(other).reduce((acc, [key, value]) => {
|
|
20
|
+
if (key && value) {
|
|
21
|
+
acc[key] = typeof value === 'string' ? new RegExp(value) : value;
|
|
22
|
+
}
|
|
23
|
+
return acc;
|
|
24
|
+
}, {}),
|
|
25
|
+
order: sort && {
|
|
26
|
+
field: Object.keys(sort)[0],
|
|
27
|
+
type: Object.values(sort)[0] === 'ascend' ? 'asc' : 'desc',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
// 将 list 的数据处理为 { label: string, value: string }[]
|
|
32
|
+
const handleRes2List = async (reqPromise) => {
|
|
33
|
+
const { data } = await reqPromise();
|
|
34
|
+
return (data?.list || []).map((item) => ({
|
|
35
|
+
label: item.name,
|
|
36
|
+
value: item._id || item.key,
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
// 计算执行 promise 花费的时间
|
|
40
|
+
const executePromise = async (promise) => {
|
|
41
|
+
const start = Date.now();
|
|
42
|
+
const result = await promise;
|
|
43
|
+
const time = Date.now() - start;
|
|
44
|
+
return {
|
|
45
|
+
result,
|
|
46
|
+
time,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
// 地址栏方面的操作
|
|
50
|
+
const locationFn = {
|
|
51
|
+
// url地址的query转为query对象
|
|
52
|
+
url2Params: (url = location.href) => {
|
|
53
|
+
url = decodeURIComponent(url);
|
|
54
|
+
let jsonList = {};
|
|
55
|
+
if (url.indexOf('?') > -1) {
|
|
56
|
+
let str = url.slice(url.indexOf('?') + 1);
|
|
57
|
+
let strs = str.split('&');
|
|
58
|
+
for (let i = 0; i < strs.length; i++) {
|
|
59
|
+
jsonList[strs[i].split('=')[0]] = strs[i].split('=')[1]; // 如果出现乱码的话,可以用decodeURI()进行解码
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return jsonList || {};
|
|
63
|
+
},
|
|
64
|
+
// 参数对象转换为url
|
|
65
|
+
params2Url: (params) => {
|
|
66
|
+
let url = '';
|
|
67
|
+
for (let k in params) {
|
|
68
|
+
if (k) {
|
|
69
|
+
url += `${k}=${params[k]}&`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return url.substr(0, url.length - 1);
|
|
73
|
+
},
|
|
74
|
+
// 设置地址栏参数
|
|
75
|
+
setUrlParams: (key, value, keepName) => {
|
|
76
|
+
if (key === undefined || value === undefined)
|
|
77
|
+
return;
|
|
78
|
+
// 给地址栏参数对象添加指定参数
|
|
79
|
+
let allParams = locationFn.url2Params();
|
|
80
|
+
if (keepName) {
|
|
81
|
+
allParams = lodash.pick(allParams, keepName) || {};
|
|
82
|
+
}
|
|
83
|
+
allParams[key] = encodeURIComponent(value);
|
|
84
|
+
// 域名和路径
|
|
85
|
+
const url = location.href;
|
|
86
|
+
const sliceEnd = url.indexOf('?') === -1 ? url.length : url.indexOf('?');
|
|
87
|
+
const domainPath = url.slice(0, sliceEnd);
|
|
88
|
+
// 参数
|
|
89
|
+
const params = locationFn.params2Url(allParams);
|
|
90
|
+
// 修改地址栏url
|
|
91
|
+
location.replace(`${domainPath}?${params}`);
|
|
92
|
+
},
|
|
93
|
+
// 取地址栏的path部分
|
|
94
|
+
urlGetPath: (url = location.href) => {
|
|
95
|
+
// 计算要截取的最后一位
|
|
96
|
+
let lastIndex = url.indexOf('?');
|
|
97
|
+
if (lastIndex === -1) {
|
|
98
|
+
lastIndex = url.length;
|
|
99
|
+
}
|
|
100
|
+
return url.slice(0, lastIndex);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
// 延迟指定毫秒数
|
|
104
|
+
const delay = (time = 1000) => {
|
|
105
|
+
return new Promise(resolve => setTimeout(resolve, time));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.delay = delay;
|
|
109
|
+
exports.executePromise = executePromise;
|
|
110
|
+
exports.handleParams = handleParams;
|
|
111
|
+
exports.handleRes2List = handleRes2List;
|
|
112
|
+
exports.locationFn = locationFn;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getChineseByStr: (str: string) => string;
|
|
2
|
+
export declare const getStrLength: (value: string) => number;
|
|
3
|
+
export declare const replaceAll: (str: string, searchValue: string, replaceValue: string) => string;
|
|
4
|
+
export declare const replaceByRules: (str: string, rules: [string, string][]) => string;
|
|
5
|
+
export declare const getType: (value: any) => string;
|
|
6
|
+
export declare const amount: (str: string) => string;
|
|
7
|
+
export declare const jsonParse: (value: string | object) => object;
|
|
8
|
+
export declare const isJson: (str: string) => boolean;
|
|
9
|
+
export declare const toString: (value: any) => string;
|
|
10
|
+
export declare const getRandomColor: () => string;
|
|
11
|
+
export declare const getRandomString: (length?: number) => string;
|
|
12
|
+
export declare const getChinese: (str: string) => string;
|
|
13
|
+
export declare const getSliceStr: (str: string, before: string, after: string) => string;
|
|
14
|
+
export declare const getProxyUrl: (url: string) => string;
|
|
15
|
+
export declare const getLength: (value: string) => number;
|
|
16
|
+
export declare const getCookie: (name: string) => string | null;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 获取字符串中的中文字符串
|
|
4
|
+
const getChineseByStr = (str) => {
|
|
5
|
+
if (!str) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
const match = str.match(/[\u4e00-\u9fa5]/g);
|
|
9
|
+
if (!match) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
return match.join('');
|
|
13
|
+
};
|
|
14
|
+
// 获取字符串中的长度,中文算 2 个字符
|
|
15
|
+
const getStrLength = (value) => {
|
|
16
|
+
if (!value) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
const chineseLength = getChineseByStr(value).length;
|
|
20
|
+
return (value.length - chineseLength) + chineseLength * 2;
|
|
21
|
+
};
|
|
22
|
+
// 替换全部指定字符串
|
|
23
|
+
const replaceAll = (str, searchValue, replaceValue) => {
|
|
24
|
+
if (!str || !searchValue || !replaceValue) {
|
|
25
|
+
return str || '';
|
|
26
|
+
}
|
|
27
|
+
str = str.replace(searchValue, replaceValue);
|
|
28
|
+
if (!str.includes(searchValue)) {
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
return replaceAll(str, searchValue, replaceValue);
|
|
32
|
+
};
|
|
33
|
+
// 根据规则替换字符串
|
|
34
|
+
const replaceByRules = (str, rules) => {
|
|
35
|
+
rules.forEach(([searchValue, replaceValue]) => {
|
|
36
|
+
str = str.replaceAll(searchValue, replaceValue);
|
|
37
|
+
});
|
|
38
|
+
return str;
|
|
39
|
+
};
|
|
40
|
+
// 获取变量的类型
|
|
41
|
+
const getType = (value) => {
|
|
42
|
+
return Object.prototype.toString.call(value).slice(8, -1);
|
|
43
|
+
};
|
|
44
|
+
// 金钱格式化,每三位加,
|
|
45
|
+
const amount = (str) => {
|
|
46
|
+
const reg = /(?=(?!\b)(\d{3})+$)/g;
|
|
47
|
+
return str.replace(reg, ',');
|
|
48
|
+
};
|
|
49
|
+
// 更安全的 JSON.parse
|
|
50
|
+
const jsonParse = (value) => {
|
|
51
|
+
if (typeof value === 'object') {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(value);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// 是否为json字符串
|
|
62
|
+
const isJson = (str) => {
|
|
63
|
+
try {
|
|
64
|
+
if (getType(JSON.parse(str)) === 'Object') {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
// 将变量转为字符串
|
|
73
|
+
const toString = (value) => {
|
|
74
|
+
return Object.prototype.toString.call(value).slice(8, -1) === 'object' ? JSON.stringify(value) : String(value);
|
|
75
|
+
};
|
|
76
|
+
// 生成随机颜色
|
|
77
|
+
const getRandomColor = () => {
|
|
78
|
+
const color = Math.floor(Math.random() * 16777215).toString(16);
|
|
79
|
+
if (color.length === 6) {
|
|
80
|
+
return color;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return getRandomColor();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
// 生成随机字符串
|
|
87
|
+
const getRandomString = (length = 4) => {
|
|
88
|
+
return Math.random().toString(36).substr(2, length);
|
|
89
|
+
};
|
|
90
|
+
// 获取字符串内的中文
|
|
91
|
+
const getChinese = (str) => {
|
|
92
|
+
if (str == null || str === '') {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
96
|
+
if (!res) {
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
return res.join('');
|
|
100
|
+
};
|
|
101
|
+
// 截取指定两个文本之间的字符串 (不好用)
|
|
102
|
+
const getSliceStr = (str, before, after) => {
|
|
103
|
+
return str.slice(str.indexOf(before) + before.length, str.lastIndexOf(after));
|
|
104
|
+
};
|
|
105
|
+
// 获取代理后的url
|
|
106
|
+
const getProxyUrl = (url) => {
|
|
107
|
+
const beforeUrl = 'https://1141871752167714.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/a.LATEST/proxy/?url=';
|
|
108
|
+
return beforeUrl + url;
|
|
109
|
+
};
|
|
110
|
+
// 获取字符串的长度
|
|
111
|
+
const getLength = (value) => {
|
|
112
|
+
const chineseLength = getChinese(value).length;
|
|
113
|
+
return (value.length - chineseLength) + chineseLength * 2;
|
|
114
|
+
};
|
|
115
|
+
// 获取指定cookie
|
|
116
|
+
const getCookie = (name) => {
|
|
117
|
+
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
118
|
+
const arr = document.cookie.match(reg);
|
|
119
|
+
return arr ? unescape(arr[2]) : null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
exports.amount = amount;
|
|
123
|
+
exports.getChinese = getChinese;
|
|
124
|
+
exports.getChineseByStr = getChineseByStr;
|
|
125
|
+
exports.getCookie = getCookie;
|
|
126
|
+
exports.getLength = getLength;
|
|
127
|
+
exports.getProxyUrl = getProxyUrl;
|
|
128
|
+
exports.getRandomColor = getRandomColor;
|
|
129
|
+
exports.getRandomString = getRandomString;
|
|
130
|
+
exports.getSliceStr = getSliceStr;
|
|
131
|
+
exports.getStrLength = getStrLength;
|
|
132
|
+
exports.getType = getType;
|
|
133
|
+
exports.isJson = isJson;
|
|
134
|
+
exports.jsonParse = jsonParse;
|
|
135
|
+
exports.replaceAll = replaceAll;
|
|
136
|
+
exports.replaceByRules = replaceByRules;
|
|
137
|
+
exports.toString = toString;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface RequestRes<D = any> {
|
|
2
|
+
success?: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
data?: D;
|
|
5
|
+
}
|
|
6
|
+
export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>;
|
|
7
|
+
export interface Pagination {
|
|
8
|
+
current?: number;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
}
|
|
11
|
+
export type SortParams<D extends object | string = string> = Record<D extends string ? string : keyof D, 'ascend' | 'descend'>;
|
|
12
|
+
export type OrderParams<D extends object | string = string> = {
|
|
13
|
+
field: D extends string ? string : keyof D;
|
|
14
|
+
type: 'asc' | 'desc';
|
|
15
|
+
};
|
|
16
|
+
export interface Option<V extends string | number = string> {
|
|
17
|
+
label: string;
|
|
18
|
+
value: V;
|
|
19
|
+
children?: Option<V>[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const scrollIntoView: (el: Element, option?: ScrollIntoViewOptions) => void;
|
|
2
|
+
export declare const getElement: (el: string | Element) => {
|
|
3
|
+
element: null;
|
|
4
|
+
originalStyle: {};
|
|
5
|
+
} | {
|
|
6
|
+
element: Element;
|
|
7
|
+
originalStyle: CSSStyleDeclaration;
|
|
8
|
+
};
|
|
9
|
+
export declare const isElementInViewport: (el: string | Element) => boolean | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import md5 from 'md5';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import copy from 'copy-to-clipboard';
|
|
4
|
+
import anime from 'animejs';
|
|
5
|
+
export { copy, classnames, md5, anime };
|
|
6
|
+
export declare const localforage: {
|
|
7
|
+
config: {
|
|
8
|
+
(options: LocalForageOptions): boolean;
|
|
9
|
+
(options: string): any;
|
|
10
|
+
(): LocalForageOptions;
|
|
11
|
+
};
|
|
12
|
+
setItem: <T>(key: string, value: T, callback?: ((err: any, value: T) => void) | undefined) => Promise<T>;
|
|
13
|
+
getItem: <T_1>(key: string, callback?: ((err: any, value: T_1 | null) => void) | undefined) => Promise<T_1 | null>;
|
|
14
|
+
removeItem: (key: string, callback?: ((err: any) => void) | undefined) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export { default as dayjs, Dayjs } from './dayjs';
|
|
17
|
+
export * from './style';
|
|
18
|
+
export * from './element';
|
|
19
|
+
export * from './other';
|
|
20
|
+
export * from './middlewares';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './error';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readClipboard: () => Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const hexToRgba: (hexColor: string, a?: number) => {
|
|
2
|
+
nums: {
|
|
3
|
+
red: number;
|
|
4
|
+
green: number;
|
|
5
|
+
blue: number;
|
|
6
|
+
};
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const flashBackground: (el: string | Element, color: string, a?: number) => void;
|
|
10
|
+
export declare const flashBorder: (el: string | Element, color: string, a?: number) => void;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lodash = require('lodash');
|
|
4
|
+
var consola = require('consola');
|
|
5
|
+
var string = require('./common/tools/string.js');
|
|
6
|
+
var object = require('./common/tools/object.js');
|
|
7
|
+
var other = require('./common/tools/other.js');
|
|
8
|
+
var number = require('./common/tools/number.js');
|
|
9
|
+
var Database = require('./rd/database/Database.js');
|
|
10
|
+
var index = require('./rd/jsonFile/index.js');
|
|
11
|
+
var index$1 = require('./rd/mail/index.js');
|
|
12
|
+
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var consola__namespace = /*#__PURE__*/_interopNamespaceDefault(consola);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
exports._ = lodash;
|
|
35
|
+
Object.defineProperty(exports, 'cloneDeep', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return lodash.cloneDeep; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, 'debounce', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return lodash.debounce; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, 'find', {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return lodash.find; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, 'groupBy', {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return lodash.groupBy; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, 'isBoolean', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return lodash.isBoolean; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'isEmpty', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return lodash.isEmpty; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, 'isEqual', {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return lodash.isEqual; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, 'isError', {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return lodash.isError; }
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, 'isFunction', {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return lodash.isFunction; }
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () { return lodash.isNumber; }
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, 'isObject', {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () { return lodash.isObject; }
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'isString', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () { return lodash.isString; }
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, 'merge', {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () { return lodash.merge; }
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, 'noop', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () { return lodash.noop; }
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, 'omit', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () { return lodash.omit; }
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, 'pick', {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () { return lodash.pick; }
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, 'uniq', {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () { return lodash.uniq; }
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, 'uniqBy', {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () { return lodash.uniqBy; }
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'uniqWith', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () { return lodash.uniqWith; }
|
|
110
|
+
});
|
|
111
|
+
exports.consola = consola__namespace;
|
|
112
|
+
exports.amount = string.amount;
|
|
113
|
+
exports.getChinese = string.getChinese;
|
|
114
|
+
exports.getChineseByStr = string.getChineseByStr;
|
|
115
|
+
exports.getCookie = string.getCookie;
|
|
116
|
+
exports.getLength = string.getLength;
|
|
117
|
+
exports.getProxyUrl = string.getProxyUrl;
|
|
118
|
+
exports.getRandomColor = string.getRandomColor;
|
|
119
|
+
exports.getRandomString = string.getRandomString;
|
|
120
|
+
exports.getSliceStr = string.getSliceStr;
|
|
121
|
+
exports.getStrLength = string.getStrLength;
|
|
122
|
+
exports.getType = string.getType;
|
|
123
|
+
exports.isJson = string.isJson;
|
|
124
|
+
exports.jsonParse = string.jsonParse;
|
|
125
|
+
exports.replaceAll = string.replaceAll;
|
|
126
|
+
exports.replaceByRules = string.replaceByRules;
|
|
127
|
+
exports.toString = string.toString;
|
|
128
|
+
exports.filterParams = object.filterParams;
|
|
129
|
+
exports.findItem = object.findItem;
|
|
130
|
+
exports.watch = object.watch;
|
|
131
|
+
exports.delay = other.delay;
|
|
132
|
+
exports.executePromise = other.executePromise;
|
|
133
|
+
exports.handleParams = other.handleParams;
|
|
134
|
+
exports.handleRes2List = other.handleRes2List;
|
|
135
|
+
exports.locationFn = other.locationFn;
|
|
136
|
+
exports.getFileSize = number.getFileSize;
|
|
137
|
+
exports.getRandomNum = number.getRandomNum;
|
|
138
|
+
exports.limitDecimals = number.limitDecimals;
|
|
139
|
+
exports.Database = Database.Database;
|
|
140
|
+
exports.JsonFile = index.JsonFile;
|
|
141
|
+
exports.sendMail = index$1.sendMail;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Database, IKeyValue } from '@cloudbase/node-sdk';
|
|
2
|
+
import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
|
|
3
|
+
export declare class Collection<D extends IKeyValue> {
|
|
4
|
+
private readonly db;
|
|
5
|
+
private readonly collection;
|
|
6
|
+
constructor(db: Database.Db, name: string);
|
|
7
|
+
private joinConditions;
|
|
8
|
+
private request;
|
|
9
|
+
private handleRes;
|
|
10
|
+
private handleData;
|
|
11
|
+
handleConditions(params: MethodParams<D>): MethodParams<D>;
|
|
12
|
+
private exec;
|
|
13
|
+
add(data: Add.Params<D>['data']): Promise<Add.Res>;
|
|
14
|
+
add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
|
|
15
|
+
delete(conditions: Conditions): Promise<Delete.Res>;
|
|
16
|
+
update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
17
|
+
update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
18
|
+
update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
|
|
19
|
+
find(conditions?: Conditions): Promise<Find.Res<D>>;
|
|
20
|
+
findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
|
|
21
|
+
count(conditions: Conditions): Promise<Count.Res>;
|
|
22
|
+
}
|