@wzyjs/utils 0.0.27 → 0.0.30
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/browser/cjs/browser/element.js +40 -0
- package/dist/browser/cjs/browser/index.js +20 -0
- package/dist/browser/cjs/browser/other.js +12 -0
- package/dist/browser/cjs/browser/style.js +49 -0
- package/dist/browser/cjs/browser.js +171 -0
- package/dist/browser/cjs/common/classs.js +14 -0
- package/dist/browser/cjs/common/dayjs.js +27 -0
- package/dist/browser/cjs/types/index.d.ts +27 -0
- package/dist/{esm/fe → browser/cjs/utils/src/browser}/index.d.ts +0 -1
- package/dist/browser/cjs/utils/src/browser.d.ts +2 -0
- package/dist/browser/cjs/utils/src/common/classs.d.ts +5 -0
- package/dist/browser/cjs/utils/src/common/index.d.ts +11 -0
- package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/other.d.ts +1 -1
- package/dist/browser/cjs/utils/src/node.d.ts +2 -0
- package/dist/{esm/fe → browser/esm/browser}/index.js +0 -1
- package/dist/{esm/index_fe.js → browser/esm/browser.js} +12 -10
- package/dist/browser/esm/common/classs.js +12 -0
- package/dist/browser/esm/types/index.d.ts +27 -0
- package/dist/{cjs/fe → browser/esm/utils/src/browser}/index.d.ts +0 -1
- package/dist/browser/esm/utils/src/browser.d.ts +2 -0
- package/dist/browser/esm/utils/src/common/classs.d.ts +5 -0
- package/dist/browser/esm/utils/src/common/index.d.ts +11 -0
- package/dist/{esm/common/tools → browser/esm/utils/src/common}/other.d.ts +1 -1
- package/dist/{esm/rd → browser/esm/utils/src/node}/jsonFile/index.d.ts +1 -1
- package/dist/browser/esm/utils/src/node.d.ts +2 -0
- package/dist/node/cjs/common/classs.js +14 -0
- package/dist/node/cjs/common/dayjs.js +27 -0
- package/dist/node/cjs/common/number.js +34 -0
- package/dist/node/cjs/common/object.js +43 -0
- package/dist/node/cjs/common/other.js +112 -0
- package/dist/node/cjs/common/string.js +137 -0
- package/dist/{cjs/index_rd.js → node/cjs/node.js} +28 -8
- package/dist/node/cjs/types/index.d.ts +27 -0
- package/dist/node/cjs/utils/src/browser/element.d.ts +9 -0
- package/dist/node/cjs/utils/src/browser/index.d.ts +18 -0
- package/dist/node/cjs/utils/src/browser/other.d.ts +1 -0
- package/dist/node/cjs/utils/src/browser/style.d.ts +10 -0
- package/dist/node/cjs/utils/src/browser.d.ts +2 -0
- package/dist/node/cjs/utils/src/common/classs.d.ts +5 -0
- package/dist/node/cjs/utils/src/common/dayjs.d.ts +4 -0
- package/dist/node/cjs/utils/src/common/index.d.ts +11 -0
- package/dist/node/cjs/utils/src/common/number.d.ts +3 -0
- package/dist/node/cjs/utils/src/common/object.d.ts +10 -0
- package/dist/node/cjs/utils/src/common/other.d.ts +26 -0
- package/dist/node/cjs/utils/src/common/string.d.ts +16 -0
- package/dist/node/cjs/utils/src/node/database/Collection.d.ts +22 -0
- package/dist/node/cjs/utils/src/node/database/Database.d.ts +10 -0
- package/dist/node/cjs/utils/src/node/database/index.d.ts +2 -0
- package/dist/node/cjs/utils/src/node/database/types.d.ts +151 -0
- package/dist/node/cjs/utils/src/node/database/utils.d.ts +3 -0
- package/dist/node/cjs/utils/src/node/index.d.ts +3 -0
- package/dist/node/cjs/utils/src/node/jsonFile/index.d.ts +6 -0
- package/dist/node/cjs/utils/src/node/mail/index.d.ts +1 -0
- package/dist/node/cjs/utils/src/node.d.ts +2 -0
- package/dist/node/esm/common/classs.js +12 -0
- package/dist/node/esm/common/dayjs.js +18 -0
- package/dist/node/esm/common/number.js +30 -0
- package/dist/node/esm/common/object.js +39 -0
- package/dist/node/esm/common/other.js +106 -0
- package/dist/node/esm/common/string.js +120 -0
- package/dist/node/esm/node/database/Collection.js +200 -0
- package/dist/node/esm/node/database/Database.js +23 -0
- package/dist/node/esm/node/database/types.js +25 -0
- package/dist/node/esm/node/database/utils.js +27 -0
- package/dist/node/esm/node/jsonFile/index.js +27 -0
- package/dist/node/esm/node/mail/index.js +29 -0
- package/dist/node/esm/node.js +14 -0
- package/dist/node/esm/types/index.d.ts +27 -0
- package/dist/node/esm/utils/src/browser/element.d.ts +9 -0
- package/dist/node/esm/utils/src/browser/index.d.ts +18 -0
- package/dist/node/esm/utils/src/browser/other.d.ts +1 -0
- package/dist/node/esm/utils/src/browser/style.d.ts +10 -0
- package/dist/node/esm/utils/src/browser.d.ts +2 -0
- package/dist/node/esm/utils/src/common/classs.d.ts +5 -0
- package/dist/node/esm/utils/src/common/dayjs.d.ts +4 -0
- package/dist/node/esm/utils/src/common/index.d.ts +11 -0
- package/dist/node/esm/utils/src/common/number.d.ts +3 -0
- package/dist/node/esm/utils/src/common/object.d.ts +10 -0
- package/dist/node/esm/utils/src/common/other.d.ts +26 -0
- package/dist/node/esm/utils/src/common/string.d.ts +16 -0
- package/dist/node/esm/utils/src/node/database/Collection.d.ts +22 -0
- package/dist/node/esm/utils/src/node/database/Database.d.ts +10 -0
- package/dist/node/esm/utils/src/node/database/index.d.ts +2 -0
- package/dist/node/esm/utils/src/node/database/types.d.ts +151 -0
- package/dist/node/esm/utils/src/node/database/utils.d.ts +3 -0
- package/dist/node/esm/utils/src/node/index.d.ts +3 -0
- package/dist/node/esm/utils/src/node/jsonFile/index.d.ts +6 -0
- package/dist/node/esm/utils/src/node/mail/index.d.ts +1 -0
- package/dist/node/esm/utils/src/node.d.ts +2 -0
- package/package.json +23 -11
- package/dist/cjs/common/index.d.ts +0 -6
- package/dist/cjs/common/tools/index.d.ts +0 -4
- package/dist/cjs/common/types/index.d.ts +0 -15
- package/dist/cjs/index_all.d.ts +0 -3
- package/dist/cjs/index_fe.d.ts +0 -2
- package/dist/cjs/index_rd.d.ts +0 -2
- package/dist/esm/common/index.d.ts +0 -6
- package/dist/esm/common/tools/index.d.ts +0 -4
- package/dist/esm/common/types/index.d.ts +0 -15
- package/dist/esm/index_all.d.ts +0 -3
- package/dist/esm/index_fe.d.ts +0 -2
- package/dist/esm/index_rd.d.ts +0 -2
- /package/dist/{cjs/common/tools → browser/cjs/common}/number.js +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/common}/object.js +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/common}/other.js +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/common}/string.js +0 -0
- /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/element.d.ts +0 -0
- /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/other.d.ts +0 -0
- /package/dist/{cjs/fe → browser/cjs/utils/src/browser}/style.d.ts +0 -0
- /package/dist/{cjs/fe → browser/cjs/utils/src/common}/dayjs.d.ts +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/number.d.ts +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/object.d.ts +0 -0
- /package/dist/{cjs/common/tools → browser/cjs/utils/src/common}/string.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/Collection.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/Database.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/index.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/types.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/database/utils.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/index.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/jsonFile/index.d.ts +0 -0
- /package/dist/{cjs/rd → browser/cjs/utils/src/node}/mail/index.d.ts +0 -0
- /package/dist/{esm/fe → browser/esm/browser}/element.js +0 -0
- /package/dist/{esm/fe → browser/esm/browser}/other.js +0 -0
- /package/dist/{esm/fe → browser/esm/browser}/style.js +0 -0
- /package/dist/{esm/fe → browser/esm/common}/dayjs.js +0 -0
- /package/dist/{esm/common/tools → browser/esm/common}/number.js +0 -0
- /package/dist/{esm/common/tools → browser/esm/common}/object.js +0 -0
- /package/dist/{esm/common/tools → browser/esm/common}/other.js +0 -0
- /package/dist/{esm/common/tools → browser/esm/common}/string.js +0 -0
- /package/dist/{esm/fe → browser/esm/utils/src/browser}/element.d.ts +0 -0
- /package/dist/{esm/fe → browser/esm/utils/src/browser}/other.d.ts +0 -0
- /package/dist/{esm/fe → browser/esm/utils/src/browser}/style.d.ts +0 -0
- /package/dist/{esm/fe → browser/esm/utils/src/common}/dayjs.d.ts +0 -0
- /package/dist/{esm/common/tools → browser/esm/utils/src/common}/number.d.ts +0 -0
- /package/dist/{esm/common/tools → browser/esm/utils/src/common}/object.d.ts +0 -0
- /package/dist/{esm/common/tools → browser/esm/utils/src/common}/string.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/database/Collection.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/database/Database.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/database/index.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/database/types.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/database/utils.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/index.d.ts +0 -0
- /package/dist/{esm/rd → browser/esm/utils/src/node}/mail/index.d.ts +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/database/Collection.js +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/database/Database.js +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/database/types.js +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/database/utils.js +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/jsonFile/index.js +0 -0
- /package/dist/{cjs/rd → node/cjs/node}/mail/index.js +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 滚动到让指定元素显示出来的位置
|
|
4
|
+
const scrollIntoView = (el, option) => {
|
|
5
|
+
if (!el) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'start', ...option });
|
|
9
|
+
};
|
|
10
|
+
// 获取指定元素 已经元素原始的样式
|
|
11
|
+
const getElement = (el) => {
|
|
12
|
+
const element = typeof el === 'string' ? document.querySelector(el) : el;
|
|
13
|
+
if (!element) {
|
|
14
|
+
return {
|
|
15
|
+
element: null,
|
|
16
|
+
originalStyle: {},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// 获取元素原始的样式
|
|
20
|
+
return {
|
|
21
|
+
element,
|
|
22
|
+
originalStyle: window.getComputedStyle(element),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
// 判断元素是否在可见范围内
|
|
26
|
+
const isElementInViewport = (el) => {
|
|
27
|
+
const { element } = getElement(el);
|
|
28
|
+
if (!element) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const rect = element.getBoundingClientRect();
|
|
32
|
+
return (rect.top >= 0 &&
|
|
33
|
+
rect.left >= 0 &&
|
|
34
|
+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
35
|
+
rect.right <= (window.innerWidth || document.documentElement.clientWidth));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.getElement = getElement;
|
|
39
|
+
exports.isElementInViewport = isElementInViewport;
|
|
40
|
+
exports.scrollIntoView = scrollIntoView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var md5 = require('md5');
|
|
4
|
+
var classnames = require('classnames');
|
|
5
|
+
var copyToClipboard = require('copy-to-clipboard');
|
|
6
|
+
var localforage$1 = require('localforage');
|
|
7
|
+
var anime = require('animejs');
|
|
8
|
+
|
|
9
|
+
const localforage = {
|
|
10
|
+
config: localforage$1.config,
|
|
11
|
+
setItem: localforage$1.setItem,
|
|
12
|
+
getItem: localforage$1.getItem,
|
|
13
|
+
removeItem: localforage$1.removeItem,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.md5 = md5;
|
|
17
|
+
exports.classnames = classnames;
|
|
18
|
+
exports.copy = copyToClipboard;
|
|
19
|
+
exports.anime = anime;
|
|
20
|
+
exports.localforage = localforage;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var anime = require('animejs');
|
|
4
|
+
var element = require('./element.js');
|
|
5
|
+
|
|
6
|
+
// 颜色值转换
|
|
7
|
+
const hexToRgba = (hexColor, a = 1) => {
|
|
8
|
+
let red = parseInt(hexColor.substr(1, 2), 16);
|
|
9
|
+
let green = parseInt(hexColor.substr(3, 2), 16);
|
|
10
|
+
let blue = parseInt(hexColor.substr(5, 2), 16);
|
|
11
|
+
return {
|
|
12
|
+
nums: { red, green, blue },
|
|
13
|
+
text: `rgba(${red}, ${green}, ${blue}, ${a})`,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
// 背景颜色闪动
|
|
17
|
+
const flashBackground = (el, color, a = 1) => {
|
|
18
|
+
const { element: element$1, originalStyle } = element.getElement(el);
|
|
19
|
+
if (!element$1) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
anime({
|
|
23
|
+
targets: element$1,
|
|
24
|
+
backgroundColor: [hexToRgba(color, a).text, originalStyle.backgroundColor],
|
|
25
|
+
duration: 1500,
|
|
26
|
+
easing: 'easeInOutSine',
|
|
27
|
+
direction: 'alternate',
|
|
28
|
+
loop: false,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
// 边框闪动
|
|
32
|
+
const flashBorder = (el, color, a = 1) => {
|
|
33
|
+
const { element: element$1 } = element.getElement(el);
|
|
34
|
+
if (!element$1) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
anime({
|
|
38
|
+
targets: element$1,
|
|
39
|
+
border: [`1px solid ${hexToRgba(color, a).text}`, 'none'],
|
|
40
|
+
duration: 1500,
|
|
41
|
+
easing: 'easeInOutSine',
|
|
42
|
+
direction: 'alternate',
|
|
43
|
+
loop: false,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.flashBackground = flashBackground;
|
|
48
|
+
exports.flashBorder = flashBorder;
|
|
49
|
+
exports.hexToRgba = hexToRgba;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lodash = require('lodash');
|
|
4
|
+
var consola = require('consola');
|
|
5
|
+
require('./common/dayjs.js');
|
|
6
|
+
var zod = require('zod');
|
|
7
|
+
var string = require('./common/string.js');
|
|
8
|
+
var object = require('./common/object.js');
|
|
9
|
+
var other = require('./common/other.js');
|
|
10
|
+
var number = require('./common/number.js');
|
|
11
|
+
var classs = require('./common/classs.js');
|
|
12
|
+
var index = require('./browser/index.js');
|
|
13
|
+
var dayjs = require('dayjs');
|
|
14
|
+
var style = require('./browser/style.js');
|
|
15
|
+
var element = require('./browser/element.js');
|
|
16
|
+
var other$1 = require('./browser/other.js');
|
|
17
|
+
var copyToClipboard = require('copy-to-clipboard');
|
|
18
|
+
var classnames = require('classnames');
|
|
19
|
+
var md5 = require('md5');
|
|
20
|
+
var anime = require('animejs');
|
|
21
|
+
|
|
22
|
+
function _interopNamespaceDefault(e) {
|
|
23
|
+
var n = Object.create(null);
|
|
24
|
+
if (e) {
|
|
25
|
+
Object.keys(e).forEach(function (k) {
|
|
26
|
+
if (k !== 'default') {
|
|
27
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return e[k]; }
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
n.default = e;
|
|
36
|
+
return Object.freeze(n);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var consola__namespace = /*#__PURE__*/_interopNamespaceDefault(consola);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
exports._ = lodash;
|
|
44
|
+
Object.defineProperty(exports, 'cloneDeep', {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return lodash.cloneDeep; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, 'debounce', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return lodash.debounce; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, 'find', {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return lodash.find; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, 'groupBy', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return lodash.groupBy; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, 'isBoolean', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return lodash.isBoolean; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, 'isEmpty', {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return lodash.isEmpty; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, 'isEqual', {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return lodash.isEqual; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, 'isError', {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return lodash.isError; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, 'isFunction', {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return lodash.isFunction; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return lodash.isNumber; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, 'isObject', {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return lodash.isObject; }
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, 'isString', {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return lodash.isString; }
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, 'merge', {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return lodash.merge; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, 'noop', {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return lodash.noop; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, 'omit', {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return lodash.omit; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, 'pick', {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return lodash.pick; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, 'uniq', {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return lodash.uniq; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, 'uniqBy', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return lodash.uniqBy; }
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, 'uniqWith', {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return lodash.uniqWith; }
|
|
119
|
+
});
|
|
120
|
+
exports.consola = consola__namespace;
|
|
121
|
+
exports.amount = string.amount;
|
|
122
|
+
exports.getChinese = string.getChinese;
|
|
123
|
+
exports.getChineseByStr = string.getChineseByStr;
|
|
124
|
+
exports.getCookie = string.getCookie;
|
|
125
|
+
exports.getLength = string.getLength;
|
|
126
|
+
exports.getProxyUrl = string.getProxyUrl;
|
|
127
|
+
exports.getRandomColor = string.getRandomColor;
|
|
128
|
+
exports.getRandomString = string.getRandomString;
|
|
129
|
+
exports.getSliceStr = string.getSliceStr;
|
|
130
|
+
exports.getStrLength = string.getStrLength;
|
|
131
|
+
exports.getType = string.getType;
|
|
132
|
+
exports.isJson = string.isJson;
|
|
133
|
+
exports.jsonParse = string.jsonParse;
|
|
134
|
+
exports.replaceAll = string.replaceAll;
|
|
135
|
+
exports.replaceByRules = string.replaceByRules;
|
|
136
|
+
exports.toString = string.toString;
|
|
137
|
+
exports.filterParams = object.filterParams;
|
|
138
|
+
exports.findItem = object.findItem;
|
|
139
|
+
exports.watch = object.watch;
|
|
140
|
+
exports.delay = other.delay;
|
|
141
|
+
exports.executePromise = other.executePromise;
|
|
142
|
+
exports.handleParams = other.handleParams;
|
|
143
|
+
exports.handleRes2List = other.handleRes2List;
|
|
144
|
+
exports.locationFn = other.locationFn;
|
|
145
|
+
exports.getFileSize = number.getFileSize;
|
|
146
|
+
exports.getRandomNum = number.getRandomNum;
|
|
147
|
+
exports.limitDecimals = number.limitDecimals;
|
|
148
|
+
exports.CustomError = classs.CustomError;
|
|
149
|
+
exports.localforage = index.localforage;
|
|
150
|
+
Object.defineProperty(exports, 'Dayjs', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () { return dayjs.Dayjs; }
|
|
153
|
+
});
|
|
154
|
+
exports.dayjs = dayjs;
|
|
155
|
+
exports.flashBackground = style.flashBackground;
|
|
156
|
+
exports.flashBorder = style.flashBorder;
|
|
157
|
+
exports.hexToRgba = style.hexToRgba;
|
|
158
|
+
exports.getElement = element.getElement;
|
|
159
|
+
exports.isElementInViewport = element.isElementInViewport;
|
|
160
|
+
exports.scrollIntoView = element.scrollIntoView;
|
|
161
|
+
exports.readClipboard = other$1.readClipboard;
|
|
162
|
+
exports.copy = copyToClipboard;
|
|
163
|
+
exports.classnames = classnames;
|
|
164
|
+
exports.md5 = md5;
|
|
165
|
+
exports.anime = anime;
|
|
166
|
+
Object.keys(zod).forEach(function (k) {
|
|
167
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
get: function () { return zod[k]; }
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class CustomError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
data;
|
|
6
|
+
constructor(message, code, data) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.data = data;
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.CustomError = CustomError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dayjs = require('dayjs');
|
|
6
|
+
var isBetween = require('dayjs/plugin/isBetween');
|
|
7
|
+
var weekday = require('dayjs/plugin/weekday');
|
|
8
|
+
var localeData = require('dayjs/plugin/localeData');
|
|
9
|
+
var isoWeek = require('dayjs/plugin/isoWeek');
|
|
10
|
+
var updateLocale = require('dayjs/plugin/updateLocale');
|
|
11
|
+
require('dayjs/locale/zh-cn');
|
|
12
|
+
|
|
13
|
+
dayjs.extend(isBetween);
|
|
14
|
+
dayjs.extend(weekday);
|
|
15
|
+
dayjs.extend(localeData);
|
|
16
|
+
dayjs.extend(isoWeek);
|
|
17
|
+
dayjs.extend(updateLocale);
|
|
18
|
+
dayjs.locale('zh-cn');
|
|
19
|
+
dayjs.updateLocale('zh-cn', {
|
|
20
|
+
weekStart: 1,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
Object.defineProperty(exports, 'Dayjs', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return dayjs.Dayjs; }
|
|
26
|
+
});
|
|
27
|
+
exports.default = dayjs;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
21
|
+
export type OrderBy = {
|
|
22
|
+
[key: string]: 'asc' | 'desc';
|
|
23
|
+
} | {
|
|
24
|
+
[key: string]: 'asc' | 'desc';
|
|
25
|
+
}[];
|
|
26
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
27
|
+
export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { default as dayjs, Dayjs } from './dayjs';
|
|
5
|
+
export * from 'zod';
|
|
6
|
+
export * from './string';
|
|
7
|
+
export * from './object';
|
|
8
|
+
export * from './other';
|
|
9
|
+
export * from './number';
|
|
10
|
+
export * from './classs';
|
|
11
|
+
export { default as _ } from 'lodash';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyValue, OrderParams, Pagination, SortParams } from '
|
|
1
|
+
import { KeyValue, OrderParams, Pagination, SortParams } from '@wzyjs/types';
|
|
2
2
|
export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
|
|
3
3
|
page: {
|
|
4
4
|
size?: number | undefined;
|
|
@@ -3,7 +3,6 @@ export { default as classnames } from 'classnames';
|
|
|
3
3
|
export { default as copy } from 'copy-to-clipboard';
|
|
4
4
|
import { config, setItem, getItem, removeItem } from 'localforage';
|
|
5
5
|
export { default as anime } from 'animejs';
|
|
6
|
-
import './dayjs.js';
|
|
7
6
|
|
|
8
7
|
const localforage = {
|
|
9
8
|
config,
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
export { cloneDeep, debounce, find, groupBy, isBoolean, isEmpty, isEqual, isError, isFunction, isNumber, isObject, isString,
|
|
1
|
+
export { default as _, cloneDeep, debounce, find, groupBy, isBoolean, isEmpty, isEqual, isError, isFunction, isNumber, isObject, isString, merge, noop, omit, pick, uniq, uniqBy, uniqWith } from 'lodash';
|
|
2
2
|
import * as consola from 'consola';
|
|
3
3
|
export { consola };
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
|
|
4
|
+
import './common/dayjs.js';
|
|
5
|
+
export * from 'zod';
|
|
6
|
+
export { amount, getChinese, getChineseByStr, getCookie, getLength, getProxyUrl, getRandomColor, getRandomString, getSliceStr, getStrLength, getType, isJson, jsonParse, replaceAll, replaceByRules, toString } from './common/string.js';
|
|
7
|
+
export { filterParams, findItem, watch } from './common/object.js';
|
|
8
|
+
export { delay, executePromise, handleParams, handleRes2List, locationFn } from './common/other.js';
|
|
9
|
+
export { getFileSize, getRandomNum, limitDecimals } from './common/number.js';
|
|
10
|
+
export { CustomError } from './common/classs.js';
|
|
11
|
+
export { localforage } from './browser/index.js';
|
|
10
12
|
export { Dayjs, default as dayjs } from 'dayjs';
|
|
11
|
-
export { flashBackground, flashBorder, hexToRgba } from './
|
|
12
|
-
export { getElement, isElementInViewport, scrollIntoView } from './
|
|
13
|
-
export { readClipboard } from './
|
|
13
|
+
export { flashBackground, flashBorder, hexToRgba } from './browser/style.js';
|
|
14
|
+
export { getElement, isElementInViewport, scrollIntoView } from './browser/element.js';
|
|
15
|
+
export { readClipboard } from './browser/other.js';
|
|
14
16
|
export { default as copy } from 'copy-to-clipboard';
|
|
15
17
|
export { default as classnames } from 'classnames';
|
|
16
18
|
export { default as md5 } from 'md5';
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
21
|
+
export type OrderBy = {
|
|
22
|
+
[key: string]: 'asc' | 'desc';
|
|
23
|
+
} | {
|
|
24
|
+
[key: string]: 'asc' | 'desc';
|
|
25
|
+
}[];
|
|
26
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
27
|
+
export type Set<T, OmitK extends keyof T = never, OptionalK extends Exclude<keyof T, OmitK> = never> = Optional<Omit<T, OmitK>, OptionalK>;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { default as dayjs, Dayjs } from './dayjs';
|
|
5
|
+
export * from 'zod';
|
|
6
|
+
export * from './string';
|
|
7
|
+
export * from './object';
|
|
8
|
+
export * from './other';
|
|
9
|
+
export * from './number';
|
|
10
|
+
export * from './classs';
|
|
11
|
+
export { default as _ } from 'lodash';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyValue, OrderParams, Pagination, SortParams } from '
|
|
1
|
+
import { KeyValue, OrderParams, Pagination, SortParams } from '@wzyjs/types';
|
|
2
2
|
export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
|
|
3
3
|
page: {
|
|
4
4
|
size?: number | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class CustomError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
data;
|
|
6
|
+
constructor(message, code, data) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.data = data;
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.CustomError = CustomError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dayjs = require('dayjs');
|
|
6
|
+
var isBetween = require('dayjs/plugin/isBetween');
|
|
7
|
+
var weekday = require('dayjs/plugin/weekday');
|
|
8
|
+
var localeData = require('dayjs/plugin/localeData');
|
|
9
|
+
var isoWeek = require('dayjs/plugin/isoWeek');
|
|
10
|
+
var updateLocale = require('dayjs/plugin/updateLocale');
|
|
11
|
+
require('dayjs/locale/zh-cn');
|
|
12
|
+
|
|
13
|
+
dayjs.extend(isBetween);
|
|
14
|
+
dayjs.extend(weekday);
|
|
15
|
+
dayjs.extend(localeData);
|
|
16
|
+
dayjs.extend(isoWeek);
|
|
17
|
+
dayjs.extend(updateLocale);
|
|
18
|
+
dayjs.locale('zh-cn');
|
|
19
|
+
dayjs.updateLocale('zh-cn', {
|
|
20
|
+
weekStart: 1,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
Object.defineProperty(exports, 'Dayjs', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return dayjs.Dayjs; }
|
|
26
|
+
});
|
|
27
|
+
exports.default = dayjs;
|
|
@@ -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,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;
|