magtool 1.0.3 → 1.0.4
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 +124 -79
- package/package.json +14 -14
package/dist/util.js
CHANGED
|
@@ -1,134 +1,179 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
i.config.globalProperties.$getImg =
|
|
4
|
-
const $ = (e,
|
|
5
|
-
let
|
|
6
|
-
return
|
|
1
|
+
const S = (i) => {
|
|
2
|
+
const f = (e) => new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
|
|
3
|
+
i.config.globalProperties.$getImg = f, window.$getImg = f;
|
|
4
|
+
const $ = (e, t = 0) => {
|
|
5
|
+
let o = parseInt(Math.random() * e);
|
|
6
|
+
return o += t, o;
|
|
7
7
|
};
|
|
8
8
|
window.$rn = $;
|
|
9
|
-
const
|
|
10
|
-
let
|
|
11
|
-
for (let
|
|
12
|
-
|
|
13
|
-
return
|
|
9
|
+
const y = (e, t) => {
|
|
10
|
+
let o = [];
|
|
11
|
+
for (let r = 0; r < e; r++)
|
|
12
|
+
o.push(t(r));
|
|
13
|
+
return o;
|
|
14
14
|
};
|
|
15
|
-
window.$fd =
|
|
16
|
-
},
|
|
15
|
+
window.$fd = y, i.config.globalProperties.$setTimeout = function(e = () => {
|
|
16
|
+
}, t) {
|
|
17
17
|
this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
|
|
18
18
|
e(), clearTimeout(this.timer);
|
|
19
|
-
},
|
|
19
|
+
}, t);
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
window.$toUpperCamel =
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
let a =
|
|
21
|
+
const h = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
|
|
22
|
+
window.$toUpperCamel = h;
|
|
23
|
+
const u = (e, t = 2) => {
|
|
24
|
+
const o = window.$getType(e);
|
|
25
|
+
let r;
|
|
26
|
+
o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
|
|
27
|
+
const n = e.split(".");
|
|
28
|
+
let a = n[0].split("");
|
|
29
29
|
a = a.reverse();
|
|
30
30
|
let l = [];
|
|
31
|
-
a.forEach((N,
|
|
32
|
-
|
|
31
|
+
a.forEach((N, b) => {
|
|
32
|
+
b !== 0 && b % 3 === 0 && l.push(","), l.push(N);
|
|
33
33
|
});
|
|
34
|
-
let
|
|
35
|
-
return window.$getType(
|
|
34
|
+
let c = l.reverse().join("");
|
|
35
|
+
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
36
|
};
|
|
37
|
-
window.$fa =
|
|
38
|
-
const
|
|
37
|
+
window.$fa = u, i.config.globalProperties.$fa = u;
|
|
38
|
+
const d = ({
|
|
39
39
|
prop: e,
|
|
40
|
-
currency:
|
|
41
|
-
value:
|
|
42
|
-
obj:
|
|
40
|
+
currency: t,
|
|
41
|
+
value: o,
|
|
42
|
+
obj: r = window.$map.asa.asaMetric.allObj
|
|
43
43
|
}) => {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
44
|
+
const n = r[e];
|
|
45
|
+
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
46
|
};
|
|
47
|
-
window.$fu =
|
|
48
|
-
const
|
|
49
|
-
},
|
|
50
|
-
let
|
|
51
|
-
return new Promise((
|
|
52
|
-
|
|
53
|
-
e(
|
|
54
|
-
},
|
|
47
|
+
window.$fu = d, i.config.globalProperties.$fu = d;
|
|
48
|
+
const w = (e = () => {
|
|
49
|
+
}, t = 2) => {
|
|
50
|
+
let o = null;
|
|
51
|
+
return new Promise((r, n) => {
|
|
52
|
+
o = setTimeout(() => {
|
|
53
|
+
e(r, n), clearTimeout(o), r(!0);
|
|
54
|
+
}, t * 100);
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
-
window.$pm =
|
|
58
|
-
const
|
|
59
|
-
},
|
|
60
|
-
let
|
|
61
|
-
return function(...
|
|
62
|
-
|
|
63
|
-
e.apply(this,
|
|
64
|
-
},
|
|
57
|
+
window.$pm = w, window.$promise = w;
|
|
58
|
+
const g = (e = () => {
|
|
59
|
+
}, t = 500) => {
|
|
60
|
+
let o;
|
|
61
|
+
return function(...r) {
|
|
62
|
+
o && clearTimeout(o), o = setTimeout(() => {
|
|
63
|
+
e.apply(this, r);
|
|
64
|
+
}, t);
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
window.$db =
|
|
67
|
+
window.$db = g, window.$debounce = g, Number.prototype.toFixedNumber = function(e) {
|
|
68
68
|
return Number(this.toFixed(e));
|
|
69
69
|
}, Array.prototype.filter1 = function(e) {
|
|
70
70
|
if (!e || typeof e != "function")
|
|
71
71
|
throw new Error(e + " is not a function");
|
|
72
|
-
let
|
|
73
|
-
for (let
|
|
74
|
-
if (e(this[
|
|
75
|
-
|
|
72
|
+
let t, o;
|
|
73
|
+
for (let r = 0; r < this.length; r++)
|
|
74
|
+
if (e(this[r], r, this)) {
|
|
75
|
+
o = r, t = this[r];
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
return {
|
|
79
|
-
index:
|
|
80
|
-
data:
|
|
79
|
+
index: o,
|
|
80
|
+
data: t
|
|
81
81
|
};
|
|
82
82
|
}, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
83
|
-
const
|
|
83
|
+
const p = (e, t) => {
|
|
84
84
|
if (!e) {
|
|
85
85
|
console.info("No Value");
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
88
|
+
const o = window.$l("Copied");
|
|
89
|
+
let r;
|
|
90
|
+
if (t ? window.$getType(t) !== "Boolean" ? r = `${o} ${t}: ${e}` : r = `${o}: ${e}` : r = o, navigator.clipboard && window.isSecureContext)
|
|
91
91
|
navigator.clipboard.writeText(e).then(() => {
|
|
92
92
|
i.config.globalProperties.$message.success({
|
|
93
|
-
message:
|
|
93
|
+
message: r,
|
|
94
94
|
// grouping: true,
|
|
95
95
|
center: !0,
|
|
96
96
|
duration: 0
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
else {
|
|
100
|
-
let
|
|
101
|
-
|
|
102
|
-
message:
|
|
100
|
+
let n = document.createElement("textarea");
|
|
101
|
+
n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), i.config.globalProperties.$message.success({
|
|
102
|
+
message: r,
|
|
103
103
|
// grouping: true,
|
|
104
104
|
center: !0,
|
|
105
105
|
duration: 0
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
window.$copy =
|
|
110
|
-
const
|
|
111
|
-
window.$sc =
|
|
112
|
-
const
|
|
109
|
+
window.$copy = p, i.config.globalProperties.$copy = p;
|
|
110
|
+
const F = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
|
|
111
|
+
window.$sc = F;
|
|
112
|
+
const C = {
|
|
113
113
|
cpa: "avgCPA",
|
|
114
114
|
cpt: "avgCPT"
|
|
115
|
-
}, T = (e,
|
|
116
|
-
const
|
|
117
|
-
|
|
115
|
+
}, T = (e, t = C) => {
|
|
116
|
+
const o = t[e.name];
|
|
117
|
+
o && (e.name = o);
|
|
118
118
|
};
|
|
119
119
|
window.$nr = T;
|
|
120
|
-
const
|
|
121
|
-
objMap[
|
|
120
|
+
const k = (e, t) => (Object.keys(e).forEach((o) => {
|
|
121
|
+
objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
|
|
122
122
|
}), e);
|
|
123
|
-
window.$nro =
|
|
123
|
+
window.$nro = k;
|
|
124
124
|
const P = (e) => {
|
|
125
|
-
let
|
|
126
|
-
return Object.keys(e).forEach((
|
|
127
|
-
(window.$getType(e[
|
|
128
|
-
}),
|
|
125
|
+
let t = 0;
|
|
126
|
+
return Object.keys(e).forEach((o) => {
|
|
127
|
+
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
|
|
128
|
+
}), t;
|
|
129
129
|
};
|
|
130
130
|
window.$pc = P;
|
|
131
|
+
const m = {
|
|
132
|
+
info: {
|
|
133
|
+
tag: "background-color:#0085FF; color:#f1f7ff;",
|
|
134
|
+
style: "background-color:#f1f7ff; color:#0085FF;"
|
|
135
|
+
},
|
|
136
|
+
log: {
|
|
137
|
+
tag: "background-color:#FFFFFF; color:#272b41;",
|
|
138
|
+
style: "background-color:#272b41; color:#FFFFFF;"
|
|
139
|
+
},
|
|
140
|
+
error: {
|
|
141
|
+
tag: "background-color:#ff4d4f; color:#fff3f3;",
|
|
142
|
+
style: "background-color:#fff3f3; color:#ff4d4f;"
|
|
143
|
+
},
|
|
144
|
+
warn: {
|
|
145
|
+
tag: "background-color:#fa8b0c; color:#fffbf6;",
|
|
146
|
+
style: "background-color:#fffbf6; color:#fa8b0c;"
|
|
147
|
+
},
|
|
148
|
+
success: {
|
|
149
|
+
tag: "background-color:#20c997; color:#f6fffc;",
|
|
150
|
+
style: "background-color:#f6fffc; color:#20c997;"
|
|
151
|
+
}
|
|
152
|
+
}, s = (e = "info", t) => {
|
|
153
|
+
e === "success" && (e = "info"), console[e](
|
|
154
|
+
`%c ${e.toUpperCase()} %c┆${t}┆`,
|
|
155
|
+
`${m[e].tag}`,
|
|
156
|
+
`${m[e].style}`
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
window.$console = {
|
|
160
|
+
info: (...e) => {
|
|
161
|
+
s("info", e);
|
|
162
|
+
},
|
|
163
|
+
log: (...e) => {
|
|
164
|
+
s("log", e);
|
|
165
|
+
},
|
|
166
|
+
error: (...e) => {
|
|
167
|
+
s("error", e);
|
|
168
|
+
},
|
|
169
|
+
warn: (...e) => {
|
|
170
|
+
s("warn", e);
|
|
171
|
+
},
|
|
172
|
+
success: (...e) => {
|
|
173
|
+
s("success", e);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
131
176
|
};
|
|
132
177
|
export {
|
|
133
|
-
|
|
178
|
+
S as d
|
|
134
179
|
};
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magtool",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"author": "magxl",
|
|
6
|
-
"main": "./dist/index.
|
|
7
|
-
"module": "./dist/index.
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"import": "./dist/index.
|
|
11
|
-
"require": "./dist/index.
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./cps": {
|
|
14
|
-
"import": "./dist/cps.
|
|
15
|
-
"require": "./dist/cps.
|
|
14
|
+
"import": "./dist/cps.js",
|
|
15
|
+
"require": "./dist/cps.js"
|
|
16
16
|
},
|
|
17
17
|
"./directive": {
|
|
18
|
-
"import": "./dist/directive.
|
|
19
|
-
"require": "./dist/directive.
|
|
18
|
+
"import": "./dist/directive.js",
|
|
19
|
+
"require": "./dist/directive.js"
|
|
20
20
|
},
|
|
21
21
|
"./util": {
|
|
22
|
-
"import": "./dist/util.
|
|
23
|
-
"require": "./dist/util.
|
|
22
|
+
"import": "./dist/util.js",
|
|
23
|
+
"require": "./dist/util.js"
|
|
24
24
|
},
|
|
25
25
|
"./store": {
|
|
26
|
-
"import": "./dist/store.
|
|
27
|
-
"require": "./dist/store.
|
|
26
|
+
"import": "./dist/store.js",
|
|
27
|
+
"require": "./dist/store.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist/*"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"magtool": "^1.0.
|
|
38
|
+
"magtool": "^1.0.3",
|
|
39
39
|
"moment": "^2.30.1",
|
|
40
40
|
"pinia": "^3.0.0",
|
|
41
41
|
"vue": "^3.3.4"
|