magtool 1.0.4 → 1.0.5
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/util.js +32 -34
- package/package.json +1 -1
package/dist/util.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
i.config.globalProperties.$getImg = f, window.$getImg = f;
|
|
4
|
-
const $ = (e, t = 0) => {
|
|
1
|
+
const M = (i) => {
|
|
2
|
+
const b = (e, t = 0) => {
|
|
5
3
|
let o = parseInt(Math.random() * e);
|
|
6
4
|
return o += t, o;
|
|
7
5
|
};
|
|
8
|
-
window.$rn =
|
|
9
|
-
const
|
|
6
|
+
window.$rn = b;
|
|
7
|
+
const $ = (e, t) => {
|
|
10
8
|
let o = [];
|
|
11
9
|
for (let r = 0; r < e; r++)
|
|
12
10
|
o.push(t(r));
|
|
13
11
|
return o;
|
|
14
12
|
};
|
|
15
|
-
window.$fd =
|
|
13
|
+
window.$fd = $, i.config.globalProperties.$setTimeout = function(e = () => {
|
|
16
14
|
}, t) {
|
|
17
15
|
this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
|
|
18
16
|
e(), clearTimeout(this.timer);
|
|
19
17
|
}, t);
|
|
20
18
|
};
|
|
21
|
-
const
|
|
22
|
-
window.$toUpperCamel =
|
|
23
|
-
const
|
|
19
|
+
const y = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
|
|
20
|
+
window.$toUpperCamel = y;
|
|
21
|
+
const f = (e, t = 2) => {
|
|
24
22
|
const o = window.$getType(e);
|
|
25
23
|
let r;
|
|
26
24
|
o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
|
|
@@ -28,14 +26,14 @@ const S = (i) => {
|
|
|
28
26
|
let a = n[0].split("");
|
|
29
27
|
a = a.reverse();
|
|
30
28
|
let l = [];
|
|
31
|
-
a.forEach((N,
|
|
32
|
-
|
|
29
|
+
a.forEach((N, m) => {
|
|
30
|
+
m !== 0 && m % 3 === 0 && l.push(","), l.push(N);
|
|
33
31
|
});
|
|
34
32
|
let c = l.reverse().join("");
|
|
35
33
|
return window.$getType(t) === "Number" && t > 0 && (c += ".", n[1] ? c += n[1].padEnd(t, 0).substr(0, t) : c += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${c}` : c;
|
|
36
34
|
};
|
|
37
|
-
window.$fa =
|
|
38
|
-
const
|
|
35
|
+
window.$fa = f, i.config.globalProperties.$fa = f;
|
|
36
|
+
const u = ({
|
|
39
37
|
prop: e,
|
|
40
38
|
currency: t,
|
|
41
39
|
value: o,
|
|
@@ -44,8 +42,8 @@ const S = (i) => {
|
|
|
44
42
|
const n = r[e];
|
|
45
43
|
return n.unit === "currency" ? t ? `${t} ${window.$fa(o, n == null ? void 0 : n.precision)}` : window.$fa(o, n == null ? void 0 : n.precision) : n.unit === "%" ? `${window.$fa(o, n == null ? void 0 : n.precision)}%` : window.$fa(o, n == null ? void 0 : n.precision);
|
|
46
44
|
};
|
|
47
|
-
window.$fu =
|
|
48
|
-
const
|
|
45
|
+
window.$fu = u, i.config.globalProperties.$fu = u;
|
|
46
|
+
const d = (e = () => {
|
|
49
47
|
}, t = 2) => {
|
|
50
48
|
let o = null;
|
|
51
49
|
return new Promise((r, n) => {
|
|
@@ -54,8 +52,8 @@ const S = (i) => {
|
|
|
54
52
|
}, t * 100);
|
|
55
53
|
});
|
|
56
54
|
};
|
|
57
|
-
window.$pm =
|
|
58
|
-
const
|
|
55
|
+
window.$pm = d, window.$promise = d;
|
|
56
|
+
const p = (e = () => {
|
|
59
57
|
}, t = 500) => {
|
|
60
58
|
let o;
|
|
61
59
|
return function(...r) {
|
|
@@ -64,7 +62,7 @@ const S = (i) => {
|
|
|
64
62
|
}, t);
|
|
65
63
|
};
|
|
66
64
|
};
|
|
67
|
-
window.$db =
|
|
65
|
+
window.$db = p, window.$debounce = p, Number.prototype.toFixedNumber = function(e) {
|
|
68
66
|
return Number(this.toFixed(e));
|
|
69
67
|
}, Array.prototype.filter1 = function(e) {
|
|
70
68
|
if (!e || typeof e != "function")
|
|
@@ -80,7 +78,7 @@ const S = (i) => {
|
|
|
80
78
|
data: t
|
|
81
79
|
};
|
|
82
80
|
}, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
83
|
-
const
|
|
81
|
+
const w = (e, t) => {
|
|
84
82
|
if (!e) {
|
|
85
83
|
console.info("No Value");
|
|
86
84
|
return;
|
|
@@ -106,29 +104,29 @@ const S = (i) => {
|
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
|
-
window.$copy =
|
|
110
|
-
const
|
|
111
|
-
window.$sc =
|
|
112
|
-
const
|
|
107
|
+
window.$copy = w, i.config.globalProperties.$copy = w;
|
|
108
|
+
const h = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
|
|
109
|
+
window.$sc = h;
|
|
110
|
+
const F = {
|
|
113
111
|
cpa: "avgCPA",
|
|
114
112
|
cpt: "avgCPT"
|
|
115
|
-
},
|
|
113
|
+
}, C = (e, t = F) => {
|
|
116
114
|
const o = t[e.name];
|
|
117
115
|
o && (e.name = o);
|
|
118
116
|
};
|
|
119
|
-
window.$nr =
|
|
120
|
-
const
|
|
117
|
+
window.$nr = C;
|
|
118
|
+
const T = (e, t) => (Object.keys(e).forEach((o) => {
|
|
121
119
|
objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
|
|
122
120
|
}), e);
|
|
123
|
-
window.$nro =
|
|
124
|
-
const
|
|
121
|
+
window.$nro = T;
|
|
122
|
+
const k = (e) => {
|
|
125
123
|
let t = 0;
|
|
126
124
|
return Object.keys(e).forEach((o) => {
|
|
127
125
|
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
|
|
128
126
|
}), t;
|
|
129
127
|
};
|
|
130
|
-
window.$pc =
|
|
131
|
-
const
|
|
128
|
+
window.$pc = k;
|
|
129
|
+
const g = {
|
|
132
130
|
info: {
|
|
133
131
|
tag: "background-color:#0085FF; color:#f1f7ff;",
|
|
134
132
|
style: "background-color:#f1f7ff; color:#0085FF;"
|
|
@@ -152,8 +150,8 @@ const S = (i) => {
|
|
|
152
150
|
}, s = (e = "info", t) => {
|
|
153
151
|
e === "success" && (e = "info"), console[e](
|
|
154
152
|
`%c ${e.toUpperCase()} %c┆${t}┆`,
|
|
155
|
-
`${
|
|
156
|
-
`${
|
|
153
|
+
`${g[e].tag}`,
|
|
154
|
+
`${g[e].style}`
|
|
157
155
|
);
|
|
158
156
|
};
|
|
159
157
|
window.$console = {
|
|
@@ -175,5 +173,5 @@ const S = (i) => {
|
|
|
175
173
|
};
|
|
176
174
|
};
|
|
177
175
|
export {
|
|
178
|
-
|
|
176
|
+
M as d
|
|
179
177
|
};
|