magtool 1.0.7 → 1.0.9
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/cps.js +73 -158
- package/dist/directive.js +19 -26
- package/dist/index.js +10 -15
- package/dist/store.js +8 -8
- package/dist/util.js +114 -241
- package/package.json +4 -2
package/dist/cps.js
CHANGED
|
@@ -1,171 +1,86 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { age:
|
|
3
|
-
let
|
|
4
|
-
if (
|
|
5
|
-
const { minAge: e, maxAge:
|
|
6
|
-
|
|
1
|
+
const v = { useAgeFormat: (t) => {
|
|
2
|
+
const { age: a } = t || {};
|
|
3
|
+
let n, o;
|
|
4
|
+
if (a != null && a.included) {
|
|
5
|
+
const { minAge: e, maxAge: l } = a.included[0] || {};
|
|
6
|
+
n = e || "all", o = l || "all";
|
|
7
7
|
}
|
|
8
|
-
return
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} : {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
maxAge: o
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}, h = (t) => {
|
|
23
|
-
const { gender: o } = t || {};
|
|
24
|
-
return o != null && o.included ? o.included[0] : null;
|
|
25
|
-
}, y = { useAgeFormat: $, useAgeValue: b, useGenderFormat: h }, P = (t) => new Promise((o, s) => {
|
|
26
|
-
const n = new Image();
|
|
27
|
-
n.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), n.onload = () => o(n), n.onerror = () => s(new Error("Could not load image"));
|
|
28
|
-
}), C = (t) => new Promise((o, s) => {
|
|
29
|
-
const n = document.createElement("video");
|
|
30
|
-
n.preload = "metadata", window.$getType(t) === "String" ? n.src = t : n.src = URL.createObjectURL(t), n.onloadedmetadata = () => {
|
|
31
|
-
window.URL.revokeObjectURL(t), console.info([n]), o(n);
|
|
8
|
+
return o === "all" ? n === "all" ? "All" : `${n}~65+` : `${n}~${o}`;
|
|
9
|
+
}, useAgeValue: (t, a) => t === "all" ? null : a === 65 ? { included: [{ minAge: t }] } : { included: [{ minAge: t, maxAge: a }] }, useGenderFormat: (t) => {
|
|
10
|
+
const { gender: a } = t || {};
|
|
11
|
+
return a != null && a.included ? a.included[0] : null;
|
|
12
|
+
}, loadImage: (t) => new Promise((a, n) => {
|
|
13
|
+
const o = new Image();
|
|
14
|
+
o.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), o.onload = () => a(o), o.onerror = () => n(new Error("Could not load image"));
|
|
15
|
+
}), loadVideo: (t) => new Promise((a, n) => {
|
|
16
|
+
const o = document.createElement("video");
|
|
17
|
+
o.preload = "metadata", window.$getType(t) === "String" ? o.src = t : o.src = URL.createObjectURL(t), o.onloadedmetadata = () => {
|
|
18
|
+
window.URL.revokeObjectURL(t), a(o);
|
|
32
19
|
};
|
|
33
|
-
}),
|
|
34
|
-
let
|
|
20
|
+
}), download: ({ type: t = "csv", data: a, name: n }) => {
|
|
21
|
+
let o = document.createElement("a");
|
|
35
22
|
if (t === "csv") {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
n.href = URL.createObjectURL(r);
|
|
23
|
+
const l = new Blob(["\uFEFF" + a], { type: "text/csv,charset=UTF-8" });
|
|
24
|
+
o.href = URL.createObjectURL(l);
|
|
40
25
|
}
|
|
41
26
|
let e = new MouseEvent("click");
|
|
42
|
-
|
|
43
|
-
},
|
|
27
|
+
o.download = n || "download", o.dispatchEvent(e), t !== "csv" && t !== "video" || URL.revokeObjectURL(o.url), o = null, e = null;
|
|
28
|
+
}, useSingleSelect: ({ table: t, key: a, form: n, value: o, cb: e = () => {
|
|
44
29
|
} }) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
let { sortable:
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
label: "-"
|
|
68
|
-
}), S = ({ columns: t, data: o, currency: s = "", channel: n = "" }) => {
|
|
69
|
-
if (!o.length || !t.length)
|
|
70
|
-
return [];
|
|
71
|
-
const e = {
|
|
72
|
-
spend: {
|
|
73
|
-
prop: "spend",
|
|
74
|
-
prefix: s,
|
|
75
|
-
format: (a) => window.$fa(a, 2)
|
|
76
|
-
},
|
|
77
|
-
taps: {
|
|
78
|
-
prop: "taps",
|
|
79
|
-
format: (a) => window.$fa(a, 0)
|
|
80
|
-
},
|
|
81
|
-
installs: {
|
|
82
|
-
prop: "installs",
|
|
83
|
-
format: (a) => window.$fa(a, 0)
|
|
84
|
-
},
|
|
85
|
-
impressions: {
|
|
86
|
-
prop: "impressions",
|
|
87
|
-
format: (a) => window.$fa(a, 0)
|
|
88
|
-
},
|
|
89
|
-
mmpInstalls: {
|
|
90
|
-
prop: "mmpInstalls",
|
|
91
|
-
format: (a) => window.$fa(a, 0)
|
|
92
|
-
},
|
|
93
|
-
mmpCPI: {
|
|
94
|
-
prop: "mmpCPI",
|
|
95
|
-
format: (a) => window.$fa(a, 2)
|
|
96
|
-
},
|
|
97
|
-
IPM: {
|
|
98
|
-
prop: "IPM",
|
|
99
|
-
format: (a) => window.$fa(a, 2)
|
|
100
|
-
},
|
|
101
|
-
revenue: {
|
|
102
|
-
prop: "revenue",
|
|
103
|
-
format: (a) => window.$fa(a, 2)
|
|
104
|
-
}
|
|
105
|
-
}, r = [], l = {
|
|
106
|
-
avgCPT: {},
|
|
107
|
-
avgCPA: {},
|
|
108
|
-
avgCPM: {},
|
|
109
|
-
cr: {},
|
|
110
|
-
ttr: {},
|
|
111
|
-
IPM: {},
|
|
112
|
-
mmpInstalls: {},
|
|
113
|
-
mmpCPI: {}
|
|
114
|
-
};
|
|
115
|
-
t.forEach((a, i) => {
|
|
116
|
-
l[a.property] && (l[a.property].i = i);
|
|
117
|
-
const m = e[a.property];
|
|
118
|
-
if (m) {
|
|
119
|
-
m.i = i;
|
|
30
|
+
const l = t.getSelectionRows();
|
|
31
|
+
l.length > 1 ? (t.clearSelection(), t.toggleRowSelection(l[1], "selected"), n[o] = l[1][a]) : l.length === 1 && (n[o] = l[0][a]), e();
|
|
32
|
+
}, useColumn: (t = {}) => {
|
|
33
|
+
let { sortable: a = !0, empty: n = !1, mmp: o = !1 } = t, e = window.$map.asa.asaMetric.all;
|
|
34
|
+
o && (e = e.concat(window.$map.asa.mmpMetric.all));
|
|
35
|
+
const l = e.map((s, m) => ({ label: s.label, prop: s.value, width: s.width, sortable: a, type: s.type, align: s.align, visible: s.visible, formatter: s.formatter }));
|
|
36
|
+
return l.unshift({ label: "Currency", prop: "currency", width: 80, align: "right" }), l;
|
|
37
|
+
}, useEmptyColumn: () => ({ label: "-" }), useRemoteSummary: ({ columns: t, data: a }, n) => t.length && a.length ? t.map((o) => {
|
|
38
|
+
let e = n[o.property] === void 0 ? "" : n[o.property];
|
|
39
|
+
if (e !== "") try {
|
|
40
|
+
e = window.$fa(e, window.$map.asa.allMetric.obj[o.property].precision);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
}) : [], useSummary: ({ columns: t, data: a, currency: n = "", channel: o = "" }) => {
|
|
45
|
+
if (!a.length || !t.length) return [];
|
|
46
|
+
const e = { spend: { prop: "spend", prefix: n, format: (r) => window.$fa(r, 2) }, taps: { prop: "taps", format: (r) => window.$fa(r, 0) }, installs: { prop: "installs", format: (r) => window.$fa(r, 0) }, impressions: { prop: "impressions", format: (r) => window.$fa(r, 0) }, mmpInstalls: { prop: "mmpInstalls", format: (r) => window.$fa(r, 0) }, mmpCPI: { prop: "mmpCPI", format: (r) => window.$fa(r, 2) }, IPM: { prop: "IPM", format: (r) => window.$fa(r, 2) }, revenue: { prop: "revenue", format: (r) => window.$fa(r, 2) } }, l = [], s = { avgCPT: {}, avgCPA: {}, avgCPM: {}, cr: {}, ttr: {}, IPM: {}, mmpInstalls: {}, mmpCPI: {} };
|
|
47
|
+
t.forEach((r, i) => {
|
|
48
|
+
s[r.property] && (s[r.property].i = i);
|
|
49
|
+
const p = e[r.property];
|
|
50
|
+
if (p) {
|
|
51
|
+
p.i = i;
|
|
120
52
|
let c = window.$bigNumber(0);
|
|
121
|
-
|
|
122
|
-
c = c.plus(
|
|
123
|
-
}), c = c.toNumber(),
|
|
124
|
-
} else
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
i.format && r[i.i] && (r[i.i] = i.format(r[i.i]));
|
|
53
|
+
a.forEach((g) => {
|
|
54
|
+
c = c.plus(g[r.property] || 0);
|
|
55
|
+
}), c = c.toNumber(), p.total = c, l.push(c);
|
|
56
|
+
} else l.push("");
|
|
57
|
+
}), Object.keys(e).forEach((r) => {
|
|
58
|
+
const i = e[r];
|
|
59
|
+
i.format && l[i.i] && (l[i.i] = i.format(l[i.i]));
|
|
129
60
|
});
|
|
130
|
-
const
|
|
131
|
-
|
|
61
|
+
const m = e.taps.total ? window.$fa(e.spend.total / e.taps.total) : "0.00";
|
|
62
|
+
l[s.avgCPT.i] = m;
|
|
132
63
|
const d = e.installs.total ? window.$fa(e.spend.total / e.installs.total) : "0.00";
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
|
|
64
|
+
if (l[s.avgCPA.i] = d, s.avgCPM.i !== void 0) {
|
|
65
|
+
const r = e.impressions.total ? window.$fa(e.spend.total / (e.impressions.total / 1e3)) : "0.00";
|
|
66
|
+
l[s.avgCPM.i] = r;
|
|
136
67
|
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
return
|
|
143
|
-
},
|
|
144
|
-
const
|
|
145
|
-
return Object.keys(t).forEach((
|
|
146
|
-
const
|
|
147
|
-
|
|
68
|
+
const w = e.taps.total ? window.$fa(e.installs.total / e.taps.total * 100) : "0.00";
|
|
69
|
+
l[s.cr.i] = w;
|
|
70
|
+
const u = e.impressions.total ? window.$fa(e.taps.total / e.impressions.total * 100) : "0.00";
|
|
71
|
+
l[s.ttr.i] = u;
|
|
72
|
+
const f = e.impressions.total ? window.$fa(1e3 * e.installs.total / e.impressions.total) : "0.00";
|
|
73
|
+
return l[s.IPM.i] = f, l;
|
|
74
|
+
}, useFormat: (t) => {
|
|
75
|
+
const a = window.$map.asa.allMetric.obj;
|
|
76
|
+
return Object.keys(t).forEach((n) => {
|
|
77
|
+
const o = t[n];
|
|
78
|
+
a[n] && (t[`${n}Format`] = window.$fu({ prop: n, value: o, currency: !1, obj: a }));
|
|
148
79
|
}), t;
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
r = window.$fa(r, window.$map.asa.allMetric.obj[e.property].precision);
|
|
154
|
-
} catch {
|
|
155
|
-
}
|
|
156
|
-
return r;
|
|
157
|
-
}) : [], L = { useSingleSelect: A, useColumn: I, useEmptyColumn: j, useRemoteSummary: E, useSummary: S, useFormat: U }, T = (t, o = 88) => {
|
|
158
|
-
const s = document.querySelector("html"), { scrollTop: n } = s, e = t.getBoundingClientRect();
|
|
159
|
-
s.scrollTo({
|
|
160
|
-
top: n + e.y - o,
|
|
161
|
-
behavior: "smooth"
|
|
162
|
-
});
|
|
163
|
-
}, O = { pageScrollTo: T }, x = {
|
|
164
|
-
...y,
|
|
165
|
-
...R,
|
|
166
|
-
...L,
|
|
167
|
-
...O
|
|
168
|
-
};
|
|
80
|
+
}, pageScrollTo: (t, a = 88) => {
|
|
81
|
+
const n = document.querySelector("html"), { scrollTop: o } = n, e = t.getBoundingClientRect();
|
|
82
|
+
n.scrollTo({ top: o + e.y - a, behavior: "smooth" });
|
|
83
|
+
} };
|
|
169
84
|
export {
|
|
170
|
-
|
|
85
|
+
v as c
|
|
171
86
|
};
|
package/dist/directive.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
const m = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
}), o.directive("pms", {
|
|
22
|
-
mounted(t, i, l) {
|
|
23
|
-
var e;
|
|
24
|
-
(e = i.value) != null && e.readonly && t.remove();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
1
|
+
const m = (l) => {
|
|
2
|
+
l.directive("copy", { mounted(t, o) {
|
|
3
|
+
let { value: r, arg: e } = o;
|
|
4
|
+
t.onclick = () => {
|
|
5
|
+
window.$copy(r, e);
|
|
6
|
+
};
|
|
7
|
+
} }), l.directive("focus", { mounted(t, o, r) {
|
|
8
|
+
let { value: e = 0, arg: n = "time" } = o;
|
|
9
|
+
if (e === null) return;
|
|
10
|
+
let c = 100, u = 0;
|
|
11
|
+
n !== "time" ? u = e : c = Number(e);
|
|
12
|
+
const a = setTimeout(() => {
|
|
13
|
+
let i = t.querySelectorAll("input, textarea");
|
|
14
|
+
i[u].focus(), i[u].select(), clearTimeout(a);
|
|
15
|
+
}, c);
|
|
16
|
+
} }), l.directive("pms", { mounted(t, o, r) {
|
|
17
|
+
var e;
|
|
18
|
+
(e = o.value) != null && e.readonly && t.remove();
|
|
19
|
+
} });
|
|
27
20
|
};
|
|
28
21
|
export {
|
|
29
22
|
m as d
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import _ from "moment";
|
|
2
|
-
import { c as
|
|
3
|
-
import { d as
|
|
4
|
-
import { d as
|
|
5
|
-
import { s as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
|
|
10
|
-
|
|
11
|
-
weekdaysMin: "日_一_二_三_四_五_六".split("_")
|
|
12
|
-
}), window.$m = _, window.$moment = _, {
|
|
13
|
-
composition: t,
|
|
14
|
-
store: i
|
|
15
|
-
});
|
|
2
|
+
import { c as s } from "./cps.js";
|
|
3
|
+
import { d as e } from "./util.js";
|
|
4
|
+
import { d as m } from "./directive.js";
|
|
5
|
+
import { s as r } from "./store.js";
|
|
6
|
+
const d = (t, i) => {
|
|
7
|
+
t.use(e).use(m);
|
|
8
|
+
const o = localStorage.getItem("lang");
|
|
9
|
+
return o && o.includes("cn") && _.locale("zh-cn", { months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"), monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"), weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"), weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"), weekdaysMin: "日_一_二_三_四_五_六".split("_") }), window.$m = _, window.$moment = _, { composition: s, store: r };
|
|
10
|
+
};
|
|
16
11
|
export {
|
|
17
|
-
|
|
12
|
+
d as default
|
|
18
13
|
};
|
package/dist/store.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createPinia as
|
|
2
|
-
const a =
|
|
3
|
-
const
|
|
4
|
-
return Object.keys(
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
}), { pinia: a, store:
|
|
1
|
+
import { createPinia as r, defineStore as s } from "pinia";
|
|
2
|
+
const a = r(), n = (t) => {
|
|
3
|
+
const e = {};
|
|
4
|
+
return Object.keys(t).forEach((c) => {
|
|
5
|
+
const o = c.match(/chip\/(\S*).js/)[1];
|
|
6
|
+
e[o] = s(o, t[c].default);
|
|
7
|
+
}), { pinia: a, store: e };
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
n as s
|
|
11
11
|
};
|
package/dist/util.js
CHANGED
|
@@ -1,295 +1,168 @@
|
|
|
1
|
-
const
|
|
1
|
+
const j = (c) => {
|
|
2
2
|
window.$getLang = () => localStorage.getItem("lang");
|
|
3
3
|
const u = (e = {}) => {
|
|
4
|
-
const { alpha:
|
|
5
|
-
|
|
6
|
-
"red",
|
|
7
|
-
"orange",
|
|
8
|
-
"green",
|
|
9
|
-
"pink",
|
|
10
|
-
"yellow",
|
|
11
|
-
"purple",
|
|
12
|
-
"primary",
|
|
13
|
-
"dark"
|
|
14
|
-
], r = ["", 1, 3, 5, 7], c = o || t[parseInt(Math.random() * t.length)], l = n === 0 ? "" : r[parseInt(Math.random() * r.length)];
|
|
15
|
-
return `${c}${l}`;
|
|
4
|
+
const { alpha: t, name: o } = e, n = ["blue", "red", "orange", "green", "pink", "yellow", "purple", "primary", "dark"], r = ["", 1, 3, 5, 7];
|
|
5
|
+
return `${o || n[parseInt(Math.random() * n.length)]}${t === 0 ? "" : r[parseInt(Math.random() * r.length)]}`;
|
|
16
6
|
};
|
|
17
|
-
window.$randomColor = u, window.$rc = u,
|
|
18
|
-
const U = (e, n = 0) => {
|
|
7
|
+
window.$randomColor = u, window.$rc = u, c.config.globalProperties.$rc = u, window.$rn = (e, t = 0) => {
|
|
19
8
|
let o = parseInt(Math.random() * e);
|
|
20
|
-
return o +=
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
o = o || t[n];
|
|
26
|
-
const r = o + "FF", c = o + "00";
|
|
27
|
-
return {
|
|
28
|
-
type: "linear",
|
|
29
|
-
x: 0,
|
|
30
|
-
y: 0,
|
|
31
|
-
x2: 0,
|
|
32
|
-
y2: 1,
|
|
33
|
-
colorStops: [
|
|
34
|
-
{
|
|
35
|
-
offset: 0,
|
|
36
|
-
color: r
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
offset: 1,
|
|
40
|
-
color: c
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
};
|
|
9
|
+
return o += t, o;
|
|
10
|
+
}, window.$elc = (e = {}) => {
|
|
11
|
+
let { i: t = 0, color: o } = e;
|
|
12
|
+
const n = window.global.config.color;
|
|
13
|
+
return o = o || n[t], { type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: o + "FF" }, { offset: 1, color: o + "00" }] };
|
|
44
14
|
}, window.$egc = (e = {}) => {
|
|
45
|
-
let { i:
|
|
46
|
-
const
|
|
47
|
-
o = o || t[
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
type: "radial",
|
|
51
|
-
x: 0.1,
|
|
52
|
-
y: 0.5,
|
|
53
|
-
r: 1,
|
|
54
|
-
colorStops: [
|
|
55
|
-
{
|
|
56
|
-
offset: 0,
|
|
57
|
-
color: o + "00"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
offset: 1,
|
|
61
|
-
color: r
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
const C = (e, n) => {
|
|
15
|
+
let { i: t = 0, color: o } = e;
|
|
16
|
+
const n = window.global.config.color;
|
|
17
|
+
return o = o || n[t], { type: "radial", x: 0.1, y: 0.5, r: 1, colorStops: [{ offset: 0, color: o + "00" }, { offset: 1, color: o + "FF" }] };
|
|
18
|
+
}, window.$fd = (e, t) => {
|
|
67
19
|
let o = [];
|
|
68
|
-
for (let
|
|
69
|
-
o.push(n(t));
|
|
20
|
+
for (let n = 0; n < e; n++) o.push(t(n));
|
|
70
21
|
return o;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}, n) {
|
|
22
|
+
}, c.config.globalProperties.$setTimeout = function(e = () => {
|
|
23
|
+
}, t) {
|
|
74
24
|
this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
|
|
75
25
|
e(), clearTimeout(this.timer);
|
|
76
|
-
},
|
|
26
|
+
}, t);
|
|
77
27
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
28
|
+
const g = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
|
|
29
|
+
c.config.globalProperties.$toUpperCamel = g, window.$toUpperCamel = g;
|
|
30
|
+
const m = (e, t = 2) => {
|
|
81
31
|
const o = window.$getType(e);
|
|
82
|
-
let
|
|
83
|
-
o === "Number" ? (e = e.toFixed(
|
|
32
|
+
let n;
|
|
33
|
+
o === "Number" ? (e = e.toFixed(t), n = String(e), e = String(Math.abs(e))) : o === "String" && (n = e, e = String(Math.abs(Number(e))));
|
|
84
34
|
const r = e.split(".");
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
|
|
35
|
+
let i = r[0].split("");
|
|
36
|
+
i = i.reverse();
|
|
37
|
+
let p = [];
|
|
38
|
+
i.forEach((l, w) => {
|
|
39
|
+
w !== 0 && w % 3 == 0 && p.push(","), p.push(l);
|
|
90
40
|
});
|
|
91
|
-
let
|
|
92
|
-
return window.$getType(
|
|
41
|
+
let s = p.reverse().join("");
|
|
42
|
+
return window.$getType(t) === "Number" && t > 0 && (s += ".", r[1] ? s += r[1].padEnd(t, 0).substr(0, t) : s += "0".padEnd(t, "0")), Number(n) !== Number(e) ? `-${s}` : s;
|
|
93
43
|
};
|
|
94
|
-
window.$fa =
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
currency:
|
|
98
|
-
value: o,
|
|
99
|
-
obj: t = window.$map.asa.asaMetric.allObj
|
|
100
|
-
}) => {
|
|
101
|
-
const r = t[e];
|
|
102
|
-
return r.unit === "currency" ? n ? `${n} ${window.$fa(o, r == null ? void 0 : r.precision)}` : window.$fa(o, r == null ? void 0 : r.precision) : r.unit === "%" ? `${window.$fa(o, r == null ? void 0 : r.precision)}%` : window.$fa(o, r == null ? void 0 : r.precision);
|
|
44
|
+
window.$fa = m, c.config.globalProperties.$fa = m;
|
|
45
|
+
const $ = ({ prop: e, currency: t, value: o, obj: n = window.$map.asa.asaMetric.allObj }) => {
|
|
46
|
+
const r = n[e];
|
|
47
|
+
return r.unit === "currency" ? t ? `${t} ${window.$fa(o, r == null ? void 0 : r.precision)}` : window.$fa(o, r == null ? void 0 : r.precision) : r.unit === "%" ? `${window.$fa(o, r == null ? void 0 : r.precision)}%` : window.$fa(o, r == null ? void 0 : r.precision);
|
|
103
48
|
};
|
|
104
|
-
window.$fu2 =
|
|
49
|
+
window.$fu2 = $, c.config.globalProperties.$fu2 = $;
|
|
105
50
|
const b = (e = () => {
|
|
106
|
-
},
|
|
51
|
+
}, t = 2) => {
|
|
107
52
|
let o = null;
|
|
108
|
-
return new Promise((
|
|
53
|
+
return new Promise((n, r) => {
|
|
109
54
|
o = setTimeout(() => {
|
|
110
|
-
e(
|
|
111
|
-
},
|
|
55
|
+
e(n, r), clearTimeout(o), n(!0);
|
|
56
|
+
}, 100 * t);
|
|
112
57
|
});
|
|
113
58
|
};
|
|
114
59
|
window.$pm = b, window.$promise = b;
|
|
115
|
-
const
|
|
116
|
-
},
|
|
60
|
+
const h = (e = () => {
|
|
61
|
+
}, t = 500) => {
|
|
117
62
|
let o;
|
|
118
|
-
return function(...
|
|
63
|
+
return function(...n) {
|
|
119
64
|
o && clearTimeout(o), o = setTimeout(() => {
|
|
120
|
-
e.apply(this,
|
|
121
|
-
},
|
|
65
|
+
e.apply(this, n);
|
|
66
|
+
}, t);
|
|
122
67
|
};
|
|
123
68
|
};
|
|
124
|
-
window.$db =
|
|
69
|
+
window.$db = h, window.$debounce = h, Number.prototype.toFixedNumber = function(e) {
|
|
125
70
|
return Number(this.toFixed(e));
|
|
126
71
|
}, Array.prototype.filter1 = function(e) {
|
|
127
|
-
if (!e || typeof e != "function")
|
|
128
|
-
|
|
129
|
-
let n,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
o = t, n = this[t];
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
index: o,
|
|
137
|
-
data: n
|
|
138
|
-
};
|
|
139
|
-
}, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
140
|
-
const h = (e, n) => {
|
|
141
|
-
if (!e) {
|
|
142
|
-
console.info("No Value");
|
|
143
|
-
return;
|
|
72
|
+
if (!e || typeof e != "function") throw new Error(e + " is not a function");
|
|
73
|
+
let t, o;
|
|
74
|
+
for (let n = 0; n < this.length; n++) if (e(this[n], n, this)) {
|
|
75
|
+
o = n, t = this[n];
|
|
76
|
+
break;
|
|
144
77
|
}
|
|
78
|
+
return { index: o, data: t };
|
|
79
|
+
}, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
80
|
+
const y = (e, t) => {
|
|
81
|
+
if (!e) return;
|
|
145
82
|
const o = window.$l("Copied");
|
|
146
|
-
let
|
|
147
|
-
if (n ? window.$getType(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
message: t,
|
|
151
|
-
// grouping: true,
|
|
152
|
-
center: !0,
|
|
153
|
-
duration: 0
|
|
154
|
-
});
|
|
155
|
-
});
|
|
83
|
+
let n;
|
|
84
|
+
if (n = t ? window.$getType(t) !== "Boolean" ? `${o} ${t}: ${e}` : `${o}: ${e}` : o, navigator.clipboard && window.isSecureContext) navigator.clipboard.writeText(e).then(() => {
|
|
85
|
+
c.config.globalProperties.$message.success({ message: n, center: !0, duration: 0 });
|
|
86
|
+
});
|
|
156
87
|
else {
|
|
157
88
|
let r = document.createElement("textarea");
|
|
158
|
-
r.value = e, r.style.position = "fixed", r.style.opacity = 0, document.body.appendChild(r), r.select(), document.execCommand("Copy"), r.remove(),
|
|
159
|
-
message: t,
|
|
160
|
-
// grouping: true,
|
|
161
|
-
center: !0,
|
|
162
|
-
duration: 0
|
|
163
|
-
});
|
|
89
|
+
r.value = e, r.style.position = "fixed", r.style.opacity = 0, document.body.appendChild(r), r.select(), document.execCommand("Copy"), r.remove(), c.config.globalProperties.$message.success({ message: n, center: !0, duration: 0 });
|
|
164
90
|
}
|
|
165
91
|
};
|
|
166
|
-
window.$copy =
|
|
167
|
-
const
|
|
168
|
-
window.$
|
|
169
|
-
|
|
170
|
-
cpa: "avgCPA",
|
|
171
|
-
cpt: "avgCPT"
|
|
172
|
-
}, j = (e, n = O) => {
|
|
173
|
-
const o = n[e.name];
|
|
92
|
+
window.$copy = y, c.config.globalProperties.$copy = y, window.$sc = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
|
|
93
|
+
const T = { cpa: "avgCPA", cpt: "avgCPT" };
|
|
94
|
+
window.$nr = (e, t = T) => {
|
|
95
|
+
const o = t[e.name];
|
|
174
96
|
o && (e.name = o);
|
|
175
|
-
}
|
|
176
|
-
window.$nr = j;
|
|
177
|
-
const E = (e, n) => (Object.keys(e).forEach((o) => {
|
|
97
|
+
}, window.$nro = (e, t) => (Object.keys(e).forEach((o) => {
|
|
178
98
|
objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
|
|
179
|
-
}), e)
|
|
180
|
-
|
|
181
|
-
const P = (e) => {
|
|
182
|
-
let n = 0;
|
|
99
|
+
}), e), window.$pc = (e) => {
|
|
100
|
+
let t = 0;
|
|
183
101
|
return Object.keys(e).forEach((o) => {
|
|
184
|
-
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) &&
|
|
185
|
-
}),
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
log
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
style: "background-color:#f6fffc; color:#20c997;"
|
|
208
|
-
}
|
|
209
|
-
}, f = (e = "info", n) => {
|
|
210
|
-
e === "success" && (e = "info"), console[e](
|
|
211
|
-
`%c ${e.toUpperCase()} %c┆${n}┆`,
|
|
212
|
-
`${y[e].tag}`,
|
|
213
|
-
`${y[e].style}`
|
|
214
|
-
);
|
|
215
|
-
};
|
|
216
|
-
window.$console = {
|
|
217
|
-
info: (...e) => {
|
|
218
|
-
f("info", e);
|
|
219
|
-
},
|
|
220
|
-
log: (...e) => {
|
|
221
|
-
f("log", e);
|
|
222
|
-
},
|
|
223
|
-
error: (...e) => {
|
|
224
|
-
f("error", e);
|
|
225
|
-
},
|
|
226
|
-
warn: (...e) => {
|
|
227
|
-
f("warn", e);
|
|
228
|
-
},
|
|
229
|
-
success: (...e) => {
|
|
230
|
-
f("success", e);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
const R = (e) => new Promise((n, o) => {
|
|
234
|
-
const t = new Image();
|
|
235
|
-
t.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), t.onload = () => n(t), t.onerror = () => o(new Error("Could not load image"));
|
|
236
|
-
});
|
|
237
|
-
window.$loadImage = R;
|
|
238
|
-
const S = (e) => new Promise((n, o) => {
|
|
239
|
-
const t = document.createElement("video");
|
|
240
|
-
t.preload = "metadata", window.$getType(e) === "String" ? t.src = e : t.src = URL.createObjectURL(e), t.onloadedmetadata = () => {
|
|
241
|
-
window.URL.revokeObjectURL(e), console.info([t]), n(t);
|
|
102
|
+
(window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
|
|
103
|
+
}), t;
|
|
104
|
+
};
|
|
105
|
+
const d = (e = "info", t) => {
|
|
106
|
+
e === "success" && (e = "info");
|
|
107
|
+
};
|
|
108
|
+
window.$console = { info: (...e) => {
|
|
109
|
+
d("info");
|
|
110
|
+
}, log: (...e) => {
|
|
111
|
+
d("log");
|
|
112
|
+
}, error: (...e) => {
|
|
113
|
+
d("error");
|
|
114
|
+
}, warn: (...e) => {
|
|
115
|
+
d("warn");
|
|
116
|
+
}, success: (...e) => {
|
|
117
|
+
d("success");
|
|
118
|
+
} }, window.$loadImage = (e) => new Promise((t, o) => {
|
|
119
|
+
const n = new Image();
|
|
120
|
+
n.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), n.onload = () => t(n), n.onerror = () => o(new Error("Could not load image"));
|
|
121
|
+
}), window.$loadVideo = (e) => new Promise((t, o) => {
|
|
122
|
+
const n = document.createElement("video");
|
|
123
|
+
n.preload = "metadata", window.$getType(e) === "String" ? n.src = e : n.src = URL.createObjectURL(e), n.onloadedmetadata = () => {
|
|
124
|
+
window.URL.revokeObjectURL(e), t(n);
|
|
242
125
|
};
|
|
243
126
|
});
|
|
244
|
-
|
|
245
|
-
const k = (e) => {
|
|
127
|
+
const v = (e) => {
|
|
246
128
|
if (e && window.$getType(e) === "Object") {
|
|
247
|
-
const
|
|
248
|
-
return Object.keys(e).forEach((
|
|
249
|
-
const
|
|
250
|
-
switch (window.$getType(
|
|
129
|
+
const t = {};
|
|
130
|
+
return Object.keys(e).forEach((o) => {
|
|
131
|
+
const n = e[o];
|
|
132
|
+
switch (window.$getType(n)) {
|
|
251
133
|
case "Object":
|
|
252
|
-
Object.keys(
|
|
134
|
+
Object.keys(n) !== 0 && (t[o] = n);
|
|
253
135
|
break;
|
|
254
136
|
case "Array":
|
|
255
|
-
|
|
137
|
+
n.length !== 0 && (t[o] = n);
|
|
256
138
|
break;
|
|
257
139
|
case "String":
|
|
258
|
-
|
|
140
|
+
n && (t[o] = n.toLowerCase());
|
|
259
141
|
break;
|
|
260
|
-
// case 'Number':
|
|
261
|
-
// r[it] = String(itv);
|
|
262
|
-
// break;
|
|
263
142
|
default:
|
|
264
|
-
[void 0, null, ""].indexOf(
|
|
265
|
-
break;
|
|
143
|
+
[void 0, null, ""].indexOf(n) === -1 && (t[o] = n);
|
|
266
144
|
}
|
|
267
|
-
}),
|
|
145
|
+
}), t;
|
|
268
146
|
}
|
|
269
147
|
};
|
|
270
|
-
window.$removeEmptyParams =
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
let { type:
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
s
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
n === "excel" && (a.method = a.method || "GET", a.headers = {
|
|
282
|
-
[l]: `${F} ${c}`
|
|
283
|
-
}), await fetch(o, a).then((d) => d.blob()).then((d) => {
|
|
284
|
-
s.href = URL.createObjectURL(d);
|
|
148
|
+
window.$removeEmptyParams = v, window.$rep = v;
|
|
149
|
+
let a = null, f = null;
|
|
150
|
+
window.$download = async (e) => {
|
|
151
|
+
let { type: t = "img", url: o, name: n, data: r } = e;
|
|
152
|
+
if (a = document.createElement("a"), t === "csv") {
|
|
153
|
+
const i = new Blob(["\uFEFF" + r], { type: "text/csv,charset=UTF-8" });
|
|
154
|
+
a.href = URL.createObjectURL(i);
|
|
155
|
+
} else if (t === "video" || t === "excel") {
|
|
156
|
+
const { access_token: i, scope: p, token_type: s } = store.launch().login.info, l = {};
|
|
157
|
+
t === "excel" && (l.method = l.method || "GET", l.headers = { [p]: `${s} ${i}` }), await fetch(o, l).then((w) => w.blob()).then((w) => {
|
|
158
|
+
a.href = URL.createObjectURL(w);
|
|
285
159
|
});
|
|
286
|
-
} else (
|
|
287
|
-
|
|
288
|
-
}) :
|
|
289
|
-
|
|
160
|
+
} else (t = "table") ? await fetch(o).then((i) => i.blob()).then((i) => {
|
|
161
|
+
a.href = URL.createObjectURL(i);
|
|
162
|
+
}) : a.href = o;
|
|
163
|
+
f = new MouseEvent("click"), a.download = n || "download", a.dispatchEvent(f), t !== "csv" && t !== "video" || URL.revokeObjectURL(a.url), a = null, f = null;
|
|
290
164
|
};
|
|
291
|
-
window.$download = x;
|
|
292
165
|
};
|
|
293
166
|
export {
|
|
294
|
-
|
|
167
|
+
j as d
|
|
295
168
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magtool",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.9",
|
|
5
5
|
"author": "magxl",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist/*"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"magtool": "^1.0.
|
|
38
|
+
"magtool": "^1.0.8",
|
|
39
39
|
"moment": "^2.30.1",
|
|
40
40
|
"pinia": "^3.0.0",
|
|
41
41
|
"vue": "^3.3.4"
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
45
45
|
"imstar-version": "^1.0.5",
|
|
46
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
47
|
+
"terser": "^5.39.0",
|
|
46
48
|
"vite": "^6.0.5"
|
|
47
49
|
},
|
|
48
50
|
"description": "",
|