magtool 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +14 -13
  2. package/dist/util.js +53 -53
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,22 +1,23 @@
1
- import t from "moment";
2
- import { d as m } from "./util.js";
1
+ import o from "moment";
2
+ import m from "markdown-it";
3
+ import { d as n } from "./util.js";
3
4
  import { d as a } from "./directive.js";
4
- import n from "./store.js";
5
+ import p from "./store.js";
5
6
  /* empty css */
6
- const w = (o, e) => {
7
- o.use(m).use(a);
8
- let s;
9
- if (e.storeChips)
7
+ const u = (t, r) => {
8
+ t.use(n).use(a);
9
+ let i;
10
+ if (r.storeChips)
10
11
  try {
11
- const { store: _, pinia: i } = n(e.storeChips);
12
- s = _, o.provide("store", _).use(i);
12
+ const { store: _, pinia: s } = p(r.storeChips);
13
+ i = _, t.provide("store", _).use(s);
13
14
  } catch {
14
15
  throw new Error(
15
16
  "piniaStore error, storeChips must be an Object source from import.meta.globa"
16
17
  );
17
18
  }
18
- const r = localStorage.getItem("lang");
19
- r && r.includes("cn") && t.locale("zh-cn", {
19
+ const e = localStorage.getItem("lang");
20
+ e && e.includes("cn") && o.locale("zh-cn", {
20
21
  months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
21
22
  "_"
22
23
  ),
@@ -26,8 +27,8 @@ const w = (o, e) => {
26
27
  weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
27
28
  weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
28
29
  weekdaysMin: "日_一_二_三_四_五_六".split("_")
29
- }), window.$m = t, window.$moment = t;
30
+ }), window.$m = o, window.$moment = o, window.$md = m;
30
31
  };
31
32
  export {
32
- w as default
33
+ u as default
33
34
  };
package/dist/util.js CHANGED
@@ -1,6 +1,6 @@
1
- const N = (i) => {
2
- window.$getLang = () => localStorage.getItem("lang");
3
- const d = (e = {}) => {
1
+ const A = (a) => {
2
+ window.$getLang = () => localStorage.getItem("lang"), window.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt", window.$md5 = (e) => e.match(/\d+(\.\d+)?/g).join("");
3
+ const f = (e = {}) => {
4
4
  const { alpha: r, name: o } = e, t = [
5
5
  "blue",
6
6
  "red",
@@ -14,12 +14,12 @@ const N = (i) => {
14
14
  ], n = ["", 1, 3, 5, 7], c = o || t[parseInt(Math.random() * t.length)], s = r === 0 ? "" : n[parseInt(Math.random() * n.length)];
15
15
  return `${c}${s}`;
16
16
  };
17
- window.$randomColor = d, window.$rc = d, i.config.globalProperties.$rc = d;
18
- const F = (e, r = 0) => {
17
+ window.$randomColor = f, window.$rc = f, a.config.globalProperties.$rc = f;
18
+ const k = (e, r = 0) => {
19
19
  let o = parseInt(Math.random() * e);
20
20
  return o += r, o;
21
21
  };
22
- window.$rn = F, window.$elc = (e = {}) => {
22
+ window.$rn = k, window.$elc = (e = {}) => {
23
23
  let { i: r = 0, color: o } = e;
24
24
  const t = window.global.config.color;
25
25
  o = o || t[r];
@@ -63,20 +63,20 @@ const N = (i) => {
63
63
  ]
64
64
  };
65
65
  };
66
- const U = (e, r) => {
66
+ const F = (e, r) => {
67
67
  let o = [];
68
68
  for (let t = 0; t < e; t++)
69
69
  o.push(r(t));
70
70
  return o;
71
71
  };
72
- window.$fd = U, i.config.globalProperties.$setTimeout = function(e = () => {
72
+ window.$fd = F, a.config.globalProperties.$setTimeout = function(e = () => {
73
73
  }, r) {
74
74
  this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
75
75
  e(), clearTimeout(this.timer);
76
76
  }, r);
77
77
  };
78
- const w = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
79
- i.config.globalProperties.$toUpperCamel = w, window.$toUpperCamel = w;
78
+ const u = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
79
+ a.config.globalProperties.$toUpperCamel = u, window.$toUpperCamel = u;
80
80
  const p = (e, r = 2) => {
81
81
  const o = window.$getType(e);
82
82
  let t;
@@ -85,13 +85,13 @@ const N = (i) => {
85
85
  let c = n[0].split("");
86
86
  c = c.reverse();
87
87
  let s = [];
88
- c.forEach((S, k) => {
89
- k !== 0 && k % 3 === 0 && s.push(","), s.push(S);
88
+ c.forEach((P, U) => {
89
+ U !== 0 && U % 3 === 0 && s.push(","), s.push(P);
90
90
  });
91
- let f = s.reverse().join("");
92
- return window.$getType(r) === "Number" && r > 0 && (f += ".", n[1] ? f += n[1].padEnd(r, 0).substr(0, r) : f += "0".padEnd(r, "0")), Number(t) !== Number(e) ? `-${f}` : f;
91
+ let d = s.reverse().join("");
92
+ return window.$getType(r) === "Number" && r > 0 && (d += ".", n[1] ? d += n[1].padEnd(r, 0).substr(0, r) : d += "0".padEnd(r, "0")), Number(t) !== Number(e) ? `-${d}` : d;
93
93
  };
94
- window.$fa = p, i.config.globalProperties.$fa = p;
94
+ window.$fa = p, a.config.globalProperties.$fa = p;
95
95
  const m = ({
96
96
  prop: e,
97
97
  currency: r,
@@ -101,7 +101,7 @@ const N = (i) => {
101
101
  const n = t[e];
102
102
  return n.unit === "currency" ? r ? `${r} ${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);
103
103
  };
104
- window.$fu2 = m, i.config.globalProperties.$fu2 = m;
104
+ window.$fu2 = m, a.config.globalProperties.$fu2 = m;
105
105
  const g = (e = () => {
106
106
  }, r = 2) => {
107
107
  let o = null;
@@ -146,7 +146,7 @@ const N = (i) => {
146
146
  let t;
147
147
  if (r ? window.$getType(r) !== "Boolean" ? t = `${o} ${r}: ${e}` : t = `${o}: ${e}` : t = o, navigator.clipboard && window.isSecureContext)
148
148
  navigator.clipboard.writeText(e).then(() => {
149
- i.config.globalProperties.$message.success({
149
+ a.config.globalProperties.$message.success({
150
150
  message: t,
151
151
  // grouping: true,
152
152
  center: !0,
@@ -155,7 +155,7 @@ const N = (i) => {
155
155
  });
156
156
  else {
157
157
  let n = document.createElement("textarea");
158
- 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({
158
+ n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), a.config.globalProperties.$message.success({
159
159
  message: t,
160
160
  // grouping: true,
161
161
  center: !0,
@@ -163,29 +163,29 @@ const N = (i) => {
163
163
  });
164
164
  }
165
165
  };
166
- window.$copy = $, i.config.globalProperties.$copy = $;
167
- const C = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
168
- window.$sc = C;
169
- const T = {
166
+ window.$copy = $, a.config.globalProperties.$copy = $;
167
+ const O = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
168
+ window.$sc = O;
169
+ const C = {
170
170
  cpa: "avgCPA",
171
171
  cpt: "avgCPT"
172
- }, L = (e, r = T) => {
172
+ }, M = (e, r = C) => {
173
173
  const o = r[e.name];
174
174
  o && (e.name = o);
175
175
  };
176
- window.$nr = L;
177
- const O = (e, r) => (Object.keys(e).forEach((o) => {
176
+ window.$nr = M;
177
+ const S = (e, r) => (Object.keys(e).forEach((o) => {
178
178
  objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
179
179
  }), e);
180
- window.$nro = O;
181
- const j = (e) => {
180
+ window.$nro = S;
181
+ const T = (e) => {
182
182
  let r = 0;
183
183
  return Object.keys(e).forEach((o) => {
184
184
  (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && r++;
185
185
  }), r;
186
186
  };
187
- window.$pc = j;
188
- const y = {
187
+ window.$pc = T;
188
+ const h = {
189
189
  info: {
190
190
  tag: "background-color:#0085FF; color:#f1f7ff;",
191
191
  style: "background-color:#f1f7ff; color:#0085FF;"
@@ -206,43 +206,43 @@ const N = (i) => {
206
206
  tag: "background-color:#20c997; color:#f6fffc;",
207
207
  style: "background-color:#f6fffc; color:#20c997;"
208
208
  }
209
- }, l = (e = "info", r) => {
209
+ }, i = (e = "info", r) => {
210
210
  console.info(
211
211
  `%c ${e.toUpperCase()} %c┆${r}┆`,
212
- `${y[e].tag}`,
213
- `${y[e].style}`
212
+ `${h[e].tag}`,
213
+ `${h[e].style}`
214
214
  );
215
215
  };
216
216
  window.$c = {
217
217
  info: (...e) => {
218
- l("info", e);
218
+ i("info", e);
219
219
  },
220
220
  log: (...e) => {
221
- l("log", e);
221
+ i("log", e);
222
222
  },
223
223
  error: (...e) => {
224
- l("error", e);
224
+ i("error", e);
225
225
  },
226
226
  warn: (...e) => {
227
- l("warn", e);
227
+ i("warn", e);
228
228
  },
229
229
  success: (...e) => {
230
- l("success", e);
230
+ i("success", e);
231
231
  }
232
232
  };
233
- const P = (e) => new Promise((r, o) => {
233
+ const E = (e) => new Promise((r, o) => {
234
234
  const t = new Image();
235
235
  t.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), t.onload = () => r(t), t.onerror = () => o(new Error("Could not load image"));
236
236
  });
237
- window.$loadImage = P;
238
- const R = (e) => new Promise((r, o) => {
237
+ window.$loadImage = E;
238
+ const j = (e) => new Promise((r, o) => {
239
239
  const t = document.createElement("video");
240
240
  t.preload = "metadata", window.$getType(e) === "String" ? t.src = e : t.src = URL.createObjectURL(e), t.onloadedmetadata = () => {
241
241
  window.URL.revokeObjectURL(e), console.info([t]), r(t);
242
242
  };
243
243
  });
244
- window.$loadVideo = R;
245
- const h = (e) => {
244
+ window.$loadVideo = j;
245
+ const y = (e) => {
246
246
  if (e && window.$getType(e) === "Object") {
247
247
  const o = {};
248
248
  return Object.keys(e).forEach((t) => {
@@ -267,24 +267,24 @@ const N = (i) => {
267
267
  }), o;
268
268
  }
269
269
  };
270
- window.$removeEmptyParams = h, window.$rep = h;
271
- let a = null, u = null;
272
- const E = async (e) => {
270
+ window.$removeEmptyParams = y, window.$rep = y;
271
+ let l = null, w = null;
272
+ const L = async (e) => {
273
273
  let { type: r = "img", url: o, name: t, data: n } = e;
274
- if (a = document.createElement("a"), r === "csv") {
274
+ if (l = document.createElement("a"), r === "csv") {
275
275
  const c = new Blob(["\uFEFF" + n], {
276
276
  type: "text/csv,charset=UTF-8"
277
277
  });
278
- a.href = URL.createObjectURL(c);
278
+ l.href = URL.createObjectURL(c);
279
279
  } else r === "video" || r === "excel" ? await fetch(o, e).then((c) => c.blob()).then((c) => {
280
- a.href = URL.createObjectURL(c);
280
+ l.href = URL.createObjectURL(c);
281
281
  }) : (r = "table") ? await fetch(o).then((c) => c.blob()).then((c) => {
282
- a.href = URL.createObjectURL(c);
283
- }) : a.href = o;
284
- u = new MouseEvent("click"), a.download = t || "download", a.dispatchEvent(u), (r === "csv" || r === "video") && URL.revokeObjectURL(a.url), a = null, u = null;
282
+ l.href = URL.createObjectURL(c);
283
+ }) : l.href = o;
284
+ w = new MouseEvent("click"), l.download = t || "download", l.dispatchEvent(w), (r === "csv" || r === "video") && URL.revokeObjectURL(l.url), l = null, w = null;
285
285
  };
286
- window.$download = E;
286
+ window.$download = L;
287
287
  };
288
288
  export {
289
- N as d
289
+ A as d
290
290
  };
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.3",
4
+ "version": "1.2.4",
5
5
  "author": "magxl",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -30,6 +30,7 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "magtool": "^1.1.2",
33
+ "markdown-it": "^14.1.0",
33
34
  "moment": "^2.30.1",
34
35
  "pinia": "^3.0.0",
35
36
  "vue": "^3.3.4"