magtool 1.2.1 → 1.2.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/dist/cps.js +101 -78
- package/dist/index.js +14 -18
- package/dist/store.js +6 -6
- package/package.json +1 -13
package/dist/cps.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { age:
|
|
3
|
-
let s,
|
|
4
|
-
if (
|
|
5
|
-
const { minAge:
|
|
6
|
-
|
|
1
|
+
const y = (e) => {
|
|
2
|
+
const { age: t } = e || {};
|
|
3
|
+
let s, o;
|
|
4
|
+
if (t != null && t.included) {
|
|
5
|
+
const { minAge: n, maxAge: r } = t.included[0] || {};
|
|
6
|
+
n ? s = n : s = "all", r ? o = r : o = "all";
|
|
7
7
|
}
|
|
8
|
-
return
|
|
9
|
-
},
|
|
8
|
+
return o === "all" ? s === "all" ? "All" : `${s}~65+` : `${s}~${o}`;
|
|
9
|
+
}, P = (e, t) => e === "all" ? null : t === 65 ? {
|
|
10
10
|
included: [
|
|
11
11
|
{
|
|
12
|
-
minAge:
|
|
12
|
+
minAge: e
|
|
13
13
|
}
|
|
14
14
|
]
|
|
15
15
|
} : {
|
|
16
16
|
included: [
|
|
17
17
|
{
|
|
18
|
-
minAge:
|
|
19
|
-
maxAge:
|
|
18
|
+
minAge: e,
|
|
19
|
+
maxAge: t
|
|
20
20
|
}
|
|
21
21
|
]
|
|
22
|
-
},
|
|
23
|
-
const { gender:
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
window.URL.revokeObjectURL(
|
|
22
|
+
}, C = (e) => {
|
|
23
|
+
const { gender: t } = e || {};
|
|
24
|
+
return t != null && t.included ? t.included[0] : null;
|
|
25
|
+
}, R = { useAgeFormat: y, useAgeValue: P, useGenderFormat: C }, A = (e) => new Promise((t, s) => {
|
|
26
|
+
const o = new Image();
|
|
27
|
+
o.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), o.onload = () => t(o), o.onerror = () => s(new Error("Could not load image"));
|
|
28
|
+
}), I = (e) => new Promise((t, s) => {
|
|
29
|
+
const o = document.createElement("video");
|
|
30
|
+
o.preload = "metadata", window.$getType(e) === "String" ? o.src = e : o.src = URL.createObjectURL(e), o.onloadedmetadata = () => {
|
|
31
|
+
window.URL.revokeObjectURL(e), console.info([o]), t(o);
|
|
32
32
|
};
|
|
33
|
-
}), M = ({ type:
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
36
|
-
const r = new Blob(["\uFEFF" +
|
|
33
|
+
}), M = ({ type: e = "csv", data: t, name: s }) => {
|
|
34
|
+
let o = document.createElement("a");
|
|
35
|
+
if (e === "csv") {
|
|
36
|
+
const r = new Blob(["\uFEFF" + t], {
|
|
37
37
|
type: "text/csv,charset=UTF-8"
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
o.href = URL.createObjectURL(r);
|
|
40
40
|
}
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
},
|
|
41
|
+
let n = new MouseEvent("click");
|
|
42
|
+
o.download = s || "download", o.dispatchEvent(n), (e === "csv" || e === "video") && URL.revokeObjectURL(o.url), o = null, n = null;
|
|
43
|
+
}, T = { loadImage: A, loadVideo: I, download: M }, j = ({ table: e, key: t, form: s, value: o, cb: n = () => {
|
|
44
44
|
} }) => {
|
|
45
|
-
const r =
|
|
46
|
-
r.length > 1 ? (
|
|
47
|
-
},
|
|
48
|
-
let { sortable:
|
|
49
|
-
|
|
50
|
-
const r =
|
|
45
|
+
const r = e.getSelectionRows();
|
|
46
|
+
r.length > 1 ? (e.clearSelection(), e.toggleRowSelection(r[1], "selected"), s[o] = r[1][t]) : r.length === 1 && (s[o] = r[0][t]), n();
|
|
47
|
+
}, E = (e = {}) => {
|
|
48
|
+
let { sortable: t = !0, empty: s = !1, mmp: o = !1 } = e, n = window.$map.asa.asaMetric.all;
|
|
49
|
+
o && (n = n.concat(window.$map.asa.mmpMetric.all));
|
|
50
|
+
const r = n.map((l, w) => ({
|
|
51
51
|
label: l.label,
|
|
52
52
|
prop: l.value,
|
|
53
53
|
width: l.width,
|
|
54
|
-
sortable:
|
|
54
|
+
sortable: t,
|
|
55
55
|
type: l.type,
|
|
56
56
|
align: l.align,
|
|
57
57
|
visible: l.visible,
|
|
@@ -63,12 +63,12 @@ const $ = (t) => {
|
|
|
63
63
|
width: 80,
|
|
64
64
|
align: "right"
|
|
65
65
|
}), r;
|
|
66
|
-
},
|
|
66
|
+
}, S = () => ({
|
|
67
67
|
label: "-"
|
|
68
|
-
}),
|
|
69
|
-
if (!
|
|
68
|
+
}), U = ({ columns: e, data: t, currency: s = "", channel: o = "" }) => {
|
|
69
|
+
if (!t.length || !e.length)
|
|
70
70
|
return [];
|
|
71
|
-
const
|
|
71
|
+
const n = {
|
|
72
72
|
spend: {
|
|
73
73
|
prop: "spend",
|
|
74
74
|
prefix: s,
|
|
@@ -112,60 +112,83 @@ const $ = (t) => {
|
|
|
112
112
|
mmpInstalls: {},
|
|
113
113
|
mmpCPI: {}
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
e.forEach((a, i) => {
|
|
116
116
|
l[a.property] && (l[a.property].i = i);
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}),
|
|
117
|
+
const u = n[a.property];
|
|
118
|
+
if (u) {
|
|
119
|
+
u.i = i;
|
|
120
|
+
let m = window.$bigNumber(0);
|
|
121
|
+
t.forEach(($) => {
|
|
122
|
+
m = m.plus($[a.property] || 0);
|
|
123
|
+
}), m = m.toNumber(), u.total = m, r.push(m);
|
|
124
124
|
} else
|
|
125
125
|
r.push("");
|
|
126
|
-
}), Object.keys(
|
|
127
|
-
const i =
|
|
126
|
+
}), Object.keys(n).forEach((a) => {
|
|
127
|
+
const i = n[a];
|
|
128
128
|
i.format && r[i.i] && (r[i.i] = i.format(r[i.i]));
|
|
129
129
|
});
|
|
130
|
-
const
|
|
131
|
-
r[l.avgCPT.i] =
|
|
132
|
-
const
|
|
133
|
-
if (r[l.avgCPA.i] =
|
|
134
|
-
const a =
|
|
130
|
+
const f = n.taps.total ? window.$fa(n.spend.total / n.taps.total) : "0.00";
|
|
131
|
+
r[l.avgCPT.i] = f;
|
|
132
|
+
const g = n.installs.total ? window.$fa(n.spend.total / n.installs.total) : "0.00";
|
|
133
|
+
if (r[l.avgCPA.i] = g, l.avgCPM.i !== void 0) {
|
|
134
|
+
const a = n.impressions.total ? window.$fa(n.spend.total / (n.impressions.total / 1e3)) : "0.00";
|
|
135
135
|
r[l.avgCPM.i] = a;
|
|
136
136
|
}
|
|
137
|
-
const
|
|
138
|
-
r[l.cr.i] =
|
|
139
|
-
const
|
|
140
|
-
r[l.ttr.i] =
|
|
141
|
-
const
|
|
142
|
-
return r[l.IPM.i] =
|
|
143
|
-
},
|
|
144
|
-
const
|
|
145
|
-
return Object.keys(
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
}),
|
|
149
|
-
},
|
|
150
|
-
let r = s[
|
|
137
|
+
const h = n.taps.total ? window.$fa(n.installs.total / n.taps.total * 100) : "0.00";
|
|
138
|
+
r[l.cr.i] = h;
|
|
139
|
+
const v = n.impressions.total ? window.$fa(n.taps.total / n.impressions.total * 100) : "0.00";
|
|
140
|
+
r[l.ttr.i] = v;
|
|
141
|
+
const b = n.impressions.total ? window.$fa(n.installs.total * 1e3 / n.impressions.total) : "0.00";
|
|
142
|
+
return r[l.IPM.i] = b, r;
|
|
143
|
+
}, L = (e) => {
|
|
144
|
+
const t = window.$map.asa.allMetric.obj;
|
|
145
|
+
return Object.keys(e).forEach((s) => {
|
|
146
|
+
const o = e[s];
|
|
147
|
+
t[s] && (e[`${s}Format`] = window.$fu({ prop: s, value: o, currency: !1, obj: t }));
|
|
148
|
+
}), e;
|
|
149
|
+
}, O = ({ columns: e, data: t }, s) => e.length && t.length ? e.map((n) => {
|
|
150
|
+
let r = s[n.property] === void 0 ? "" : s[n.property];
|
|
151
151
|
if (r !== "")
|
|
152
152
|
try {
|
|
153
|
-
r = window.$fa(r, window.$map.asa.allMetric.obj[
|
|
153
|
+
r = window.$fa(r, window.$map.asa.allMetric.obj[n.property].precision);
|
|
154
154
|
} catch {
|
|
155
155
|
}
|
|
156
156
|
return r;
|
|
157
|
-
}) : [],
|
|
158
|
-
const s = document.querySelector("html"), { scrollTop:
|
|
157
|
+
}) : [], F = { useSingleSelect: j, useColumn: E, useEmptyColumn: S, useRemoteSummary: O, useSummary: U, useFormat: L }, x = (e, t = 88) => {
|
|
158
|
+
const s = document.querySelector("html"), { scrollTop: o } = s, n = e.getBoundingClientRect();
|
|
159
159
|
s.scrollTo({
|
|
160
|
-
top:
|
|
160
|
+
top: o + n.y - t,
|
|
161
161
|
behavior: "smooth"
|
|
162
162
|
});
|
|
163
|
-
},
|
|
164
|
-
|
|
163
|
+
}, k = { pageScrollTo: x }, c = [];
|
|
164
|
+
let d = 0;
|
|
165
|
+
const p = function(e) {
|
|
166
|
+
c.forEach((t) => {
|
|
167
|
+
if (t.time === void 0 || t.lastTime === 0 || e - t.lastTime >= t.time) {
|
|
168
|
+
t.cb(e), t.lastTime = e;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}), c.length && window.requestAnimationFrame(p);
|
|
172
|
+
}, q = function(e, t = 1e3) {
|
|
173
|
+
return d++, c.push({
|
|
174
|
+
cb: e,
|
|
175
|
+
time: t,
|
|
176
|
+
lastTime: 0,
|
|
177
|
+
id: d
|
|
178
|
+
}), c.length === 1 && window.requestAnimationFrame(p), d;
|
|
179
|
+
}, B = function(e) {
|
|
180
|
+
for (let t = 0; t < c.length; t++)
|
|
181
|
+
if (c[t].id === e) {
|
|
182
|
+
c.splice(t, 1);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}, N = { useRaf: q, clearRaf: B }, V = {
|
|
165
186
|
...R,
|
|
166
|
-
...
|
|
167
|
-
...
|
|
187
|
+
...T,
|
|
188
|
+
...F,
|
|
189
|
+
...k,
|
|
190
|
+
...N
|
|
168
191
|
};
|
|
169
192
|
export {
|
|
170
|
-
|
|
193
|
+
V as default
|
|
171
194
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { d as a } from "./
|
|
4
|
-
import
|
|
5
|
-
import { p } from "./store.js";
|
|
1
|
+
import t from "moment";
|
|
2
|
+
import { d as m } from "./util.js";
|
|
3
|
+
import { d as a } from "./directive.js";
|
|
4
|
+
import n from "./store.js";
|
|
6
5
|
/* empty css */
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
if (
|
|
6
|
+
const w = (o, e) => {
|
|
7
|
+
o.use(m).use(a);
|
|
8
|
+
let s;
|
|
9
|
+
if (e.storeChips)
|
|
11
10
|
try {
|
|
12
|
-
const { store:
|
|
13
|
-
|
|
11
|
+
const { store: _, pinia: i } = n(e.storeChips);
|
|
12
|
+
s = _, o.provide("store", _).use(i);
|
|
14
13
|
} catch {
|
|
15
14
|
throw new Error(
|
|
16
15
|
"piniaStore error, storeChips must be an Object source from import.meta.globa"
|
|
17
16
|
);
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
const r = localStorage.getItem("lang");
|
|
19
|
+
r && r.includes("cn") && t.locale("zh-cn", {
|
|
21
20
|
months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
|
|
22
21
|
"_"
|
|
23
22
|
),
|
|
@@ -27,11 +26,8 @@ const u = (_, r) => {
|
|
|
27
26
|
weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
|
|
28
27
|
weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
|
|
29
28
|
weekdaysMin: "日_一_二_三_四_五_六".split("_")
|
|
30
|
-
}), window.$m =
|
|
31
|
-
composition: m,
|
|
32
|
-
store: e
|
|
33
|
-
};
|
|
29
|
+
}), window.$m = t, window.$moment = t;
|
|
34
30
|
};
|
|
35
31
|
export {
|
|
36
|
-
|
|
32
|
+
w as default
|
|
37
33
|
};
|
package/dist/store.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createPinia as
|
|
2
|
-
const r =
|
|
1
|
+
import { createPinia as o, defineStore as c } from "pinia";
|
|
2
|
+
const r = o(), s = (e) => {
|
|
3
3
|
const t = {};
|
|
4
|
-
return Object.keys(e).forEach((
|
|
5
|
-
const
|
|
6
|
-
t[
|
|
4
|
+
return Object.keys(e).forEach((a) => {
|
|
5
|
+
const n = a.match(/chip\/(\S*).js/)[1];
|
|
6
|
+
t[n] = c(n, e[a].default);
|
|
7
7
|
}), { pinia: r, store: t };
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
|
-
s as
|
|
10
|
+
s as default
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magtool",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"author": "magxl",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -11,18 +11,6 @@
|
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
-
"./cps": {
|
|
15
|
-
"import": "./dist/cps.js",
|
|
16
|
-
"require": "./dist/cps.js"
|
|
17
|
-
},
|
|
18
|
-
"./directive": {
|
|
19
|
-
"import": "./dist/directive.js",
|
|
20
|
-
"require": "./dist/directive.js"
|
|
21
|
-
},
|
|
22
|
-
"./util": {
|
|
23
|
-
"import": "./dist/util.js",
|
|
24
|
-
"require": "./dist/util.js"
|
|
25
|
-
},
|
|
26
14
|
"./store": {
|
|
27
15
|
"import": "./dist/store.js",
|
|
28
16
|
"require": "./dist/store.js"
|