magtool 1.0.7 → 1.0.8

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 CHANGED
@@ -1,171 +1,86 @@
1
- const $ = (t) => {
2
- const { age: o } = t || {};
3
- let s, n;
4
- if (o != null && o.included) {
5
- const { minAge: e, maxAge: r } = o.included[0] || {};
6
- e ? s = e : s = "all", r ? n = r : n = "all";
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 n === "all" ? s === "all" ? "All" : `${s}~65+` : `${s}~${n}`;
9
- }, b = (t, o) => t === "all" ? null : o === 65 ? {
10
- included: [
11
- {
12
- minAge: t
13
- }
14
- ]
15
- } : {
16
- included: [
17
- {
18
- minAge: t,
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
- }), M = ({ type: t = "csv", data: o, name: s }) => {
34
- let n = document.createElement("a");
20
+ }), download: ({ type: t = "csv", data: a, name: n }) => {
21
+ let o = document.createElement("a");
35
22
  if (t === "csv") {
36
- const r = new Blob(["\uFEFF" + o], {
37
- type: "text/csv,charset=UTF-8"
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
- n.download = s || "download", n.dispatchEvent(e), (t === "csv" || t === "video") && URL.revokeObjectURL(n.url), n = null, e = null;
43
- }, R = { loadImage: P, loadVideo: C, download: M }, A = ({ table: t, key: o, form: s, value: n, cb: e = () => {
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 r = t.getSelectionRows();
46
- r.length > 1 ? (t.clearSelection(), t.toggleRowSelection(r[1], "selected"), s[n] = r[1][o]) : r.length === 1 && (s[n] = r[0][o]), e();
47
- }, I = (t = {}) => {
48
- let { sortable: o = !0, empty: s = !1, mmp: n = !1 } = t, e = window.$map.asa.asaMetric.all;
49
- n && (e = e.concat(window.$map.asa.mmpMetric.all));
50
- const r = e.map((l, u) => ({
51
- label: l.label,
52
- prop: l.value,
53
- width: l.width,
54
- sortable: o,
55
- type: l.type,
56
- align: l.align,
57
- visible: l.visible,
58
- formatter: l.formatter
59
- }));
60
- return r.unshift({
61
- label: "Currency",
62
- prop: "currency",
63
- width: 80,
64
- align: "right"
65
- }), r;
66
- }, j = () => ({
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
- o.forEach((v) => {
122
- c = c.plus(v[a.property] || 0);
123
- }), c = c.toNumber(), m.total = c, r.push(c);
124
- } else
125
- r.push("");
126
- }), Object.keys(e).forEach((a) => {
127
- const i = e[a];
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 p = e.taps.total ? window.$fa(e.spend.total / e.taps.total) : "0.00";
131
- r[l.avgCPT.i] = p;
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 (r[l.avgCPA.i] = d, l.avgCPM.i !== void 0) {
134
- const a = e.impressions.total ? window.$fa(e.spend.total / (e.impressions.total / 1e3)) : "0.00";
135
- r[l.avgCPM.i] = a;
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 f = e.taps.total ? window.$fa(e.installs.total / e.taps.total * 100) : "0.00";
138
- r[l.cr.i] = f;
139
- const w = e.impressions.total ? window.$fa(e.taps.total / e.impressions.total * 100) : "0.00";
140
- r[l.ttr.i] = w;
141
- const g = e.impressions.total ? window.$fa(e.installs.total * 1e3 / e.impressions.total) : "0.00";
142
- return r[l.IPM.i] = g, r;
143
- }, U = (t) => {
144
- const o = window.$map.asa.allMetric.obj;
145
- return Object.keys(t).forEach((s) => {
146
- const n = t[s];
147
- o[s] && (t[`${s}Format`] = window.$fu({ prop: s, value: n, currency: !1, obj: o }));
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
- }, E = ({ columns: t, data: o }, s) => t.length && o.length ? t.map((e) => {
150
- let r = s[e.property] === void 0 ? "" : s[e.property];
151
- if (r !== "")
152
- try {
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
- x as c
85
+ v as c
171
86
  };
package/dist/directive.js CHANGED
@@ -1,29 +1,22 @@
1
- const m = (o) => {
2
- o.directive("copy", {
3
- mounted(t, i) {
4
- let { value: l, arg: e } = i;
5
- t.onclick = () => {
6
- window.$copy(l, e);
7
- };
8
- }
9
- }), o.directive("focus", {
10
- mounted(t, i, l) {
11
- let { value: e = 0, arg: d = "time" } = i;
12
- if (e === null)
13
- return;
14
- let c = 100, r = 0;
15
- d !== "time" ? r = e : c = Number(e);
16
- const n = setTimeout(() => {
17
- let u = t.querySelectorAll("input, textarea");
18
- u[r].focus(), u[r].select(), clearTimeout(n);
19
- }, c);
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
@@ -2,17 +2,8 @@ import _ from "moment";
2
2
  import { c as t } from "./cps.js";
3
3
  import { d as s } from "./util.js";
4
4
  import { d as e } from "./directive.js";
5
- import { s as i } from "./store.js";
6
- const c = (o, m) => (o.use(s).use(e), localStorage.getItem("lang").includes("cn") && _.locale("zh-cn", {
7
- months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
8
- monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
9
- weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
10
- weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
11
- weekdaysMin: "日_一_二_三_四_五_六".split("_")
12
- }), window.$m = _, window.$moment = _, {
13
- composition: t,
14
- store: i
15
- });
5
+ import { s as m } from "./store.js";
6
+ const d = (o, i) => (o.use(s).use(e), localStorage.getItem("lang").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: t, store: m });
16
7
  export {
17
- c as default
8
+ d as default
18
9
  };
package/dist/store.js CHANGED
@@ -1,11 +1,11 @@
1
- import { createPinia as n, defineStore as r } from "pinia";
2
- const a = n(), i = (e) => {
3
- const t = {};
4
- return Object.keys(e).forEach((o) => {
5
- const c = o.match(/chip\/(\S*).js/)[1];
6
- t[c] = r(c, e[o].default);
7
- }), { pinia: a, store: t };
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
- i as s
10
+ n as s
11
11
  };
package/dist/util.js CHANGED
@@ -1,295 +1,168 @@
1
- const M = (i) => {
1
+ const j = (c) => {
2
2
  window.$getLang = () => localStorage.getItem("lang");
3
3
  const u = (e = {}) => {
4
- const { alpha: n, name: o } = e, t = [
5
- "blue",
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, i.config.globalProperties.$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 += n, o;
21
- };
22
- window.$rn = U, window.$elc = (e = {}) => {
23
- let { i: n = 0, color: o } = e;
24
- const t = window.global.config.color;
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: n = 0, color: o } = e;
46
- const t = window.global.config.color;
47
- o = o || t[n];
48
- const r = o + "FF";
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 t = 0; t < e; t++)
69
- o.push(n(t));
20
+ for (let n = 0; n < e; n++) o.push(t(n));
70
21
  return o;
71
- };
72
- window.$fd = C, i.config.globalProperties.$setTimeout = function(e = () => {
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
- }, n);
26
+ }, t);
77
27
  };
78
- const p = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
79
- i.config.globalProperties.$toUpperCamel = p, window.$toUpperCamel = p;
80
- const g = (e, n = 2) => {
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 t;
83
- o === "Number" ? (e = e.toFixed(n), t = String(e), e = String(Math.abs(e))) : o === "String" && (t = e, e = String(Math.abs(Number(e))));
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 c = r[0].split("");
86
- c = c.reverse();
87
- let l = [];
88
- c.forEach((d, T) => {
89
- T !== 0 && T % 3 === 0 && l.push(","), l.push(d);
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 a = l.reverse().join("");
92
- return window.$getType(n) === "Number" && n > 0 && (a += ".", r[1] ? a += r[1].padEnd(n, 0).substr(0, n) : a += "0".padEnd(n, "0")), Number(t) !== Number(e) ? `-${a}` : a;
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 = g, i.config.globalProperties.$fa = g;
95
- const m = ({
96
- prop: e,
97
- currency: n,
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 = m, i.config.globalProperties.$fu2 = m;
49
+ window.$fu2 = $, c.config.globalProperties.$fu2 = $;
105
50
  const b = (e = () => {
106
- }, n = 2) => {
51
+ }, t = 2) => {
107
52
  let o = null;
108
- return new Promise((t, r) => {
53
+ return new Promise((n, r) => {
109
54
  o = setTimeout(() => {
110
- e(t, r), clearTimeout(o), t(!0);
111
- }, n * 100);
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 $ = (e = () => {
116
- }, n = 500) => {
60
+ const h = (e = () => {
61
+ }, t = 500) => {
117
62
  let o;
118
- return function(...t) {
63
+ return function(...n) {
119
64
  o && clearTimeout(o), o = setTimeout(() => {
120
- e.apply(this, t);
121
- }, n);
65
+ e.apply(this, n);
66
+ }, t);
122
67
  };
123
68
  };
124
- window.$db = $, window.$debounce = $, Number.prototype.toFixedNumber = function(e) {
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
- throw new Error(e + " is not a function");
129
- let n, o;
130
- for (let t = 0; t < this.length; t++)
131
- if (e(this[t], t, this)) {
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 t;
147
- if (n ? window.$getType(n) !== "Boolean" ? t = `${o} ${n}: ${e}` : t = `${o}: ${e}` : t = o, navigator.clipboard && window.isSecureContext)
148
- navigator.clipboard.writeText(e).then(() => {
149
- i.config.globalProperties.$message.success({
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(), i.config.globalProperties.$message.success({
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 = h, i.config.globalProperties.$copy = h;
167
- const L = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
168
- window.$sc = L;
169
- const O = {
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
- window.$nro = E;
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]) && n++;
185
- }), n;
186
- };
187
- window.$pc = P;
188
- const y = {
189
- info: {
190
- tag: "background-color:#0085FF; color:#f1f7ff;",
191
- style: "background-color:#f1f7ff; color:#0085FF;"
192
- },
193
- log: {
194
- tag: "background-color:#FFFFFF; color:#272b41;",
195
- style: "background-color:#272b41; color:#FFFFFF;"
196
- },
197
- error: {
198
- tag: "background-color:#ff4d4f; color:#fff3f3;",
199
- style: "background-color:#fff3f3; color:#ff4d4f;"
200
- },
201
- warn: {
202
- tag: "background-color:#fa8b0c; color:#fffbf6;",
203
- style: "background-color:#fffbf6; color:#fa8b0c;"
204
- },
205
- success: {
206
- tag: "background-color:#20c997; color:#f6fffc;",
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
- window.$loadVideo = S;
245
- const k = (e) => {
127
+ const v = (e) => {
246
128
  if (e && window.$getType(e) === "Object") {
247
- const o = {};
248
- return Object.keys(e).forEach((t) => {
249
- const r = e[t];
250
- switch (window.$getType(r)) {
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(r) !== 0 && (o[t] = r);
134
+ Object.keys(n) !== 0 && (t[o] = n);
253
135
  break;
254
136
  case "Array":
255
- r.length !== 0 && (o[t] = r);
137
+ n.length !== 0 && (t[o] = n);
256
138
  break;
257
139
  case "String":
258
- r && (o[t] = r.toLowerCase());
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(r) === -1 && (o[t] = r);
265
- break;
143
+ [void 0, null, ""].indexOf(n) === -1 && (t[o] = n);
266
144
  }
267
- }), o;
145
+ }), t;
268
146
  }
269
147
  };
270
- window.$removeEmptyParams = k, window.$rep = k;
271
- let s = null, w = null;
272
- const x = async (e) => {
273
- let { type: n = "img", url: o, name: t, data: r } = e;
274
- if (s = document.createElement("a"), n === "csv") {
275
- const c = new Blob(["\uFEFF" + r], {
276
- type: "text/csv,charset=UTF-8"
277
- });
278
- s.href = URL.createObjectURL(c);
279
- } else if (n === "video" || n === "excel") {
280
- const { access_token: c, scope: l, token_type: F } = store.launch().login.info, a = {};
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 (n = "table") ? await fetch(o).then((c) => c.blob()).then((c) => {
287
- s.href = URL.createObjectURL(c);
288
- }) : s.href = o;
289
- w = new MouseEvent("click"), s.download = t || "download", s.dispatchEvent(w), (n === "csv" || n === "video") && URL.revokeObjectURL(s.url), s = null, w = null;
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
- M as d
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.7",
4
+ "version": "1.0.8",
5
5
  "author": "magxl",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -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": "",