mgacn-commonsdk 1.2.0 → 1.2.1

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.
@@ -1,18 +1,18 @@
1
- import U from "axios";
2
- const M = "__MGACN_COMMONSDK_SYSTEM_ID__", D = "__MGACN_COMMONSDK_USER_ID__";
3
- function F(t) {
4
- globalThis[M] = t == null ? "" : String(t);
5
- }
6
- function S() {
7
- return globalThis[M] || "";
8
- }
1
+ import F from "axios";
2
+ const D = "__MGACN_COMMONSDK_SYSTEM_ID__", P = "__MGACN_COMMONSDK_USER_ID__";
9
3
  function G(t) {
10
4
  globalThis[D] = t == null ? "" : String(t);
11
5
  }
12
- function H() {
6
+ function S() {
13
7
  return globalThis[D] || "";
14
8
  }
15
- function K(t = {}) {
9
+ function H(t) {
10
+ globalThis[P] = t == null ? "" : String(t);
11
+ }
12
+ function K() {
13
+ return globalThis[P] || "";
14
+ }
15
+ function L(t = {}) {
16
16
  const {
17
17
  baseURL: e = "",
18
18
  timeout: n = 6e4,
@@ -21,8 +21,8 @@ function K(t = {}) {
21
21
  userId: s,
22
22
  loginUrl: l = "/login"
23
23
  } = t;
24
- i != null && i !== "" && F(i), s != null && s !== "" && G(s);
25
- const a = U.create({ baseURL: e, timeout: n });
24
+ i != null && i !== "" && G(i), s != null && s !== "" && H(s);
25
+ const a = F.create({ baseURL: e, timeout: n });
26
26
  let f = !1;
27
27
  function c() {
28
28
  typeof localStorage < "u" && localStorage.clear(), !f && (f = !0, setTimeout(() => {
@@ -78,8 +78,8 @@ function A(t) {
78
78
  }
79
79
  return "";
80
80
  }
81
- function dt(t = {}) {
82
- const e = K(t);
81
+ function gt(t = {}) {
82
+ const e = L(t);
83
83
  return {
84
84
  GET(n, r = {}) {
85
85
  return e({ method: "get", url: n, ...r });
@@ -92,17 +92,17 @@ function dt(t = {}) {
92
92
  }
93
93
  };
94
94
  }
95
- const P = "__MGACN_COMMONSDK_REQUEST__";
96
- function gt(t) {
97
- globalThis[P] = t;
95
+ const $ = "__MGACN_COMMONSDK_REQUEST__";
96
+ function pt(t) {
97
+ globalThis[$] = t;
98
98
  }
99
- function L() {
100
- const t = globalThis[P];
99
+ function B() {
100
+ const t = globalThis[$];
101
101
  if (!t)
102
102
  throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
103
103
  return t;
104
104
  }
105
- function $(t, e, n = "application/vnd.ms-excel") {
105
+ function Y(t, e, n = "application/vnd.ms-excel") {
106
106
  if (t == null || typeof window > "u") return;
107
107
  const r = t instanceof Blob ? t : new Blob([t], { type: n }), i = window.URL.createObjectURL(r), s = document.createElement("a");
108
108
  s.href = i, s.download = e || "download", s.style.display = "none", document.body.appendChild(s), s.click(), document.body.removeChild(s), window.URL.revokeObjectURL(i);
@@ -110,10 +110,10 @@ function $(t, e, n = "application/vnd.ms-excel") {
110
110
  function b(t) {
111
111
  return String(t).padStart(2, "0");
112
112
  }
113
- function B(t = /* @__PURE__ */ new Date()) {
113
+ function q(t = /* @__PURE__ */ new Date()) {
114
114
  return `${t.getFullYear()}${b(t.getMonth() + 1)}${b(t.getDate())}${b(t.getHours())}${b(t.getMinutes())}${b(t.getSeconds())}`;
115
115
  }
116
- async function q(t) {
116
+ async function z(t) {
117
117
  if (!(t instanceof Blob) || !t.type || !/json/i.test(t.type)) return;
118
118
  const e = await t.text();
119
119
  let n = "导出失败";
@@ -124,7 +124,7 @@ async function q(t) {
124
124
  }
125
125
  throw new Error(n);
126
126
  }
127
- async function z(t = {}) {
127
+ async function k(t = {}) {
128
128
  const {
129
129
  url: e,
130
130
  data: n,
@@ -135,42 +135,42 @@ async function z(t = {}) {
135
135
  } = t;
136
136
  if (!e) throw new Error("导出地址不能为空");
137
137
  if (!s) throw new Error("导出文件名不能为空");
138
- const a = L(), f = String(i).toUpperCase();
138
+ const a = B(), f = String(i).toUpperCase();
139
139
  let c;
140
- f === "GET" ? c = await a.GET(e, { params: r, responseType: "blob" }) : c = await a.POST(e, n, { responseType: "blob" }), await q(c);
141
- const u = /\.[a-z0-9]+$/i.test(s) ? s : `${s}_${B()}.${l}`;
142
- return $(c, u), u;
140
+ f === "GET" ? c = await a.GET(e, { params: r, responseType: "blob" }) : c = await a.POST(e, n, { responseType: "blob" }), await z(c);
141
+ const u = /\.[a-z0-9]+$/i.test(s) ? s : `${s}_${q()}.${l}`;
142
+ return Y(c, u), u;
143
143
  }
144
144
  let d = null, p = null;
145
- function k(t, e) {
145
+ function Q(t, e) {
146
146
  if (!t || e == null || e === "") return !1;
147
147
  if (typeof e == "object")
148
148
  return e.id != null && e.id !== "" && String(t.id) === String(e.id) || e.platformName != null && e.platformName !== "" && String(t.platformName || "") === String(e.platformName).trim();
149
149
  const n = String(e).trim();
150
150
  return t.id != null && String(t.id) === n || String(t.platformName || "") === n;
151
151
  }
152
- function Y(t) {
152
+ function I(t) {
153
153
  d = Array.isArray(t) ? t : [];
154
154
  }
155
- function Q() {
155
+ function X() {
156
156
  d = null, p = null;
157
157
  }
158
- function X(t) {
158
+ function J(t) {
159
159
  if (!Array.isArray(d) || !d.length) return "";
160
- const e = d.find((n) => k(n, t));
160
+ const e = d.find((n) => Q(n, t));
161
161
  return (e == null ? void 0 : e.platformLogo) || "";
162
162
  }
163
- async function J() {
163
+ async function Z() {
164
164
  return d ?? (p || (p = (async () => {
165
165
  try {
166
- const t = await at().listPlatformInfoAll();
167
- return Y(t), d;
166
+ const t = await lt().listPlatformInfoAll();
167
+ return I(t), d;
168
168
  } finally {
169
169
  p = null;
170
170
  }
171
171
  })(), p));
172
172
  }
173
- function I(t) {
173
+ function O(t) {
174
174
  const e = String(t || "").trim().toUpperCase();
175
175
  if (/^\d{15}$/.test(e)) {
176
176
  const c = +`19${e.slice(6, 8)}`, o = Number(e.slice(8, 10)), u = Number(e.slice(10, 12)), m = new Date(c, o - 1, u);
@@ -184,51 +184,51 @@ function I(t) {
184
184
  for (let c = 0; c < 17; c++) f += Number(e[c]) * l[c];
185
185
  return a[f % 11] === e[17];
186
186
  }
187
- function O(t) {
187
+ function C(t) {
188
188
  const e = String(t || "").trim().replace(/\s+/g, "");
189
189
  return e ? /^1\d{10}$/.test(e) || /^\+[1-9]\d{6,14}$/.test(e) : !1;
190
190
  }
191
- function C(t) {
191
+ function x(t) {
192
192
  const e = String(t || "").trim();
193
193
  return e ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) : !1;
194
194
  }
195
195
  function _(t) {
196
196
  return t == null || t === "";
197
197
  }
198
- function Z(t, e, n) {
198
+ function V(t, e, n) {
199
199
  if (_(e)) {
200
200
  n();
201
201
  return;
202
202
  }
203
- if (!I(e)) {
203
+ if (!O(e)) {
204
204
  n(new Error("请输入正确的身份证号(15/18位)"));
205
205
  return;
206
206
  }
207
207
  n();
208
208
  }
209
- function V(t, e, n) {
209
+ function W(t, e, n) {
210
210
  if (_(e)) {
211
211
  n();
212
212
  return;
213
213
  }
214
- if (!O(e)) {
214
+ if (!C(e)) {
215
215
  n(new Error("请输入正确的国内或海外手机号"));
216
216
  return;
217
217
  }
218
218
  n();
219
219
  }
220
- function W(t, e, n) {
220
+ function v(t, e, n) {
221
221
  if (_(e)) {
222
222
  n();
223
223
  return;
224
224
  }
225
- if (!C(e)) {
225
+ if (!x(e)) {
226
226
  n(new Error("请输入正确的邮箱"));
227
227
  return;
228
228
  }
229
229
  n();
230
230
  }
231
- function v(t) {
231
+ function tt(t) {
232
232
  return !!(t == null || typeof t == "string" && t.trim() === "" || Array.isArray(t) && t.length === 0 || typeof t == "object" && !Array.isArray(t) && Object.keys(t).length === 0);
233
233
  }
234
234
  function T(t) {
@@ -240,7 +240,7 @@ function T(t) {
240
240
  e[n] = T(t[n]);
241
241
  }), e;
242
242
  }
243
- function tt(t, e = 300) {
243
+ function et(t, e = 300) {
244
244
  let n = null;
245
245
  return function(...i) {
246
246
  n && clearTimeout(n), n = setTimeout(() => {
@@ -248,14 +248,14 @@ function tt(t, e = 300) {
248
248
  }, e);
249
249
  };
250
250
  }
251
- function et(t, e = 300) {
251
+ function nt(t, e = 300) {
252
252
  let n = 0;
253
253
  return function(...i) {
254
254
  const s = Date.now();
255
255
  s - n >= e && (n = s, t.apply(this, i));
256
256
  };
257
257
  }
258
- function x(t) {
258
+ function R(t) {
259
259
  if (t == null || t === "") return null;
260
260
  if (t instanceof Date)
261
261
  return Number.isNaN(t.getTime()) ? null : t;
@@ -292,7 +292,7 @@ function x(t) {
292
292
  return Number.isNaN(r.getTime()) ? null : r;
293
293
  }
294
294
  function w(t, e = "YYYY-MM-DD HH:mm:ss") {
295
- const n = x(t);
295
+ const n = R(t);
296
296
  if (!n) return "";
297
297
  const r = n.getFullYear(), i = n.getMonth() + 1, s = n.getDate(), l = n.getHours(), a = n.getMinutes(), f = n.getSeconds(), c = {
298
298
  YYYY: String(r),
@@ -309,7 +309,7 @@ function w(t, e = "YYYY-MM-DD HH:mm:ss") {
309
309
  };
310
310
  return e.replace(/YYYY|MM|DD|HH|mm|ss|M|D|H|m|s/g, (o) => c[o]);
311
311
  }
312
- function nt() {
312
+ function rt() {
313
313
  const t = /* @__PURE__ */ new Date();
314
314
  t.setHours(23, 59, 59, 0);
315
315
  const e = /* @__PURE__ */ new Date();
@@ -325,24 +325,29 @@ function h(t) {
325
325
  r == null || r === "" || Array.isArray(r) && r.length === 0 || (e[n] = r);
326
326
  }), e;
327
327
  }
328
- function rt(t) {
328
+ function it(t) {
329
329
  return t == null || t === "" ? "-" : t;
330
330
  }
331
+ function M(t, e = 2) {
332
+ if (!Number.isFinite(t)) return t;
333
+ const n = Math.max(0, Math.floor(Number(e) || 0));
334
+ return +(Math.round(+`${t}e${n}`) + `e-${n}`);
335
+ }
331
336
  function E(t, e = 2) {
332
337
  if (t == null || t === "") return "-";
333
338
  const n = Number(t);
334
339
  if (Number.isNaN(n)) return t;
335
- const r = n.toFixed(e), [i, s] = r.split("."), l = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
340
+ const r = M(n, e).toFixed(e), [i, s] = r.split("."), l = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
336
341
  if (s == null) return l;
337
342
  const a = s.replace(/0+$/, "");
338
343
  return a ? `${l}.${a}` : l;
339
344
  }
340
- function it(t) {
345
+ function st(t) {
341
346
  if (t == null || t === "") return "-";
342
347
  const e = Number(t);
343
348
  return Number.isNaN(e) ? "-" : Math.abs(e) > 1e4 ? `${E(e / 1e4, 2)}w` : String(E(e, 0));
344
349
  }
345
- function st(t, e = 4, n = "toDecimal") {
350
+ function ot(t, e = 4, n = "toDecimal") {
346
351
  if (n === "toPercent" || n === "toPercentText") {
347
352
  if (t == null || t === "") return n === "toPercentText" ? "-" : t;
348
353
  const i = Number(t);
@@ -356,53 +361,54 @@ function st(t, e = 4, n = "toDecimal") {
356
361
  if (Number.isFinite(r))
357
362
  return Number((r / 100).toFixed(e));
358
363
  }
359
- function ot(t) {
364
+ function ut(t) {
360
365
  if (t === "" || t == null) return "";
361
366
  const e = Number(t);
362
367
  return Number.isFinite(e) ? e : "";
363
368
  }
364
- function ut(t, e = 2, n = 9999999999999) {
369
+ function ct(t, e = 2, n = 9999999999999) {
365
370
  if (t === 0 || t === "0") return 0;
366
371
  if (t == null || t === "") return "";
367
372
  let r = Number(t);
368
373
  if (!Number.isFinite(r)) return "";
369
374
  const i = Number(n), s = Number.isFinite(i) ? Math.abs(i) : 9999999999999;
370
- return Math.abs(r) >= s && (r = r < 0 ? -s : s), Number.isInteger(r) ? r : Number(r.toFixed(e));
375
+ return Math.abs(r) >= s && (r = r < 0 ? -s : s), Number.isInteger(r) ? r : M(r, e);
371
376
  }
372
- function ct(t = "id") {
377
+ function at(t = "id") {
373
378
  return `${t}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
374
379
  }
375
- const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
380
+ const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
376
381
  __proto__: null,
377
- cleanNumber: ut,
382
+ cleanNumber: ct,
378
383
  cleanParams: h,
379
- clearPlatformCache: Q,
380
- debounce: tt,
384
+ clearPlatformCache: X,
385
+ debounce: et,
381
386
  deepClone: T,
382
- downloadBlob: $,
383
- exportFile: z,
384
- findPlatformLogo: X,
387
+ downloadBlob: Y,
388
+ exportFile: k,
389
+ findPlatformLogo: J,
385
390
  formatDate: w,
386
- formatEmpty: rt,
387
- formatFansCount: it,
391
+ formatEmpty: it,
392
+ formatFansCount: st,
388
393
  formatNum: E,
389
- getRecentMonthRange: nt,
390
- isEmail: C,
391
- isEmpty: v,
392
- isMainlandIdCard: I,
393
- isMobile: O,
394
- parseDate: x,
395
- preloadPlatformList: J,
396
- setPlatformCache: Y,
397
- throttle: et,
398
- toNumberOrEmpty: ot,
399
- toRebateRatio: st,
400
- uniqueId: ct,
401
- validateEmail: W,
402
- validateIdCardNo: Z,
403
- validateMobile: V
394
+ getRecentMonthRange: rt,
395
+ isEmail: x,
396
+ isEmpty: tt,
397
+ isMainlandIdCard: O,
398
+ isMobile: C,
399
+ parseDate: R,
400
+ preloadPlatformList: Z,
401
+ roundHalfUp: M,
402
+ setPlatformCache: I,
403
+ throttle: nt,
404
+ toNumberOrEmpty: ut,
405
+ toRebateRatio: ot,
406
+ uniqueId: at,
407
+ validateEmail: v,
408
+ validateIdCardNo: V,
409
+ validateMobile: W
404
410
  }, Symbol.toStringTag, { value: "Module" }));
405
- function yt(t) {
411
+ function bt(t) {
406
412
  if (!t)
407
413
  throw new Error("[mgacn-commonsdk] createApi 需要传入 request 实例");
408
414
  return {
@@ -491,7 +497,7 @@ function yt(t) {
491
497
  "/yhAdmin/trace/addTraceData",
492
498
  h({
493
499
  ...s,
494
- userId: H(),
500
+ userId: K(),
495
501
  projectId: S(),
496
502
  clientType: 1
497
503
  })
@@ -503,61 +509,61 @@ function yt(t) {
503
509
  }
504
510
  };
505
511
  }
506
- const R = "__MGACN_COMMONSDK_API__";
507
- function bt(t) {
508
- globalThis[R] = t;
512
+ const j = "__MGACN_COMMONSDK_API__";
513
+ function ht(t) {
514
+ globalThis[j] = t;
509
515
  }
510
- function at() {
511
- const t = globalThis[R];
516
+ function lt() {
517
+ const t = globalThis[j];
512
518
  if (!t)
513
519
  throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
514
520
  return t;
515
521
  }
516
- const j = "__MGACN_COMMONSDK_PERMISSION_GETTER__";
517
- function ht(t) {
518
- globalThis[j] = typeof t == "function" ? t : null;
522
+ const U = "__MGACN_COMMONSDK_PERMISSION_GETTER__";
523
+ function Nt(t) {
524
+ globalThis[U] = typeof t == "function" ? t : null;
519
525
  }
520
- function lt() {
521
- return globalThis[j] || null;
526
+ function ft() {
527
+ return globalThis[U] || null;
522
528
  }
523
- function ft(t, e, n = "and") {
529
+ function mt(t, e, n = "and") {
524
530
  const r = (Array.isArray(e) ? e : [e]).map((s) => String(s ?? "").trim()).filter(Boolean);
525
531
  if (!r.length) return !0;
526
532
  const i = new Set((t || []).map(String));
527
533
  return n === "or" ? r.some((s) => i.has(s)) : r.every((s) => i.has(s));
528
534
  }
529
- function Nt(t, e = "and") {
530
- const n = lt();
531
- return typeof n != "function" ? !0 : ft(n(), t, e);
535
+ function St(t, e = "and") {
536
+ const n = ft();
537
+ return typeof n != "function" ? !0 : mt(n(), t, e);
532
538
  }
533
- const St = (t, e) => {
539
+ const Tt = (t, e) => {
534
540
  const n = t.__vccOpts || t;
535
541
  for (const [r, i] of e)
536
542
  n[r] = i;
537
543
  return n;
538
544
  };
539
545
  export {
540
- St as _,
541
- F as a,
542
- L as b,
543
- ft as c,
546
+ Tt as _,
547
+ G as a,
548
+ B as b,
549
+ mt as c,
544
550
  T as d,
545
551
  h as e,
546
- tt as f,
547
- at as g,
552
+ et as f,
553
+ lt as g,
548
554
  E as h,
549
- rt as i,
550
- Nt as j,
551
- ht as k,
552
- dt as l,
553
- yt as m,
554
- gt as n,
555
- bt as o,
556
- K as p,
557
- lt as q,
555
+ it as i,
556
+ St as j,
557
+ Nt as k,
558
+ gt as l,
559
+ bt as m,
560
+ pt as n,
561
+ ht as o,
562
+ L as p,
563
+ ft as q,
558
564
  S as r,
559
- G as s,
560
- st as t,
561
- H as u,
562
- pt as v
565
+ H as s,
566
+ ot as t,
567
+ K as u,
568
+ yt as v
563
569
  };
@@ -3,7 +3,7 @@ import { defineStore as aA, createPinia as bg } from "pinia";
3
3
  import xg, { ElMessageBox as Zg, ElMessage as gg } from "element-plus";
4
4
  import mg from "element-plus/es/locale/lang/zh-cn";
5
5
  import zg from "mgacn-commonsdk";
6
- import { s as vA, g as KA, a as TA, b as _, c as hg, _ as IA, d as jA, e as xA, f as ig } from "./_plugin-vue_export-helper-Bp7fC9dg.js";
6
+ import { s as vA, g as KA, a as TA, b as _, c as hg, _ as IA, d as jA, e as xA, f as ig } from "./_plugin-vue_export-helper-C5bbN0Gq.js";
7
7
  import { useRoute as FA, useRouter as rA, createRouter as jg, createWebHashHistory as yg } from "vue-router";
8
8
  const cA = {
9
9
  /** 部署目录名,如 account_cms;DEV 无 path 前缀时用于匹配当前系统 */
@@ -2,8 +2,8 @@ import { Plus as ot, Delete as it, CircleCloseFilled as ut, Document as ct, Clos
2
2
  import { ElMessage as E, ElMessageBox as Oe } from "element-plus";
3
3
  import mt from "cropperjs";
4
4
  import * as $e from "ali-oss";
5
- import { g as gt, _ as G, h as Ie, t as yt, i as vt, j as Ae, k as bt, l as _t, m as wt, n as Ct, o as kt } from "./_plugin-vue_export-helper-Bp7fC9dg.js";
6
- import { c as ol, p as il, q as ul, b as cl, r as dl, u as pl, a as fl, s as hl, v as ml } from "./_plugin-vue_export-helper-Bp7fC9dg.js";
5
+ import { g as gt, _ as G, h as Ie, t as yt, i as vt, j as Ae, k as bt, l as _t, m as wt, n as Ct, o as kt } from "./_plugin-vue_export-helper-C5bbN0Gq.js";
6
+ import { c as ol, p as il, q as ul, b as cl, r as dl, u as pl, a as fl, s as hl, v as ml } from "./_plugin-vue_export-helper-C5bbN0Gq.js";
7
7
  import { resolveComponent as F, openBlock as u, createElementBlock as b, createElementVNode as w, toDisplayString as T, createCommentVNode as D, createTextVNode as K, Fragment as W, renderList as q, normalizeStyle as re, normalizeClass as z, createVNode as U, withCtx as S, withModifiers as de, withDirectives as ee, vShow as te, createBlock as P, computed as ye, ref as A, watch as se, onMounted as ve, reactive as Ne, nextTick as Z, onBeforeUnmount as ze, withKeys as Le, unref as ne, renderSlot as ae, mergeProps as Me, createSlots as Ut } from "vue";
8
8
  const xt = $e.default ?? $e, He = "__MGACN_COMMONSDK_OSS_URL__";
9
9
  function St(e = "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mgacn-commonsdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "芒果ACN公共组件库:公共组件、工具方法、网络请求与子系统壳层",
5
5
  "type": "module",
6
6
  "main": "./dist/mgacn-commonsdk.js",