magtool 1.3.0 → 1.3.2
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/README.1.md +3 -0
- package/dist/util.js +116 -116
- package/package.json +2 -2
package/README.1.md
CHANGED
package/dist/util.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
window.$getLang = () => localStorage.getItem("lang")
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
const I = (a) => {
|
|
2
|
+
window.$getLang = () => localStorage.getItem("lang") || "en_us", window.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt";
|
|
3
|
+
const k = (e) => Number(e.match(/\d+(\.\d+)?/g).join(""));
|
|
4
|
+
window.$md5 = (e) => k(e);
|
|
5
|
+
const u = (e = {}) => {
|
|
6
|
+
const { alpha: t, name: o } = e, r = [
|
|
5
7
|
"blue",
|
|
6
8
|
"red",
|
|
7
9
|
"orange",
|
|
@@ -11,18 +13,18 @@ const A = (a) => {
|
|
|
11
13
|
"purple",
|
|
12
14
|
"primary",
|
|
13
15
|
"dark"
|
|
14
|
-
], n = ["", 1, 3, 5, 7], c = o ||
|
|
16
|
+
], n = ["", 1, 3, 5, 7], c = o || r[parseInt(Math.random() * r.length)], s = t === 0 ? "" : n[parseInt(Math.random() * n.length)];
|
|
15
17
|
return `${c}${s}`;
|
|
16
18
|
};
|
|
17
|
-
window.$
|
|
18
|
-
const
|
|
19
|
+
window.$rc = u, a.config.globalProperties.$rc = u;
|
|
20
|
+
const U = (e, t = 0) => {
|
|
19
21
|
let o = parseInt(Math.random() * e);
|
|
20
|
-
return o +=
|
|
22
|
+
return o += t, o;
|
|
21
23
|
};
|
|
22
|
-
window.$rn =
|
|
23
|
-
let { i:
|
|
24
|
-
const
|
|
25
|
-
o = o || t
|
|
24
|
+
window.$rn = U, window.$elc = (e = {}) => {
|
|
25
|
+
let { i: t = 0, color: o } = e;
|
|
26
|
+
const r = window.global.config.color;
|
|
27
|
+
o = o || r[t];
|
|
26
28
|
const n = o + "FF", c = o + "00";
|
|
27
29
|
return {
|
|
28
30
|
type: "linear",
|
|
@@ -42,9 +44,9 @@ const A = (a) => {
|
|
|
42
44
|
]
|
|
43
45
|
};
|
|
44
46
|
}, window.$egc = (e = {}) => {
|
|
45
|
-
let { i:
|
|
46
|
-
const
|
|
47
|
-
o = o || t
|
|
47
|
+
let { i: t = 0, color: o } = e;
|
|
48
|
+
const r = window.config.color;
|
|
49
|
+
o = o || r[t];
|
|
48
50
|
const n = o + "FF";
|
|
49
51
|
return {
|
|
50
52
|
type: "radial",
|
|
@@ -63,62 +65,62 @@ const A = (a) => {
|
|
|
63
65
|
]
|
|
64
66
|
};
|
|
65
67
|
};
|
|
66
|
-
const
|
|
68
|
+
const O = (e, t) => {
|
|
67
69
|
let o = [];
|
|
68
|
-
for (let
|
|
69
|
-
o.push(r
|
|
70
|
+
for (let r = 0; r < e; r++)
|
|
71
|
+
o.push(t(r));
|
|
70
72
|
return o;
|
|
71
73
|
};
|
|
72
|
-
window.$fd =
|
|
73
|
-
},
|
|
74
|
+
window.$fd = O, a.config.globalProperties.$setTimeout = function(e = () => {
|
|
75
|
+
}, t) {
|
|
74
76
|
this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
|
|
75
77
|
e(), clearTimeout(this.timer);
|
|
76
|
-
},
|
|
78
|
+
}, t);
|
|
77
79
|
};
|
|
78
|
-
const
|
|
79
|
-
a.config.globalProperties.$toUpperCamel =
|
|
80
|
-
const p = (e,
|
|
80
|
+
const w = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
|
|
81
|
+
a.config.globalProperties.$toUpperCamel = w, window.$toUpperCamel = w;
|
|
82
|
+
const p = (e, t = 2) => {
|
|
81
83
|
const o = window.$getType(e);
|
|
82
|
-
let
|
|
83
|
-
o === "Number" ? (e = e.toFixed(
|
|
84
|
+
let r;
|
|
85
|
+
o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
|
|
84
86
|
const n = e.split(".");
|
|
85
87
|
let c = n[0].split("");
|
|
86
88
|
c = c.reverse();
|
|
87
89
|
let s = [];
|
|
88
|
-
c.forEach((
|
|
89
|
-
|
|
90
|
+
c.forEach((A, y) => {
|
|
91
|
+
y !== 0 && y % 3 === 0 && s.push(","), s.push(A);
|
|
90
92
|
});
|
|
91
|
-
let
|
|
92
|
-
return window.$getType(
|
|
93
|
+
let i = s.reverse().join("");
|
|
94
|
+
return window.$getType(t) === "Number" && t > 0 && (i += ".", n[1] ? i += n[1].padEnd(t, 0).substr(0, t) : i += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${i}` : i;
|
|
93
95
|
};
|
|
94
96
|
window.$fa = p, a.config.globalProperties.$fa = p;
|
|
95
97
|
const m = ({
|
|
96
98
|
prop: e,
|
|
97
|
-
currency:
|
|
99
|
+
currency: t,
|
|
98
100
|
value: o,
|
|
99
|
-
obj:
|
|
101
|
+
obj: r = window.$map.asa.asaMetric.allObj
|
|
100
102
|
}) => {
|
|
101
|
-
const n =
|
|
102
|
-
return n.unit === "currency" ?
|
|
103
|
+
const n = r[e];
|
|
104
|
+
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);
|
|
103
105
|
};
|
|
104
106
|
window.$fu2 = m, a.config.globalProperties.$fu2 = m;
|
|
105
107
|
const g = (e = () => {
|
|
106
|
-
},
|
|
108
|
+
}, t = 2) => {
|
|
107
109
|
let o = null;
|
|
108
|
-
return new Promise((
|
|
110
|
+
return new Promise((r, n) => {
|
|
109
111
|
o = setTimeout(() => {
|
|
110
|
-
e(
|
|
111
|
-
},
|
|
112
|
+
e(r, n), clearTimeout(o), r(!0);
|
|
113
|
+
}, t * 100);
|
|
112
114
|
});
|
|
113
115
|
};
|
|
114
116
|
window.$pm = g, window.$promise = g;
|
|
115
117
|
const b = (e = () => {
|
|
116
|
-
},
|
|
118
|
+
}, t = 500) => {
|
|
117
119
|
let o;
|
|
118
|
-
return function(...
|
|
120
|
+
return function(...r) {
|
|
119
121
|
o && clearTimeout(o), o = setTimeout(() => {
|
|
120
|
-
e.apply(this,
|
|
121
|
-
},
|
|
122
|
+
e.apply(this, r);
|
|
123
|
+
}, t);
|
|
122
124
|
};
|
|
123
125
|
};
|
|
124
126
|
window.$db = b, window.$debounce = b, Number.prototype.toFixedNumber = function(e) {
|
|
@@ -126,28 +128,28 @@ const A = (a) => {
|
|
|
126
128
|
}, Array.prototype.filter1 = function(e) {
|
|
127
129
|
if (!e || typeof e != "function")
|
|
128
130
|
throw new Error(e + " is not a function");
|
|
129
|
-
let
|
|
130
|
-
for (let
|
|
131
|
-
if (e(this[
|
|
132
|
-
o =
|
|
131
|
+
let t, o;
|
|
132
|
+
for (let r = 0; r < this.length; r++)
|
|
133
|
+
if (e(this[r], r, this)) {
|
|
134
|
+
o = r, t = this[r];
|
|
133
135
|
break;
|
|
134
136
|
}
|
|
135
137
|
return {
|
|
136
138
|
index: o,
|
|
137
|
-
data:
|
|
139
|
+
data: t
|
|
138
140
|
};
|
|
139
141
|
}, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
140
|
-
const $ = (e,
|
|
142
|
+
const $ = (e, t) => {
|
|
141
143
|
if (!e) {
|
|
142
144
|
console.info("No Value");
|
|
143
145
|
return;
|
|
144
146
|
}
|
|
145
147
|
const o = window.$l("Copied");
|
|
146
|
-
let
|
|
147
|
-
if (
|
|
148
|
+
let r;
|
|
149
|
+
if (t ? window.$getType(t) !== "Boolean" ? r = `${o} ${t}: ${e}` : r = `${o}: ${e}` : r = o, navigator.clipboard && window.isSecureContext)
|
|
148
150
|
navigator.clipboard.writeText(e).then(() => {
|
|
149
151
|
a.config.globalProperties.$message.success({
|
|
150
|
-
message:
|
|
152
|
+
message: r,
|
|
151
153
|
// grouping: true,
|
|
152
154
|
center: !0,
|
|
153
155
|
duration: 5e3
|
|
@@ -156,7 +158,7 @@ const A = (a) => {
|
|
|
156
158
|
else {
|
|
157
159
|
let n = document.createElement("textarea");
|
|
158
160
|
n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), a.config.globalProperties.$message.success({
|
|
159
|
-
message:
|
|
161
|
+
message: r,
|
|
160
162
|
// grouping: true,
|
|
161
163
|
center: !0,
|
|
162
164
|
duration: 5e3
|
|
@@ -164,28 +166,28 @@ const A = (a) => {
|
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
168
|
window.$copy = $, a.config.globalProperties.$copy = $;
|
|
167
|
-
const
|
|
168
|
-
window.$sc =
|
|
169
|
+
const F = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
|
|
170
|
+
window.$sc = F;
|
|
169
171
|
const C = {
|
|
170
172
|
cpa: "avgCPA",
|
|
171
173
|
cpt: "avgCPT"
|
|
172
|
-
},
|
|
173
|
-
const o =
|
|
174
|
+
}, T = (e, t = C) => {
|
|
175
|
+
const o = t[e.name];
|
|
174
176
|
o && (e.name = o);
|
|
175
177
|
};
|
|
176
|
-
window.$nr =
|
|
177
|
-
const
|
|
178
|
+
window.$nr = T;
|
|
179
|
+
const E = (e, t) => (Object.keys(e).forEach((o) => {
|
|
178
180
|
objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
|
|
179
181
|
}), e);
|
|
180
|
-
window.$nro =
|
|
181
|
-
const
|
|
182
|
-
let
|
|
182
|
+
window.$nro = E;
|
|
183
|
+
const M = (e) => {
|
|
184
|
+
let t = 0;
|
|
183
185
|
return Object.keys(e).forEach((o) => {
|
|
184
|
-
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) &&
|
|
185
|
-
}),
|
|
186
|
+
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
|
|
187
|
+
}), t;
|
|
186
188
|
};
|
|
187
|
-
window.$pc =
|
|
188
|
-
const
|
|
189
|
+
window.$pc = M;
|
|
190
|
+
const d = {
|
|
189
191
|
info: {
|
|
190
192
|
tag: "background-color:#0085FF; color:#f1f7ff;",
|
|
191
193
|
style: "background-color:#f1f7ff; color:#0085FF;"
|
|
@@ -206,88 +208,86 @@ const A = (a) => {
|
|
|
206
208
|
tag: "background-color:#20c997; color:#f6fffc;",
|
|
207
209
|
style: "background-color:#f6fffc; color:#20c997;"
|
|
208
210
|
}
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
};
|
|
233
|
-
const E = (e) => {
|
|
211
|
+
}, j = (e) => {
|
|
212
|
+
let t = !1;
|
|
213
|
+
for (let o in e)
|
|
214
|
+
if (window.$getType(e[o]) === "Object") {
|
|
215
|
+
t = !0;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
return t;
|
|
219
|
+
}, S = ["info", "log", "warn", "error", "success"];
|
|
220
|
+
window.$c = {}, S.forEach((e) => {
|
|
221
|
+
window.$c[e] = (...t) => {
|
|
222
|
+
const o = e.toUpperCase();
|
|
223
|
+
j(t) ? (console.groupCollapsed(
|
|
224
|
+
`%c ${o} `,
|
|
225
|
+
`${d[e].tag}`
|
|
226
|
+
), console[e](...t), console.groupEnd()) : console.info(
|
|
227
|
+
`%c ${o} %c┆${t}┆`,
|
|
228
|
+
`${d[e].tag}`,
|
|
229
|
+
`${d[e].style}`
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
const L = (e) => {
|
|
234
234
|
if (e)
|
|
235
|
-
return new Promise((
|
|
236
|
-
const
|
|
237
|
-
|
|
235
|
+
return new Promise((t, o) => {
|
|
236
|
+
const r = new Image();
|
|
237
|
+
r.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), r.onload = () => t(r), r.onerror = () => o(new Error("Could not load image"));
|
|
238
238
|
});
|
|
239
239
|
};
|
|
240
|
-
window.$loadImage =
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
window.URL.revokeObjectURL(e), console.info([
|
|
240
|
+
window.$loadImage = L;
|
|
241
|
+
const P = (e) => new Promise((t, o) => {
|
|
242
|
+
const r = document.createElement("video");
|
|
243
|
+
r.preload = "metadata", window.$getType(e) === "String" ? r.src = e : r.src = URL.createObjectURL(e), r.onloadedmetadata = () => {
|
|
244
|
+
window.URL.revokeObjectURL(e), console.info([r]), t(r);
|
|
245
245
|
};
|
|
246
246
|
});
|
|
247
|
-
window.$loadVideo =
|
|
248
|
-
const
|
|
247
|
+
window.$loadVideo = P;
|
|
248
|
+
const h = (e) => {
|
|
249
249
|
if (e && window.$getType(e) === "Object") {
|
|
250
250
|
const o = {};
|
|
251
|
-
return Object.keys(e).forEach((
|
|
252
|
-
const n = e[
|
|
251
|
+
return Object.keys(e).forEach((r) => {
|
|
252
|
+
const n = e[r];
|
|
253
253
|
switch (window.$getType(n)) {
|
|
254
254
|
case "Object":
|
|
255
|
-
Object.keys(n) !== 0 && (o[
|
|
255
|
+
Object.keys(n) !== 0 && (o[r] = n);
|
|
256
256
|
break;
|
|
257
257
|
case "Array":
|
|
258
|
-
n.length !== 0 && (o[
|
|
258
|
+
n.length !== 0 && (o[r] = n);
|
|
259
259
|
break;
|
|
260
260
|
case "String":
|
|
261
|
-
n && (o[
|
|
261
|
+
n && (o[r] = n.toLowerCase());
|
|
262
262
|
break;
|
|
263
263
|
// case 'Number':
|
|
264
264
|
// r[it] = String(itv);
|
|
265
265
|
// break;
|
|
266
266
|
default:
|
|
267
|
-
[void 0, null, ""].indexOf(n) === -1 && (o[
|
|
267
|
+
[void 0, null, ""].indexOf(n) === -1 && (o[r] = n);
|
|
268
268
|
break;
|
|
269
269
|
}
|
|
270
270
|
}), o;
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
window.$removeEmptyParams =
|
|
274
|
-
let l = null,
|
|
275
|
-
const
|
|
276
|
-
let { type:
|
|
277
|
-
if (l = document.createElement("a"),
|
|
273
|
+
window.$removeEmptyParams = h, window.$rep = h;
|
|
274
|
+
let l = null, f = null;
|
|
275
|
+
const R = async (e) => {
|
|
276
|
+
let { type: t = "img", url: o, name: r, data: n } = e;
|
|
277
|
+
if (l = document.createElement("a"), t === "csv") {
|
|
278
278
|
const c = new Blob(["\uFEFF" + n], {
|
|
279
279
|
type: "text/csv,charset=UTF-8"
|
|
280
280
|
});
|
|
281
281
|
l.href = URL.createObjectURL(c);
|
|
282
|
-
} else
|
|
282
|
+
} else t === "video" || t === "excel" ? await fetch(o, e).then((c) => c.blob()).then((c) => {
|
|
283
283
|
l.href = URL.createObjectURL(c);
|
|
284
|
-
}) : (
|
|
284
|
+
}) : (t = "table") ? await fetch(o).then((c) => c.blob()).then((c) => {
|
|
285
285
|
l.href = URL.createObjectURL(c);
|
|
286
286
|
}) : l.href = o;
|
|
287
|
-
|
|
287
|
+
f = new MouseEvent("click"), l.download = r || "download", l.dispatchEvent(f), (t === "csv" || t === "video") && URL.revokeObjectURL(l.url), l = null, f = null;
|
|
288
288
|
};
|
|
289
|
-
window.$download =
|
|
289
|
+
window.$download = R;
|
|
290
290
|
};
|
|
291
291
|
export {
|
|
292
|
-
|
|
292
|
+
I as d
|
|
293
293
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magtool",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
5
5
|
"author": "matt avis",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"bignumber.js": "^9.1.2",
|
|
33
33
|
"echarts": "^5.6.0",
|
|
34
|
-
"magtool": "^1.
|
|
34
|
+
"magtool": "^1.3.1",
|
|
35
35
|
"markdown-it": "^14.1.0",
|
|
36
36
|
"moment": "^2.30.1",
|
|
37
37
|
"pinia": "^3.0.0",
|