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