qidian-shared 1.0.73 → 1.0.75
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/_virtual/dayjs.min.mjs +7 -0
- package/dist/_virtual/dayjs.min2.mjs +4 -0
- package/dist/index.mjs +2 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.mjs +286 -0
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.mjs +19 -2
- package/dist/utils/date.d.ts +2 -0
- package/dist/utils/date.mjs +11 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getDefaultExportFromCjs } from "./_commonjsHelpers.mjs";
|
|
2
|
+
import { __require as requireDayjs_min } from "../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.mjs";
|
|
3
|
+
var dayjs_minExports = requireDayjs_min();
|
|
4
|
+
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
|
5
|
+
export {
|
|
6
|
+
dayjs as default
|
|
7
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { padZero, toMoney, toMoneyTrimmed, toMoneyWithK, toPrecision } from "./u
|
|
|
12
12
|
import { checkSameObject, createEnum, createExposeProxy, easyCopy, extractSlotsWithPrefix, extractSlotsWithoutPrefix, filterSlots, findEnum, hasOwn, isEmpty, noop, valueFillter } from "./utils/common.mjs";
|
|
13
13
|
import { buildTree, remapKeys, toArr } from "./utils/conversion.mjs";
|
|
14
14
|
import { MD5, decryptBase64, encryptBase64, encryptWithAes, generateAesKey, generateRandomString } from "./utils/crypto.mjs";
|
|
15
|
+
import { formatDate } from "./utils/date.mjs";
|
|
15
16
|
import { domOff, domOn, getHtmlTxt, getScrollEl } from "./utils/dom.mjs";
|
|
16
17
|
import { easyDownload } from "./utils/download.mjs";
|
|
17
18
|
import { b2gb, b2kb, b2mb, cutFileSuffix, cutFilename, formatByte, isTypeByName } from "./utils/file.mjs";
|
|
@@ -54,6 +55,7 @@ export {
|
|
|
54
55
|
filterSlots,
|
|
55
56
|
findEnum,
|
|
56
57
|
formatByte,
|
|
58
|
+
formatDate,
|
|
57
59
|
formatGlob,
|
|
58
60
|
generateAesKey,
|
|
59
61
|
generateRandomString,
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { __module as dayjs_min$1 } from "../../../../../_virtual/dayjs.min2.mjs";
|
|
2
|
+
var dayjs_min = dayjs_min$1.exports;
|
|
3
|
+
var hasRequiredDayjs_min;
|
|
4
|
+
function requireDayjs_min() {
|
|
5
|
+
if (hasRequiredDayjs_min) return dayjs_min$1.exports;
|
|
6
|
+
hasRequiredDayjs_min = 1;
|
|
7
|
+
(function(module, exports) {
|
|
8
|
+
!(function(t, e) {
|
|
9
|
+
module.exports = e();
|
|
10
|
+
})(dayjs_min, (function() {
|
|
11
|
+
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
|
|
12
|
+
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
|
|
13
|
+
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
14
|
+
} }, m = function(t2, e2, n2) {
|
|
15
|
+
var r2 = String(t2);
|
|
16
|
+
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
17
|
+
}, v = { s: m, z: function(t2) {
|
|
18
|
+
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
19
|
+
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
20
|
+
}, m: function t2(e2, n2) {
|
|
21
|
+
if (e2.date() < n2.date()) return -t2(n2, e2);
|
|
22
|
+
var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
|
|
23
|
+
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
24
|
+
}, a: function(t2) {
|
|
25
|
+
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
26
|
+
}, p: function(t2) {
|
|
27
|
+
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
28
|
+
}, u: function(t2) {
|
|
29
|
+
return void 0 === t2;
|
|
30
|
+
} }, g = "en", D = {};
|
|
31
|
+
D[g] = M;
|
|
32
|
+
var p = "$isDayjsObject", S = function(t2) {
|
|
33
|
+
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
34
|
+
}, w = function t2(e2, n2, r2) {
|
|
35
|
+
var i2;
|
|
36
|
+
if (!e2) return g;
|
|
37
|
+
if ("string" == typeof e2) {
|
|
38
|
+
var s2 = e2.toLowerCase();
|
|
39
|
+
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
40
|
+
var u2 = e2.split("-");
|
|
41
|
+
if (!i2 && u2.length > 1) return t2(u2[0]);
|
|
42
|
+
} else {
|
|
43
|
+
var a2 = e2.name;
|
|
44
|
+
D[a2] = e2, i2 = a2;
|
|
45
|
+
}
|
|
46
|
+
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
47
|
+
}, O = function(t2, e2) {
|
|
48
|
+
if (S(t2)) return t2.clone();
|
|
49
|
+
var n2 = "object" == typeof e2 ? e2 : {};
|
|
50
|
+
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
51
|
+
}, b = v;
|
|
52
|
+
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
53
|
+
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
54
|
+
};
|
|
55
|
+
var _ = (function() {
|
|
56
|
+
function M2(t2) {
|
|
57
|
+
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
58
|
+
}
|
|
59
|
+
var m2 = M2.prototype;
|
|
60
|
+
return m2.parse = function(t2) {
|
|
61
|
+
this.$d = (function(t3) {
|
|
62
|
+
var e2 = t3.date, n2 = t3.utc;
|
|
63
|
+
if (null === e2) return /* @__PURE__ */ new Date(NaN);
|
|
64
|
+
if (b.u(e2)) return /* @__PURE__ */ new Date();
|
|
65
|
+
if (e2 instanceof Date) return new Date(e2);
|
|
66
|
+
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
67
|
+
var r2 = e2.match($);
|
|
68
|
+
if (r2) {
|
|
69
|
+
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
70
|
+
return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return new Date(e2);
|
|
74
|
+
})(t2), this.init();
|
|
75
|
+
}, m2.init = function() {
|
|
76
|
+
var t2 = this.$d;
|
|
77
|
+
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
|
|
78
|
+
}, m2.$utils = function() {
|
|
79
|
+
return b;
|
|
80
|
+
}, m2.isValid = function() {
|
|
81
|
+
return !(this.$d.toString() === l);
|
|
82
|
+
}, m2.isSame = function(t2, e2) {
|
|
83
|
+
var n2 = O(t2);
|
|
84
|
+
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
85
|
+
}, m2.isAfter = function(t2, e2) {
|
|
86
|
+
return O(t2) < this.startOf(e2);
|
|
87
|
+
}, m2.isBefore = function(t2, e2) {
|
|
88
|
+
return this.endOf(e2) < O(t2);
|
|
89
|
+
}, m2.$g = function(t2, e2, n2) {
|
|
90
|
+
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
91
|
+
}, m2.unix = function() {
|
|
92
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
93
|
+
}, m2.valueOf = function() {
|
|
94
|
+
return this.$d.getTime();
|
|
95
|
+
}, m2.startOf = function(t2, e2) {
|
|
96
|
+
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
97
|
+
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
98
|
+
return r2 ? i2 : i2.endOf(a);
|
|
99
|
+
}, $2 = function(t3, e3) {
|
|
100
|
+
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
|
|
101
|
+
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
102
|
+
switch (f2) {
|
|
103
|
+
case h:
|
|
104
|
+
return r2 ? l2(1, 0) : l2(31, 11);
|
|
105
|
+
case c:
|
|
106
|
+
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
107
|
+
case o:
|
|
108
|
+
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
109
|
+
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
110
|
+
case a:
|
|
111
|
+
case d:
|
|
112
|
+
return $2(v2 + "Hours", 0);
|
|
113
|
+
case u:
|
|
114
|
+
return $2(v2 + "Minutes", 1);
|
|
115
|
+
case s:
|
|
116
|
+
return $2(v2 + "Seconds", 2);
|
|
117
|
+
case i:
|
|
118
|
+
return $2(v2 + "Milliseconds", 3);
|
|
119
|
+
default:
|
|
120
|
+
return this.clone();
|
|
121
|
+
}
|
|
122
|
+
}, m2.endOf = function(t2) {
|
|
123
|
+
return this.startOf(t2, false);
|
|
124
|
+
}, m2.$set = function(t2, e2) {
|
|
125
|
+
var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
|
|
126
|
+
if (o2 === c || o2 === h) {
|
|
127
|
+
var y2 = this.clone().set(d, 1);
|
|
128
|
+
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
129
|
+
} else l2 && this.$d[l2]($2);
|
|
130
|
+
return this.init(), this;
|
|
131
|
+
}, m2.set = function(t2, e2) {
|
|
132
|
+
return this.clone().$set(t2, e2);
|
|
133
|
+
}, m2.get = function(t2) {
|
|
134
|
+
return this[b.p(t2)]();
|
|
135
|
+
}, m2.add = function(r2, f2) {
|
|
136
|
+
var d2, l2 = this;
|
|
137
|
+
r2 = Number(r2);
|
|
138
|
+
var $2 = b.p(f2), y2 = function(t2) {
|
|
139
|
+
var e2 = O(l2);
|
|
140
|
+
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
141
|
+
};
|
|
142
|
+
if ($2 === c) return this.set(c, this.$M + r2);
|
|
143
|
+
if ($2 === h) return this.set(h, this.$y + r2);
|
|
144
|
+
if ($2 === a) return y2(1);
|
|
145
|
+
if ($2 === o) return y2(7);
|
|
146
|
+
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
147
|
+
return b.w(m3, this);
|
|
148
|
+
}, m2.subtract = function(t2, e2) {
|
|
149
|
+
return this.add(-1 * t2, e2);
|
|
150
|
+
}, m2.format = function(t2) {
|
|
151
|
+
var e2 = this, n2 = this.$locale();
|
|
152
|
+
if (!this.isValid()) return n2.invalidDate || l;
|
|
153
|
+
var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
|
|
154
|
+
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
155
|
+
}, d2 = function(t3) {
|
|
156
|
+
return b.s(s2 % 12 || 12, t3, "0");
|
|
157
|
+
}, $2 = f2 || function(t3, e3, n3) {
|
|
158
|
+
var r3 = t3 < 12 ? "AM" : "PM";
|
|
159
|
+
return n3 ? r3.toLowerCase() : r3;
|
|
160
|
+
};
|
|
161
|
+
return r2.replace(y, (function(t3, r3) {
|
|
162
|
+
return r3 || (function(t4) {
|
|
163
|
+
switch (t4) {
|
|
164
|
+
case "YY":
|
|
165
|
+
return String(e2.$y).slice(-2);
|
|
166
|
+
case "YYYY":
|
|
167
|
+
return b.s(e2.$y, 4, "0");
|
|
168
|
+
case "M":
|
|
169
|
+
return a2 + 1;
|
|
170
|
+
case "MM":
|
|
171
|
+
return b.s(a2 + 1, 2, "0");
|
|
172
|
+
case "MMM":
|
|
173
|
+
return h2(n2.monthsShort, a2, c2, 3);
|
|
174
|
+
case "MMMM":
|
|
175
|
+
return h2(c2, a2);
|
|
176
|
+
case "D":
|
|
177
|
+
return e2.$D;
|
|
178
|
+
case "DD":
|
|
179
|
+
return b.s(e2.$D, 2, "0");
|
|
180
|
+
case "d":
|
|
181
|
+
return String(e2.$W);
|
|
182
|
+
case "dd":
|
|
183
|
+
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
184
|
+
case "ddd":
|
|
185
|
+
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
186
|
+
case "dddd":
|
|
187
|
+
return o2[e2.$W];
|
|
188
|
+
case "H":
|
|
189
|
+
return String(s2);
|
|
190
|
+
case "HH":
|
|
191
|
+
return b.s(s2, 2, "0");
|
|
192
|
+
case "h":
|
|
193
|
+
return d2(1);
|
|
194
|
+
case "hh":
|
|
195
|
+
return d2(2);
|
|
196
|
+
case "a":
|
|
197
|
+
return $2(s2, u2, true);
|
|
198
|
+
case "A":
|
|
199
|
+
return $2(s2, u2, false);
|
|
200
|
+
case "m":
|
|
201
|
+
return String(u2);
|
|
202
|
+
case "mm":
|
|
203
|
+
return b.s(u2, 2, "0");
|
|
204
|
+
case "s":
|
|
205
|
+
return String(e2.$s);
|
|
206
|
+
case "ss":
|
|
207
|
+
return b.s(e2.$s, 2, "0");
|
|
208
|
+
case "SSS":
|
|
209
|
+
return b.s(e2.$ms, 3, "0");
|
|
210
|
+
case "Z":
|
|
211
|
+
return i2;
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
})(t3) || i2.replace(":", "");
|
|
215
|
+
}));
|
|
216
|
+
}, m2.utcOffset = function() {
|
|
217
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
218
|
+
}, m2.diff = function(r2, d2, l2) {
|
|
219
|
+
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
220
|
+
return b.m(y2, m3);
|
|
221
|
+
};
|
|
222
|
+
switch (M3) {
|
|
223
|
+
case h:
|
|
224
|
+
$2 = D2() / 12;
|
|
225
|
+
break;
|
|
226
|
+
case c:
|
|
227
|
+
$2 = D2();
|
|
228
|
+
break;
|
|
229
|
+
case f:
|
|
230
|
+
$2 = D2() / 3;
|
|
231
|
+
break;
|
|
232
|
+
case o:
|
|
233
|
+
$2 = (g2 - v2) / 6048e5;
|
|
234
|
+
break;
|
|
235
|
+
case a:
|
|
236
|
+
$2 = (g2 - v2) / 864e5;
|
|
237
|
+
break;
|
|
238
|
+
case u:
|
|
239
|
+
$2 = g2 / n;
|
|
240
|
+
break;
|
|
241
|
+
case s:
|
|
242
|
+
$2 = g2 / e;
|
|
243
|
+
break;
|
|
244
|
+
case i:
|
|
245
|
+
$2 = g2 / t;
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
$2 = g2;
|
|
249
|
+
}
|
|
250
|
+
return l2 ? $2 : b.a($2);
|
|
251
|
+
}, m2.daysInMonth = function() {
|
|
252
|
+
return this.endOf(c).$D;
|
|
253
|
+
}, m2.$locale = function() {
|
|
254
|
+
return D[this.$L];
|
|
255
|
+
}, m2.locale = function(t2, e2) {
|
|
256
|
+
if (!t2) return this.$L;
|
|
257
|
+
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
258
|
+
return r2 && (n2.$L = r2), n2;
|
|
259
|
+
}, m2.clone = function() {
|
|
260
|
+
return b.w(this.$d, this);
|
|
261
|
+
}, m2.toDate = function() {
|
|
262
|
+
return new Date(this.valueOf());
|
|
263
|
+
}, m2.toJSON = function() {
|
|
264
|
+
return this.isValid() ? this.toISOString() : null;
|
|
265
|
+
}, m2.toISOString = function() {
|
|
266
|
+
return this.$d.toISOString();
|
|
267
|
+
}, m2.toString = function() {
|
|
268
|
+
return this.$d.toUTCString();
|
|
269
|
+
}, M2;
|
|
270
|
+
})(), k = _.prototype;
|
|
271
|
+
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach((function(t2) {
|
|
272
|
+
k[t2[1]] = function(e2) {
|
|
273
|
+
return this.$g(e2, t2[0], t2[1]);
|
|
274
|
+
};
|
|
275
|
+
})), O.extend = function(t2, e2) {
|
|
276
|
+
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
277
|
+
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
278
|
+
return O(1e3 * t2);
|
|
279
|
+
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
280
|
+
}));
|
|
281
|
+
})(dayjs_min$1);
|
|
282
|
+
return dayjs_min$1.exports;
|
|
283
|
+
}
|
|
284
|
+
export {
|
|
285
|
+
requireDayjs_min as __require
|
|
286
|
+
};
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function extractSlotsWithPrefix(slots: SetupContext['slots'], pre
|
|
|
36
36
|
}[];
|
|
37
37
|
export declare function extractSlotsWithoutPrefix(slots: SetupContext['slots'], prefix: string): string[];
|
|
38
38
|
export declare function filterSlots(slots: SetupContext['slots'], filterName: string[]): string[];
|
|
39
|
-
export declare function easyCopy<T>(data: T): T;
|
|
39
|
+
export declare function easyCopy<T>(data: T, reviver?: (key: string, value: any) => any): T;
|
|
40
40
|
export declare function checkSameObject(newData: unknown, oldData: unknown): boolean;
|
|
41
41
|
export declare function valueFillter(val: string, keys: string, data: Record<string, string | number>): string;
|
|
42
42
|
type Simplify<T> = T extends any ? {
|
package/dist/utils/common.mjs
CHANGED
|
@@ -66,8 +66,25 @@ function filterSlots(slots, filterName) {
|
|
|
66
66
|
}
|
|
67
67
|
return res;
|
|
68
68
|
}
|
|
69
|
-
function easyCopy(data) {
|
|
70
|
-
|
|
69
|
+
function easyCopy(data, reviver) {
|
|
70
|
+
if (!data) return data;
|
|
71
|
+
const undefinedKey = `__QD_EASY_COPY_UNDEFINED_${(/* @__PURE__ */ new Date()).getTime()}__`;
|
|
72
|
+
const res = JSON.parse(
|
|
73
|
+
JSON.stringify(data, (key, value) => {
|
|
74
|
+
const reVal = reviver ? reviver(key, value) : value;
|
|
75
|
+
return reVal === void 0 ? undefinedKey : reVal;
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
return restoreUndefined(res);
|
|
79
|
+
function restoreUndefined(value) {
|
|
80
|
+
if (value === undefinedKey) return void 0;
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
for (let i = 0; i < value.length; i++) value[i] = restoreUndefined(value[i]);
|
|
83
|
+
} else if (value && typeof value === "object") {
|
|
84
|
+
for (const key in value) value[key] = restoreUndefined(value[key]);
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
71
88
|
}
|
|
72
89
|
function checkSameObject(newData, oldData) {
|
|
73
90
|
if (newData && !oldData || !newData && oldData || typeof newData !== typeof oldData) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import dayjs from "../_virtual/dayjs.min.mjs";
|
|
2
|
+
import { isEmpty } from "./common.mjs";
|
|
3
|
+
function formatDate(value, format = "YYYY-MM-DD HH:mm:ss", fallback = "") {
|
|
4
|
+
if (isEmpty(value)) return fallback;
|
|
5
|
+
const date = value === "now" ? dayjs() : dayjs(value);
|
|
6
|
+
if (!date.isValid()) return fallback;
|
|
7
|
+
return date.format(format);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
formatDate
|
|
11
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qidian-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.75",
|
|
4
4
|
"description": "QiDian 共享工具函数和钩子",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "qidian",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"crypto-js": "^4.2.0",
|
|
35
|
+
"dayjs": "^1.11.19",
|
|
35
36
|
"jsencrypt": "^3.5.4",
|
|
36
37
|
"vue-request": "^2.0.4",
|
|
37
38
|
"jsonrepair": "^3.12.0"
|