zxl-common-utils 0.0.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.
- package/README.md +9 -0
- package/lib/components/index.d.ts +6 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +894 -0
- package/lib/index.js.gz +0 -0
- package/lib/plugins/components.d.ts +14 -0
- package/lib/plugins/components.d.ts.map +1 -0
- package/lib/types/index.d.ts +44 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/utils/index.d.ts +10 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/vite.svg +1 -0
- package/lib/zxl-common-utils.css +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;AAY3C,eAAe,UAAU,CAAC;AAG1B,eAAO,MAAM,cAAc,KAA4B,CAAC;AACxD,eAAO,MAAM,KAAK,KAAmB,CAAC;AACtC,eAAO,MAAM,UAAU,KAAwB,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useComponents } from './plugins/components';
|
|
2
|
+
export { useComponents };
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './components';
|
|
5
|
+
export type { ColorList, TemplateToolsType, DefaultPropsType, StaticConfig, StaticOptions, StaticResources, UseColorReturn, ColorMap, ComponentProps, } from './types';
|
|
6
|
+
declare const defaultExport: Record<string, any>;
|
|
7
|
+
export default defaultExport;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,EAAE,aAAa,EAAE,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,QAAQ,EACR,cAAc,GACf,MAAM,SAAS,CAAC;AAIjB,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAItC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
import { defineComponent as W, ref as v, watch as P, onMounted as oe, onUnmounted as G, createElementBlock as U, openBlock as z, normalizeStyle as N, normalizeClass as ne, renderSlot as Q, computed as re, nextTick as se, createCommentVNode as ae } from "vue";
|
|
2
|
+
function A(e) {
|
|
3
|
+
var t = typeof e;
|
|
4
|
+
return e != null && (t == "object" || t == "function");
|
|
5
|
+
}
|
|
6
|
+
var ce = typeof global == "object" && global && global.Object === Object && global, ie = typeof self == "object" && self && self.Object === Object && self, Z = ce || ie || Function("return this")(), F = function() {
|
|
7
|
+
return Z.Date.now();
|
|
8
|
+
}, le = /\s/;
|
|
9
|
+
function fe(e) {
|
|
10
|
+
for (var t = e.length; t-- && le.test(e.charAt(t)); )
|
|
11
|
+
;
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
var ue = /^\s+/;
|
|
15
|
+
function de(e) {
|
|
16
|
+
return e && e.slice(0, fe(e) + 1).replace(ue, "");
|
|
17
|
+
}
|
|
18
|
+
var D = Z.Symbol, ee = Object.prototype, ge = ee.hasOwnProperty, he = ee.toString, B = D ? D.toStringTag : void 0;
|
|
19
|
+
function be(e) {
|
|
20
|
+
var t = ge.call(e, B), o = e[B];
|
|
21
|
+
try {
|
|
22
|
+
e[B] = void 0;
|
|
23
|
+
var n = !0;
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
var r = he.call(e);
|
|
27
|
+
return n && (t ? e[B] = o : delete e[B]), r;
|
|
28
|
+
}
|
|
29
|
+
var me = Object.prototype, pe = me.toString;
|
|
30
|
+
function ye(e) {
|
|
31
|
+
return pe.call(e);
|
|
32
|
+
}
|
|
33
|
+
var ve = "[object Null]", we = "[object Undefined]", Y = D ? D.toStringTag : void 0;
|
|
34
|
+
function Ce(e) {
|
|
35
|
+
return e == null ? e === void 0 ? we : ve : Y && Y in Object(e) ? be(e) : ye(e);
|
|
36
|
+
}
|
|
37
|
+
function $e(e) {
|
|
38
|
+
return e != null && typeof e == "object";
|
|
39
|
+
}
|
|
40
|
+
var Se = "[object Symbol]";
|
|
41
|
+
function _e(e) {
|
|
42
|
+
return typeof e == "symbol" || $e(e) && Ce(e) == Se;
|
|
43
|
+
}
|
|
44
|
+
var V = NaN, ke = /^[-+]0x[0-9a-f]+$/i, Re = /^0b[01]+$/i, Ee = /^0o[0-7]+$/i, Me = parseInt;
|
|
45
|
+
function H(e) {
|
|
46
|
+
if (typeof e == "number")
|
|
47
|
+
return e;
|
|
48
|
+
if (_e(e))
|
|
49
|
+
return V;
|
|
50
|
+
if (A(e)) {
|
|
51
|
+
var t = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
52
|
+
e = A(t) ? t + "" : t;
|
|
53
|
+
}
|
|
54
|
+
if (typeof e != "string")
|
|
55
|
+
return e === 0 ? e : +e;
|
|
56
|
+
e = de(e);
|
|
57
|
+
var o = Re.test(e);
|
|
58
|
+
return o || Ee.test(e) ? Me(e.slice(2), o ? 2 : 8) : ke.test(e) ? V : +e;
|
|
59
|
+
}
|
|
60
|
+
var Oe = "Expected a function", Te = Math.max, je = Math.min;
|
|
61
|
+
function xe(e, t, o) {
|
|
62
|
+
var n, r, c, i, u, s, l = 0, w = !1, y = !1, p = !0;
|
|
63
|
+
if (typeof e != "function")
|
|
64
|
+
throw new TypeError(Oe);
|
|
65
|
+
t = H(t) || 0, A(o) && (w = !!o.leading, y = "maxWait" in o, c = y ? Te(H(o.maxWait) || 0, t) : c, p = "trailing" in o ? !!o.trailing : p);
|
|
66
|
+
function m(h) {
|
|
67
|
+
var $ = n, _ = r;
|
|
68
|
+
return n = r = void 0, l = h, i = e.apply(_, $), i;
|
|
69
|
+
}
|
|
70
|
+
function f(h) {
|
|
71
|
+
return l = h, u = setTimeout(a, t), w ? m(h) : i;
|
|
72
|
+
}
|
|
73
|
+
function g(h) {
|
|
74
|
+
var $ = h - s, _ = h - l, R = t - $;
|
|
75
|
+
return y ? je(R, c - _) : R;
|
|
76
|
+
}
|
|
77
|
+
function d(h) {
|
|
78
|
+
var $ = h - s, _ = h - l;
|
|
79
|
+
return s === void 0 || $ >= t || $ < 0 || y && _ >= c;
|
|
80
|
+
}
|
|
81
|
+
function a() {
|
|
82
|
+
var h = F();
|
|
83
|
+
if (d(h))
|
|
84
|
+
return b(h);
|
|
85
|
+
u = setTimeout(a, g(h));
|
|
86
|
+
}
|
|
87
|
+
function b(h) {
|
|
88
|
+
return u = void 0, p && n ? m(h) : (n = r = void 0, i);
|
|
89
|
+
}
|
|
90
|
+
function C() {
|
|
91
|
+
u !== void 0 && clearTimeout(u), l = 0, n = s = r = u = void 0;
|
|
92
|
+
}
|
|
93
|
+
function S() {
|
|
94
|
+
return u === void 0 ? i : b(F());
|
|
95
|
+
}
|
|
96
|
+
function k() {
|
|
97
|
+
var h = F(), $ = d(h);
|
|
98
|
+
if (n = arguments, r = this, s = h, $) {
|
|
99
|
+
if (u === void 0)
|
|
100
|
+
return f(s);
|
|
101
|
+
if (y)
|
|
102
|
+
return clearTimeout(u), u = setTimeout(a, t), m(s);
|
|
103
|
+
}
|
|
104
|
+
return u === void 0 && (u = setTimeout(a, t)), i;
|
|
105
|
+
}
|
|
106
|
+
return k.cancel = C, k.flush = S, k;
|
|
107
|
+
}
|
|
108
|
+
var Le = "Expected a function";
|
|
109
|
+
function Ie(e, t, o) {
|
|
110
|
+
var n = !0, r = !0;
|
|
111
|
+
if (typeof e != "function")
|
|
112
|
+
throw new TypeError(Le);
|
|
113
|
+
return A(o) && (n = "leading" in o ? !1 : n, r = "trailing" in o ? !0 : r), xe(e, t, {
|
|
114
|
+
leading: n,
|
|
115
|
+
maxWait: t,
|
|
116
|
+
trailing: r
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const Be = /* @__PURE__ */ W({
|
|
120
|
+
__name: "ComponentRatio",
|
|
121
|
+
props: {
|
|
122
|
+
width: { default: 1920 },
|
|
123
|
+
height: { default: 1080 },
|
|
124
|
+
maxWidth: { default: 1920 },
|
|
125
|
+
full: { type: Boolean, default: !1 }
|
|
126
|
+
},
|
|
127
|
+
setup(e) {
|
|
128
|
+
const t = e, o = v(t.width), n = v(1), r = v(1), c = v(1), i = v(1), u = v(null);
|
|
129
|
+
let s = null, l = null;
|
|
130
|
+
P(
|
|
131
|
+
() => t.full,
|
|
132
|
+
() => {
|
|
133
|
+
t.full && w();
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
function w() {
|
|
137
|
+
if (!s || !u.value) return;
|
|
138
|
+
const p = s.offsetWidth, m = s.offsetHeight;
|
|
139
|
+
if (p === 0 || m === 0) return;
|
|
140
|
+
if (t.full) {
|
|
141
|
+
const d = window.innerWidth, a = window.innerHeight;
|
|
142
|
+
c.value = d / t.width, i.value = a / t.height, o.value = t.width, n.value = 1, r.value = 1;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const f = p / t.width, g = m / t.height;
|
|
146
|
+
if (n.value = Math.min(f, g), t.maxWidth > t.width && f > g) {
|
|
147
|
+
const d = Math.min(
|
|
148
|
+
t.width / g,
|
|
149
|
+
// 按高度比例计算的宽度
|
|
150
|
+
p / g,
|
|
151
|
+
// 父容器允许的宽度
|
|
152
|
+
t.maxWidth
|
|
153
|
+
// 用户设置的最大宽度
|
|
154
|
+
);
|
|
155
|
+
o.value = d;
|
|
156
|
+
} else
|
|
157
|
+
o.value = t.width;
|
|
158
|
+
r.value = o.value / t.width, c.value = n.value, i.value = n.value;
|
|
159
|
+
}
|
|
160
|
+
const y = Ie(w, 500, { leading: !1, trailing: !0 });
|
|
161
|
+
return oe(() => {
|
|
162
|
+
s = u.value?.parentElement ?? null, s && (l = new ResizeObserver(y), l.observe(s)), t.full && window.addEventListener("resize", y), w();
|
|
163
|
+
}), G(() => {
|
|
164
|
+
l && (l.disconnect(), l = null), window.removeEventListener("resize", y), y.cancel(), s = null;
|
|
165
|
+
}), (p, m) => (z(), U("div", {
|
|
166
|
+
ref_key: "container",
|
|
167
|
+
ref: u,
|
|
168
|
+
class: ne(["fixed-aspect-ratio", { "is-full": e.full }]),
|
|
169
|
+
style: N({
|
|
170
|
+
width: `${o.value}px`,
|
|
171
|
+
height: `${e.height}px`,
|
|
172
|
+
transform: e.full ? `scale(${c.value}, ${i.value})` : `scale(${n.value}) translate(-50%, 0)`
|
|
173
|
+
})
|
|
174
|
+
}, [
|
|
175
|
+
Q(p.$slots, "default", {}, void 0, !0)
|
|
176
|
+
], 6));
|
|
177
|
+
}
|
|
178
|
+
}), Pe = (e, t) => {
|
|
179
|
+
const o = e.__vccOpts || e;
|
|
180
|
+
for (const [n, r] of t)
|
|
181
|
+
o[n] = r;
|
|
182
|
+
return o;
|
|
183
|
+
}, Ue = /* @__PURE__ */ Pe(Be, [["__scopeId", "data-v-b6cd8c05"]]), ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
184
|
+
__proto__: null,
|
|
185
|
+
default: Ue
|
|
186
|
+
}, Symbol.toStringTag, { value: "Module" })), Ae = "#000000", De = "#ffffff", Fe = "#ff0000", We = "#00ff00", Ge = "#0000ff", Ne = "#ffff00", Xe = "#00ffff", qe = "#ff00ff", Ye = "#c0c0c0", Ve = "#808080", He = "#800000", Ke = "#808000", Je = "#800080", Qe = "#008080", Ze = "#000080", et = "#f0f8ff", tt = "#faebd7", ot = "#7fffd4", nt = "#f0ffff", rt = "#f5f5dc", st = "#ffe4c4", at = "#ffebcd", ct = "#8a2be2", it = "#a52a2a", lt = "#deb887", ft = "#5f9ea0", ut = "#7fff00", dt = "#d2691e", gt = "#ff7f50", ht = "#6495ed", bt = "#fff8dc", mt = "#dc143c", pt = "#00008b", yt = "#008b8b", vt = "#b8860b", wt = "#a9a9a9", Ct = "#006400", $t = "#bdb76b", St = "#8b008b", _t = "#556b2f", kt = "#ff8c00", Rt = "#9932cc", Et = "#8b0000", Mt = "#e9967a", Ot = "#8fbc8f", Tt = "#483d8b", jt = "#2f4f4f", xt = "#00ced1", Lt = "#9400d3", It = "#ff1493", Bt = "#00bfff", Pt = "#696969", Ut = "#1e90ff", zt = "#b22222", At = "#fffaf0", Dt = "#228b22", Ft = "#ff00ff", Wt = "#dcdcdc", Gt = "#f8f8ff", Nt = "#ffd700", Xt = "#daa520", qt = "#adff2f", Yt = "#f0fff0", Vt = "#ff69b4", Ht = "#cd5c5c", Kt = "#4b0082", Jt = "#fffff0", Qt = "#f0e68c", Zt = "#e6e6fa", eo = "#fff0f5", to = "#7cfc00", oo = "#fffacd", no = "#add8e6", ro = "#f08080", so = "#e0ffff", ao = "#fafad2", co = "#d3d3d3", io = "#90ee90", lo = "#ffb6c1", fo = "#ffa07a", uo = "#20b2aa", go = "#87cefa", ho = "#778899", bo = "#b0c4de", mo = "#ffffe0", po = "#00ff00", yo = "#32cd32", vo = "#faf0e6", wo = "#66cdaa", Co = "#0000cd", $o = "#ba55d3", So = "#9370db", _o = "#3cb371", ko = "#7b68ee", Ro = "#00fa9a", Eo = "#48d1cc", Mo = "#c71585", Oo = "#191970", To = "#f5fffa", jo = "#ffe4e1", xo = "#ffe4b5", Lo = "#ffdead", Io = "#fdf5e6", Bo = "#ffa500", Po = "#ff4500", Uo = "#da70d6", zo = "#eee8aa", Ao = "#98fb98", Do = "#afeeee", Fo = "#db7093", Wo = "#ffefd5", Go = "#ffdab9", No = "#cd853f", Xo = "#ffc0cb", qo = "#dda0dd", Yo = "#b0e0e6", Vo = "#bc8f8f", Ho = "#4169e1", Ko = "#8b4513", Jo = "#fa8072", Qo = "#f4a460", Zo = "#2e8b57", en = "#fff5ee", tn = "#a0522d", on = "#87ceeb", nn = "#6a5acd", rn = "#708090", sn = "#fffafa", an = "#00ff7f", cn = "#4682b4", ln = "#d2b48c", fn = "#d8bfd8", un = "#ff6347", dn = "#40e0d0", gn = "#ee82ee", hn = "#f5deb3", bn = "#f5f5f5", mn = "#9acd32", pn = {
|
|
187
|
+
black: Ae,
|
|
188
|
+
white: De,
|
|
189
|
+
red: Fe,
|
|
190
|
+
green: We,
|
|
191
|
+
blue: Ge,
|
|
192
|
+
yellow: Ne,
|
|
193
|
+
cyan: Xe,
|
|
194
|
+
magenta: qe,
|
|
195
|
+
silver: Ye,
|
|
196
|
+
gray: Ve,
|
|
197
|
+
maroon: He,
|
|
198
|
+
olive: Ke,
|
|
199
|
+
purple: Je,
|
|
200
|
+
teal: Qe,
|
|
201
|
+
navy: Ze,
|
|
202
|
+
aliceblue: et,
|
|
203
|
+
antiquewhite: tt,
|
|
204
|
+
aquamarine: ot,
|
|
205
|
+
azure: nt,
|
|
206
|
+
beige: rt,
|
|
207
|
+
bisque: st,
|
|
208
|
+
blanchedalmond: at,
|
|
209
|
+
blueviolet: ct,
|
|
210
|
+
brown: it,
|
|
211
|
+
burlywood: lt,
|
|
212
|
+
cadetblue: ft,
|
|
213
|
+
chartreuse: ut,
|
|
214
|
+
chocolate: dt,
|
|
215
|
+
coral: gt,
|
|
216
|
+
cornflowerblue: ht,
|
|
217
|
+
cornsilk: bt,
|
|
218
|
+
crimson: mt,
|
|
219
|
+
darkblue: pt,
|
|
220
|
+
darkcyan: yt,
|
|
221
|
+
darkgoldenrod: vt,
|
|
222
|
+
darkgray: wt,
|
|
223
|
+
darkgreen: Ct,
|
|
224
|
+
darkkhaki: $t,
|
|
225
|
+
darkmagenta: St,
|
|
226
|
+
darkolivegreen: _t,
|
|
227
|
+
darkorange: kt,
|
|
228
|
+
darkorchid: Rt,
|
|
229
|
+
darkred: Et,
|
|
230
|
+
darksalmon: Mt,
|
|
231
|
+
darkseagreen: Ot,
|
|
232
|
+
darkslateblue: Tt,
|
|
233
|
+
darkslategray: jt,
|
|
234
|
+
darkturquoise: xt,
|
|
235
|
+
darkviolet: Lt,
|
|
236
|
+
deeppink: It,
|
|
237
|
+
deepskyblue: Bt,
|
|
238
|
+
dimgray: Pt,
|
|
239
|
+
dodgerblue: Ut,
|
|
240
|
+
firebrick: zt,
|
|
241
|
+
floralwhite: At,
|
|
242
|
+
forestgreen: Dt,
|
|
243
|
+
fuchsia: Ft,
|
|
244
|
+
gainsboro: Wt,
|
|
245
|
+
ghostwhite: Gt,
|
|
246
|
+
gold: Nt,
|
|
247
|
+
goldenrod: Xt,
|
|
248
|
+
greenyellow: qt,
|
|
249
|
+
honeydew: Yt,
|
|
250
|
+
hotpink: Vt,
|
|
251
|
+
indianred: Ht,
|
|
252
|
+
indigo: Kt,
|
|
253
|
+
ivory: Jt,
|
|
254
|
+
khaki: Qt,
|
|
255
|
+
lavender: Zt,
|
|
256
|
+
lavenderblush: eo,
|
|
257
|
+
lawngreen: to,
|
|
258
|
+
lemonchiffon: oo,
|
|
259
|
+
lightblue: no,
|
|
260
|
+
lightcoral: ro,
|
|
261
|
+
lightcyan: so,
|
|
262
|
+
lightgoldenrodyellow: ao,
|
|
263
|
+
lightgray: co,
|
|
264
|
+
lightgreen: io,
|
|
265
|
+
lightpink: lo,
|
|
266
|
+
lightsalmon: fo,
|
|
267
|
+
lightseagreen: uo,
|
|
268
|
+
lightskyblue: go,
|
|
269
|
+
lightslategray: ho,
|
|
270
|
+
lightsteelblue: bo,
|
|
271
|
+
lightyellow: mo,
|
|
272
|
+
lime: po,
|
|
273
|
+
limegreen: yo,
|
|
274
|
+
linen: vo,
|
|
275
|
+
mediumaquamarine: wo,
|
|
276
|
+
mediumblue: Co,
|
|
277
|
+
mediumorchid: $o,
|
|
278
|
+
mediumpurple: So,
|
|
279
|
+
mediumseagreen: _o,
|
|
280
|
+
mediumslateblue: ko,
|
|
281
|
+
mediumspringgreen: Ro,
|
|
282
|
+
mediumturquoise: Eo,
|
|
283
|
+
mediumvioletred: Mo,
|
|
284
|
+
midnightblue: Oo,
|
|
285
|
+
mintcream: To,
|
|
286
|
+
mistyrose: jo,
|
|
287
|
+
moccasin: xo,
|
|
288
|
+
navajowhite: Lo,
|
|
289
|
+
oldlace: Io,
|
|
290
|
+
orange: Bo,
|
|
291
|
+
orangered: Po,
|
|
292
|
+
orchid: Uo,
|
|
293
|
+
palegoldenrod: zo,
|
|
294
|
+
palegreen: Ao,
|
|
295
|
+
paleturquoise: Do,
|
|
296
|
+
palevioletred: Fo,
|
|
297
|
+
papayawhip: Wo,
|
|
298
|
+
peachpuff: Go,
|
|
299
|
+
peru: No,
|
|
300
|
+
pink: Xo,
|
|
301
|
+
plum: qo,
|
|
302
|
+
powderblue: Yo,
|
|
303
|
+
rosybrown: Vo,
|
|
304
|
+
royalblue: Ho,
|
|
305
|
+
saddlebrown: Ko,
|
|
306
|
+
salmon: Jo,
|
|
307
|
+
sandybrown: Qo,
|
|
308
|
+
seagreen: Zo,
|
|
309
|
+
seashell: en,
|
|
310
|
+
sienna: tn,
|
|
311
|
+
skyblue: on,
|
|
312
|
+
slateblue: nn,
|
|
313
|
+
slategray: rn,
|
|
314
|
+
snow: sn,
|
|
315
|
+
springgreen: an,
|
|
316
|
+
steelblue: cn,
|
|
317
|
+
tan: ln,
|
|
318
|
+
thistle: fn,
|
|
319
|
+
tomato: un,
|
|
320
|
+
turquoise: dn,
|
|
321
|
+
violet: gn,
|
|
322
|
+
wheat: hn,
|
|
323
|
+
whitesmoke: bn,
|
|
324
|
+
yellowgreen: mn
|
|
325
|
+
};
|
|
326
|
+
function T(e) {
|
|
327
|
+
let t = e;
|
|
328
|
+
if (/^#([0-9A-F]{3})$/i.test(e))
|
|
329
|
+
t = `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toLowerCase();
|
|
330
|
+
else if (/^#([0-9A-F]{4})$/i.test(e))
|
|
331
|
+
t = `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}${e[4]}${e[4]}`.toLowerCase();
|
|
332
|
+
else if (/^#([0-9A-F]{6})$/i.test(e) || /^#([0-9A-F]{8})$/i.test(e))
|
|
333
|
+
t = e.toLowerCase();
|
|
334
|
+
else {
|
|
335
|
+
const n = e.toLowerCase().trim(), r = pn[n];
|
|
336
|
+
if (r)
|
|
337
|
+
t = r;
|
|
338
|
+
else
|
|
339
|
+
throw new Error(
|
|
340
|
+
`Invalid color value: ${e}. Supported formats: hex (#RGB, #RGBA, #RRGGBB, #RRGGBBAA) or CSS color names (e.g., blue, red, gray)`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
const o = t.replace("#", "");
|
|
344
|
+
return {
|
|
345
|
+
r: parseInt(o.substring(0, 2), 16),
|
|
346
|
+
g: parseInt(o.substring(2, 4), 16),
|
|
347
|
+
b: parseInt(o.substring(4, 6), 16)
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function yn(e, t) {
|
|
351
|
+
const o = typeof e == "string" ? e : e.value, n = T(o);
|
|
352
|
+
return v(`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`);
|
|
353
|
+
}
|
|
354
|
+
function vn(e, t, o) {
|
|
355
|
+
const n = typeof e == "string" ? e : e.value, r = typeof t == "string" ? t : t.value, c = T(n), i = T(r), u = Math.round(c.r * (1 - o) + i.r * o), s = Math.round(c.g * (1 - o) + i.g * o), l = Math.round(c.b * (1 - o) + i.b * o);
|
|
356
|
+
return v(
|
|
357
|
+
`#${u.toString(16).padStart(2, "0")}${s.toString(16).padStart(2, "0")}${l.toString(16).padStart(2, "0")}`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
function wn(e, t) {
|
|
361
|
+
const o = typeof e == "string" ? e : e.value, n = T(o), r = 1 + t / 100, c = Math.min(255, Math.max(0, Math.round(n.r * r))), i = Math.min(255, Math.max(0, Math.round(n.g * r))), u = Math.min(255, Math.max(0, Math.round(n.b * r)));
|
|
362
|
+
return v(
|
|
363
|
+
`#${c.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}${u.toString(16).padStart(2, "0")}`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
let Cn = class {
|
|
367
|
+
colorMap = /* @__PURE__ */ new Map();
|
|
368
|
+
constructor(t) {
|
|
369
|
+
this.initializeColors(t);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* 初始化颜色映射
|
|
373
|
+
* @param colors 颜色列表
|
|
374
|
+
*
|
|
375
|
+
*/
|
|
376
|
+
initializeColors(t) {
|
|
377
|
+
t.forEach(({ name: o, value: n }) => {
|
|
378
|
+
(Array.isArray(n) ? n : [n]).forEach((c, i) => {
|
|
379
|
+
const u = Array.isArray(n) ? `${o}:${i}` : o;
|
|
380
|
+
this.colorMap.set(u, c);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* 获取颜色
|
|
386
|
+
* @param key 颜色键名
|
|
387
|
+
* @param index 索引(用于数组类型的颜色)
|
|
388
|
+
* @returns 响应式颜色引用
|
|
389
|
+
*/
|
|
390
|
+
get(t, o) {
|
|
391
|
+
const n = o !== void 0 ? `${t}:${o}` : t, r = this.colorMap.get(n);
|
|
392
|
+
return v(r || "#000000");
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* 获取所有颜色键
|
|
396
|
+
* @returns 颜色键数组
|
|
397
|
+
*/
|
|
398
|
+
getAllKeys() {
|
|
399
|
+
return Array.from(this.colorMap.keys());
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* 获取颜色键
|
|
403
|
+
* @returns 颜色键数组
|
|
404
|
+
*/
|
|
405
|
+
getKeys(t) {
|
|
406
|
+
return Array.from(this.colorMap.keys()).filter(
|
|
407
|
+
(n) => n === t || n.startsWith(`${t}:`)
|
|
408
|
+
).map((n) => this.colorMap.get(n));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* 检查是否存在指定颜色
|
|
412
|
+
* @param key 颜色键名
|
|
413
|
+
* @returns 是否存在
|
|
414
|
+
*/
|
|
415
|
+
has(t) {
|
|
416
|
+
return this.colorMap.has(t);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
420
|
+
__proto__: null,
|
|
421
|
+
ColorPlateSystem: Cn,
|
|
422
|
+
hexToRgb: T,
|
|
423
|
+
lightenColor: wn,
|
|
424
|
+
mixColor: vn,
|
|
425
|
+
opacity: yn
|
|
426
|
+
}, Symbol.toStringTag, { value: "Module" })), Sn = /* @__PURE__ */ W({
|
|
427
|
+
__name: "Image",
|
|
428
|
+
props: {
|
|
429
|
+
src: { default: "" },
|
|
430
|
+
color: { default: "" },
|
|
431
|
+
alt: { default: "" },
|
|
432
|
+
changeColor: { type: Boolean, default: !1 }
|
|
433
|
+
},
|
|
434
|
+
setup(e) {
|
|
435
|
+
const t = e, o = v(""), n = re(() => ({
|
|
436
|
+
backgroundImage: o.value ? `url(${o.value})` : t.src ? `url(${t.src})` : "none",
|
|
437
|
+
backgroundSize: "contain",
|
|
438
|
+
backgroundRepeat: "no-repeat",
|
|
439
|
+
backgroundPosition: "center"
|
|
440
|
+
}));
|
|
441
|
+
function r(s) {
|
|
442
|
+
if (!s) return "";
|
|
443
|
+
const l = s.match(/^url\(['"]?(.+?)['"]?\)$/);
|
|
444
|
+
return l && l[1] ? l[1] : s;
|
|
445
|
+
}
|
|
446
|
+
function c(s) {
|
|
447
|
+
return s ? typeof s == "string" ? s : s.value : "";
|
|
448
|
+
}
|
|
449
|
+
async function i(s, l) {
|
|
450
|
+
return new Promise((w, y) => {
|
|
451
|
+
const p = new Image();
|
|
452
|
+
p.crossOrigin = "anonymous", p.onload = () => {
|
|
453
|
+
try {
|
|
454
|
+
const m = document.createElement("canvas"), f = m.getContext("2d");
|
|
455
|
+
if (!f) {
|
|
456
|
+
y(new Error("Failed to get canvas context"));
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
m.width = p.width, m.height = p.height, f.drawImage(p, 0, 0);
|
|
460
|
+
const g = f.getImageData(0, 0, m.width, m.height), d = g.data, a = T(l), b = (a.r * 0.299 + a.g * 0.587 + a.b * 0.114) / 255;
|
|
461
|
+
for (let S = 0; S < d.length; S += 4) {
|
|
462
|
+
const k = d[S], h = d[S + 1], $ = d[S + 2];
|
|
463
|
+
if (d[S + 3] > 0) {
|
|
464
|
+
const R = (k * 0.299 + h * 0.587 + $ * 0.114) / 255;
|
|
465
|
+
let E = R;
|
|
466
|
+
b > 0.5 ? E = Math.pow(R, 0.7) : E = R, d[S] = Math.min(255, Math.round(a.r * E)), d[S + 1] = Math.min(255, Math.round(a.g * E)), d[S + 2] = Math.min(255, Math.round(a.b * E));
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
f.putImageData(g, 0, 0);
|
|
470
|
+
const C = m.toDataURL("image/png");
|
|
471
|
+
w(C);
|
|
472
|
+
} catch (m) {
|
|
473
|
+
y(m);
|
|
474
|
+
}
|
|
475
|
+
}, p.onerror = () => {
|
|
476
|
+
y(new Error(`Failed to load image: ${s}`));
|
|
477
|
+
}, p.src = s;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
async function u() {
|
|
481
|
+
if (!t.src || !t.color) {
|
|
482
|
+
o.value = "";
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
try {
|
|
486
|
+
debugger;
|
|
487
|
+
const s = r(t.src), l = c(t.color);
|
|
488
|
+
if (!l) {
|
|
489
|
+
o.value = "";
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const w = await i(s, l);
|
|
493
|
+
o.value = w;
|
|
494
|
+
} catch (s) {
|
|
495
|
+
console.error("Failed to process image color:", s), o.value = "";
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return P([() => t.src, () => t.color], () => {
|
|
499
|
+
t.changeColor && u();
|
|
500
|
+
}, { immediate: !0 }), G(() => {
|
|
501
|
+
o.value && URL.revokeObjectURL(o.value);
|
|
502
|
+
}), (s, l) => (z(), U("div", {
|
|
503
|
+
style: N(n.value)
|
|
504
|
+
}, null, 4));
|
|
505
|
+
}
|
|
506
|
+
}), _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
507
|
+
__proto__: null,
|
|
508
|
+
default: Sn
|
|
509
|
+
}, Symbol.toStringTag, { value: "Module" })), kn = /* @__PURE__ */ W({
|
|
510
|
+
__name: "TooltipBox",
|
|
511
|
+
props: {
|
|
512
|
+
isShow: { type: Boolean, default: !1 },
|
|
513
|
+
offset: { default: 10 }
|
|
514
|
+
},
|
|
515
|
+
setup(e) {
|
|
516
|
+
const t = e, o = v(null), n = v(null), r = v(-9999), c = v(-9999), i = v(!1);
|
|
517
|
+
let u = 0, s = 0;
|
|
518
|
+
function l(f, g, d) {
|
|
519
|
+
if (f === void 0) return d;
|
|
520
|
+
if (typeof f == "number") return f;
|
|
521
|
+
if (typeof f == "string") {
|
|
522
|
+
const a = f.match(/^(\d+(?:\.\d+)?)%$/);
|
|
523
|
+
if (a && a[1])
|
|
524
|
+
return parseFloat(a[1]) / 100 * g;
|
|
525
|
+
const b = parseFloat(f);
|
|
526
|
+
if (!isNaN(b)) return b;
|
|
527
|
+
}
|
|
528
|
+
return d;
|
|
529
|
+
}
|
|
530
|
+
function w(f, g) {
|
|
531
|
+
const a = t.offset;
|
|
532
|
+
if (a == null)
|
|
533
|
+
return { gapX: 10, gapY: 10 };
|
|
534
|
+
if (typeof a == "number")
|
|
535
|
+
return { gapX: a, gapY: a };
|
|
536
|
+
if (typeof a == "string") {
|
|
537
|
+
const b = l(a, f, 10), C = l(a, g, 10);
|
|
538
|
+
return { gapX: b, gapY: C };
|
|
539
|
+
}
|
|
540
|
+
if (typeof a == "object") {
|
|
541
|
+
const b = l(a.x, f, 10), C = l(a.y, g, 10);
|
|
542
|
+
return { gapX: b, gapY: C };
|
|
543
|
+
}
|
|
544
|
+
return { gapX: 10, gapY: 10 };
|
|
545
|
+
}
|
|
546
|
+
function y(f) {
|
|
547
|
+
let g = 1, d = 1, a = 0, b = 0, C = f.parentElement;
|
|
548
|
+
for (; C; ) {
|
|
549
|
+
const k = window.getComputedStyle(C).transform;
|
|
550
|
+
if (k && k !== "none") {
|
|
551
|
+
const h = k.match(/matrix\(([^)]+)\)/);
|
|
552
|
+
if (h && h[1]) {
|
|
553
|
+
const _ = h[1].split(",").map(Number);
|
|
554
|
+
g = _[0] || 1, d = _[3] || 1;
|
|
555
|
+
}
|
|
556
|
+
const $ = C.getBoundingClientRect();
|
|
557
|
+
a = $.left, b = $.top;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
C = C.parentElement;
|
|
561
|
+
}
|
|
562
|
+
return { scaleX: g, scaleY: d, offsetX: a, offsetY: b };
|
|
563
|
+
}
|
|
564
|
+
function p(f, g) {
|
|
565
|
+
const d = o.value, a = n.value;
|
|
566
|
+
if (!d || !a) return;
|
|
567
|
+
const { scaleX: b, scaleY: C, offsetX: S, offsetY: k } = y(a), h = (f - S) / b, $ = (g - k) / C, _ = d.offsetWidth, R = d.offsetHeight, { gapX: E, gapY: x } = w(_, R), X = window.innerWidth / b, q = window.innerHeight / C;
|
|
568
|
+
let L = h + E, I = $ + x;
|
|
569
|
+
L + _ + E > X && (L = h - _ - E), I + R + x > q && (I = $ - R - x), L = Math.max(E, Math.min(L, X - _ - E)), I = Math.max(x, Math.min(I, q - R - x)), r.value = L, c.value = I;
|
|
570
|
+
}
|
|
571
|
+
const m = (f) => {
|
|
572
|
+
u = f.clientX, s = f.clientY, i.value && p(f.clientX, f.clientY);
|
|
573
|
+
};
|
|
574
|
+
return P(i, (f) => {
|
|
575
|
+
f ? document.addEventListener("mousemove", m, { passive: !0 }) : document.removeEventListener("mousemove", m);
|
|
576
|
+
}), G(() => {
|
|
577
|
+
document.removeEventListener("mousemove", m);
|
|
578
|
+
}), P(
|
|
579
|
+
() => t.isShow,
|
|
580
|
+
(f) => {
|
|
581
|
+
t.isShow ? (r.value = -9999, c.value = -9999, i.value = !0, se(() => {
|
|
582
|
+
p(u, s);
|
|
583
|
+
})) : i.value = !1;
|
|
584
|
+
},
|
|
585
|
+
{ deep: !0, immediate: !0 }
|
|
586
|
+
), (f, g) => (z(), U("div", {
|
|
587
|
+
ref_key: "containerDom",
|
|
588
|
+
ref: n,
|
|
589
|
+
style: { position: "static" }
|
|
590
|
+
}, [
|
|
591
|
+
i.value ? (z(), U("div", {
|
|
592
|
+
key: 0,
|
|
593
|
+
ref_key: "tooltipBoxDom",
|
|
594
|
+
ref: o,
|
|
595
|
+
class: "tooltip-box",
|
|
596
|
+
style: N({
|
|
597
|
+
position: "fixed",
|
|
598
|
+
left: `${r.value}px`,
|
|
599
|
+
top: `${c.value}px`,
|
|
600
|
+
zIndex: 1e5,
|
|
601
|
+
pointerEvents: "none"
|
|
602
|
+
})
|
|
603
|
+
}, [
|
|
604
|
+
Q(f.$slots, "default")
|
|
605
|
+
], 4)) : ae("", !0)
|
|
606
|
+
], 512));
|
|
607
|
+
}
|
|
608
|
+
}), Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
609
|
+
__proto__: null,
|
|
610
|
+
default: kn
|
|
611
|
+
}, Symbol.toStringTag, { value: "Module" })), K = /* @__PURE__ */ Object.assign({ "./layout/ComponentRatio.vue": ze, "./resource/Image.vue": _n, "./ui/TooltipBox.vue": Rn }), j = {};
|
|
612
|
+
for (const e in K) {
|
|
613
|
+
const t = e.match(/\.\/(.+?)\/([^/]+)\.vue$/);
|
|
614
|
+
if (t && t[2]) {
|
|
615
|
+
const o = t[2];
|
|
616
|
+
j[o] = K[e].default;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const Ln = j.ComponentRatio, In = j.Image, Bn = j.TooltipBox, En = {
|
|
620
|
+
/**
|
|
621
|
+
* 注册所有组件
|
|
622
|
+
* @returns Vue 插件对象
|
|
623
|
+
*/
|
|
624
|
+
install(e) {
|
|
625
|
+
for (const [t, o] of Object.entries(j))
|
|
626
|
+
e.component(t, o);
|
|
627
|
+
console.log("所有组件已注册");
|
|
628
|
+
},
|
|
629
|
+
/**
|
|
630
|
+
* 注册特定组件
|
|
631
|
+
* @param componentName 组件名称
|
|
632
|
+
* @param component 组件对象
|
|
633
|
+
*/
|
|
634
|
+
registerComponent(e, t, o) {
|
|
635
|
+
e.component(t, o);
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
let te = class O {
|
|
639
|
+
static instance;
|
|
640
|
+
dbName;
|
|
641
|
+
dbVersion;
|
|
642
|
+
db;
|
|
643
|
+
constructor() {
|
|
644
|
+
this.dbName = "localforage", this.dbVersion = 1, this.db = null;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* 获取单例实例
|
|
648
|
+
*/
|
|
649
|
+
static getInstance() {
|
|
650
|
+
return O.instance || (O.instance = new O()), O.instance;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* 初始化数据库
|
|
654
|
+
*/
|
|
655
|
+
async init() {
|
|
656
|
+
return new Promise((t, o) => {
|
|
657
|
+
if (!("indexedDB" in window)) {
|
|
658
|
+
o(new Error("IndexedDB not supported"));
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const n = indexedDB.open(this.dbName, this.dbVersion);
|
|
662
|
+
n.onerror = () => {
|
|
663
|
+
o(new Error("Failed to open IndexedDB"));
|
|
664
|
+
}, n.onsuccess = () => {
|
|
665
|
+
this.db = n.result, t();
|
|
666
|
+
}, n.onupgradeneeded = (r) => {
|
|
667
|
+
const c = r.target.result;
|
|
668
|
+
c.objectStoreNames.contains("keyvaluepairs") || c.createObjectStore("keyvaluepairs", { autoIncrement: !0 });
|
|
669
|
+
};
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* 存储资源到缓存
|
|
674
|
+
* @param url 资源URL
|
|
675
|
+
* @param componentId 组件ID
|
|
676
|
+
* @param data 资源数据
|
|
677
|
+
*/
|
|
678
|
+
async storeResource(t, o) {
|
|
679
|
+
if (!this.db)
|
|
680
|
+
throw new Error("Database not initialized");
|
|
681
|
+
return new Promise((n, r) => {
|
|
682
|
+
const u = this.db.transaction(["keyvaluepairs"], "readwrite").objectStore("keyvaluepairs").put(o, t);
|
|
683
|
+
u.onsuccess = () => {
|
|
684
|
+
n();
|
|
685
|
+
}, u.onerror = () => {
|
|
686
|
+
r(new Error("Failed to store resource"));
|
|
687
|
+
};
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* 从缓存获取资源
|
|
692
|
+
* @param url 资源URL
|
|
693
|
+
*/
|
|
694
|
+
async getResource(t) {
|
|
695
|
+
if (!this.db)
|
|
696
|
+
throw new Error("Database not initialized");
|
|
697
|
+
return new Promise((o, n) => {
|
|
698
|
+
try {
|
|
699
|
+
const i = this.db.transaction(["keyvaluepairs"], "readonly").objectStore("keyvaluepairs").get(t);
|
|
700
|
+
i.onsuccess = () => {
|
|
701
|
+
o(i.result);
|
|
702
|
+
}, i.onerror = (u) => {
|
|
703
|
+
const s = u.target.error || new Error("Unknown IndexedDB error");
|
|
704
|
+
n(new Error(`Resource fetch failed: ${s.message}`));
|
|
705
|
+
};
|
|
706
|
+
} catch (r) {
|
|
707
|
+
n(
|
|
708
|
+
new Error(
|
|
709
|
+
`Operation setup failed: ${r instanceof Error ? r.message : String(r)}`
|
|
710
|
+
)
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* 检查资源是否存在
|
|
717
|
+
* @param url 资源URL
|
|
718
|
+
*/
|
|
719
|
+
async hasResource(t) {
|
|
720
|
+
if (!this.db)
|
|
721
|
+
throw new Error("Database not initialized");
|
|
722
|
+
return new Promise((o, n) => {
|
|
723
|
+
const i = this.db.transaction(["keyvaluepairs"], "readonly").objectStore("keyvaluepairs").count(t);
|
|
724
|
+
i.onsuccess = () => {
|
|
725
|
+
o(i.result > 0);
|
|
726
|
+
}, i.onerror = () => {
|
|
727
|
+
n(new Error("Failed to check resource"));
|
|
728
|
+
};
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* 清除所有缓存
|
|
733
|
+
*/
|
|
734
|
+
async clearAll() {
|
|
735
|
+
if (!this.db)
|
|
736
|
+
throw new Error("Database not initialized");
|
|
737
|
+
return new Promise((t, o) => {
|
|
738
|
+
const c = this.db.transaction(["keyvaluepairs"], "readwrite").objectStore("keyvaluepairs").clear();
|
|
739
|
+
c.onsuccess = () => {
|
|
740
|
+
t();
|
|
741
|
+
}, c.onerror = () => {
|
|
742
|
+
o(new Error("Failed to clear cache"));
|
|
743
|
+
};
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
async destroy() {
|
|
747
|
+
return new Promise((t, o) => {
|
|
748
|
+
if (!this.db) {
|
|
749
|
+
o(new Error("Database not initialized"));
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
this.db.close(), this.db = null;
|
|
753
|
+
const n = indexedDB.deleteDatabase(this.dbName);
|
|
754
|
+
n.onsuccess = () => {
|
|
755
|
+
O.instance = null, t();
|
|
756
|
+
}, n.onerror = () => {
|
|
757
|
+
o(new Error("Failed to delete database"));
|
|
758
|
+
}, n.onblocked = () => {
|
|
759
|
+
o(new Error("Database is blocked by other operations"));
|
|
760
|
+
};
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* 获取缓存统计信息
|
|
765
|
+
*/
|
|
766
|
+
async getCacheStats() {
|
|
767
|
+
if (!this.db)
|
|
768
|
+
throw new Error("Database not initialized");
|
|
769
|
+
return new Promise((t, o) => {
|
|
770
|
+
const c = this.db.transaction(["keyvaluepairs"], "readonly").objectStore("keyvaluepairs").count();
|
|
771
|
+
c.onsuccess = () => {
|
|
772
|
+
t({
|
|
773
|
+
count: c.result,
|
|
774
|
+
size: 0
|
|
775
|
+
// 在实际实现中需要计算实际大小
|
|
776
|
+
});
|
|
777
|
+
}, c.onerror = () => {
|
|
778
|
+
o(new Error("Failed to get cache stats"));
|
|
779
|
+
};
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
784
|
+
__proto__: null,
|
|
785
|
+
LCResourceCache: te
|
|
786
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
787
|
+
let On = class {
|
|
788
|
+
// 静态配置
|
|
789
|
+
static staticConfig = {
|
|
790
|
+
isProduction: !1,
|
|
791
|
+
isCache: !0
|
|
792
|
+
};
|
|
793
|
+
// 私有静态成员
|
|
794
|
+
static blobCache = /* @__PURE__ */ new Map();
|
|
795
|
+
static resourceCache = null;
|
|
796
|
+
/**
|
|
797
|
+
* 获取或创建资源缓存实例
|
|
798
|
+
*/
|
|
799
|
+
static async getResourceCache() {
|
|
800
|
+
if (!this.resourceCache) {
|
|
801
|
+
this.resourceCache = te.getInstance();
|
|
802
|
+
try {
|
|
803
|
+
await this.resourceCache.init();
|
|
804
|
+
} catch (t) {
|
|
805
|
+
throw this.resourceCache = null, t;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return this.resourceCache;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* 静态资源处理工具
|
|
812
|
+
*/
|
|
813
|
+
static useStatic(t, o, n = {}) {
|
|
814
|
+
const r = {}, c = [];
|
|
815
|
+
let i = "/components";
|
|
816
|
+
Object.keys(t).forEach((l) => {
|
|
817
|
+
r[l] = v("");
|
|
818
|
+
});
|
|
819
|
+
const u = this.staticConfig.isCache ? this.getResourceCache() : Promise.resolve(null);
|
|
820
|
+
return Object.entries(t).forEach(([l, w]) => {
|
|
821
|
+
const y = `${o}/${w}`, p = `${i}/${o}/assets/${w}`, m = n.noUrlList?.includes(l), f = async () => {
|
|
822
|
+
try {
|
|
823
|
+
const g = await u;
|
|
824
|
+
let d, a;
|
|
825
|
+
if (g && await g.hasResource(y)) {
|
|
826
|
+
const b = await g.getResource(y);
|
|
827
|
+
if (b) {
|
|
828
|
+
d = URL.createObjectURL(b), r[l].value = m ? d : `url('${d}')`;
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (this.staticConfig.isProduction && this.staticConfig.fetchFilter)
|
|
833
|
+
a = await (await this.staticConfig.fetchFilter(y)).blob();
|
|
834
|
+
else {
|
|
835
|
+
const b = await fetch(p);
|
|
836
|
+
if (!b.ok) throw new Error(`HTTP ${b.status}`);
|
|
837
|
+
a = await b.blob();
|
|
838
|
+
}
|
|
839
|
+
d = URL.createObjectURL(a), g && await g.storeResource(y, a), r[l].value = m ? d : `url('${d}')`;
|
|
840
|
+
} catch (g) {
|
|
841
|
+
console.error(`Failed to load resource ${w}:`, g), r[l].value = "";
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
c.push(f());
|
|
845
|
+
}), {
|
|
846
|
+
...r,
|
|
847
|
+
delay: Promise.all(c).then(() => ({ ...r }))
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* 清除所有缓存
|
|
852
|
+
*/
|
|
853
|
+
static async clearAllCache() {
|
|
854
|
+
this.resourceCache && (await this.resourceCache.clearAll(), this.blobCache.clear());
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* 销毁实例,释放资源
|
|
858
|
+
*/
|
|
859
|
+
static async destroy() {
|
|
860
|
+
this.resourceCache && (await this.resourceCache.destroy(), this.resourceCache = null);
|
|
861
|
+
for (const t of this.blobCache.values())
|
|
862
|
+
URL.revokeObjectURL(t);
|
|
863
|
+
this.blobCache.clear();
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
867
|
+
__proto__: null,
|
|
868
|
+
LCUtils: On
|
|
869
|
+
}, Symbol.toStringTag, { value: "Module" })), J = /* @__PURE__ */ Object.assign({ "./color/color.ts": $n, "./common/lcUtils.ts": Tn, "./resource/resourceCache.ts": Mn }), M = {};
|
|
870
|
+
for (const e in J) {
|
|
871
|
+
if (e === "./index.ts") continue;
|
|
872
|
+
const t = J[e];
|
|
873
|
+
for (const o of Object.keys(t))
|
|
874
|
+
o !== "default" && (M[o] = t[o]);
|
|
875
|
+
}
|
|
876
|
+
const Un = M.hexToRgb, zn = M.opacity, An = M.mixColor, Dn = M.lightenColor, Fn = M.ColorPlateSystem, Wn = M.LCUtils, Gn = M.LCResourceCache, Nn = {
|
|
877
|
+
useComponents: En,
|
|
878
|
+
...M,
|
|
879
|
+
...j
|
|
880
|
+
};
|
|
881
|
+
export {
|
|
882
|
+
Fn as ColorPlateSystem,
|
|
883
|
+
Ln as ComponentRatio,
|
|
884
|
+
In as Image,
|
|
885
|
+
Gn as LCResourceCache,
|
|
886
|
+
Wn as LCUtils,
|
|
887
|
+
Bn as TooltipBox,
|
|
888
|
+
Nn as default,
|
|
889
|
+
Un as hexToRgb,
|
|
890
|
+
Dn as lightenColor,
|
|
891
|
+
An as mixColor,
|
|
892
|
+
zn as opacity,
|
|
893
|
+
En as useComponents
|
|
894
|
+
};
|
package/lib/index.js.gz
ADDED
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const useComponents: {
|
|
2
|
+
/**
|
|
3
|
+
* 注册所有组件
|
|
4
|
+
* @returns Vue 插件对象
|
|
5
|
+
*/
|
|
6
|
+
install(app: any): void;
|
|
7
|
+
/**
|
|
8
|
+
* 注册特定组件
|
|
9
|
+
* @param componentName 组件名称
|
|
10
|
+
* @param component 组件对象
|
|
11
|
+
*/
|
|
12
|
+
registerComponent(app: any, componentName: string, component: any): void;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/plugins/components.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa;IACxB;;;OAGG;iBACU,GAAG;IAOhB;;;;OAIG;2BACoB,GAAG,iBAAiB,MAAM,aAAa,GAAG;CAGlE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type ColorList = Array<{
|
|
2
|
+
name: string;
|
|
3
|
+
value: string | Array<string>;
|
|
4
|
+
displayName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}>;
|
|
7
|
+
export interface TemplateToolsType {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export type DefaultPropsType<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends Function ? T[K] : () => T[K];
|
|
12
|
+
};
|
|
13
|
+
export interface StaticConfig {
|
|
14
|
+
isCache: boolean;
|
|
15
|
+
isProduction: boolean;
|
|
16
|
+
fetchFilter?: (moduleId: string) => Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export interface StaticOptions {
|
|
19
|
+
noUrlList?: string[];
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
import type { Ref } from 'vue';
|
|
23
|
+
export type StaticResources<T extends Record<string, string>> = {
|
|
24
|
+
[K in keyof T]: Ref<string>;
|
|
25
|
+
} & {
|
|
26
|
+
delay: Promise<{
|
|
27
|
+
[K in keyof T]: Ref<string>;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
export interface ColorMap {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
}
|
|
33
|
+
export interface UseColorReturn {
|
|
34
|
+
getColor: (key: string) => string;
|
|
35
|
+
getColorMap: (keys: string[]) => ColorMap;
|
|
36
|
+
}
|
|
37
|
+
export interface ComponentProps {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export interface CacheEntry {
|
|
41
|
+
data: Blob;
|
|
42
|
+
url: string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAGH,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAGF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAClD;AAGD,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI;KAC7D,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;CAC5B,GAAG;IACF,KAAK,EAAE,OAAO,CAAC;SACZ,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;KAC5B,CAAC,CAAC;CACJ,CAAC;AAGF,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAGD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,QAAQ,CAAC;CAC3C;AAGD,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const collectedUtils: Record<string, any>;
|
|
2
|
+
export default collectedUtils;
|
|
3
|
+
export declare const hexToRgb: any;
|
|
4
|
+
export declare const opacity: any;
|
|
5
|
+
export declare const mixColor: any;
|
|
6
|
+
export declare const lightenColor: any;
|
|
7
|
+
export declare const ColorPlateSystem: any;
|
|
8
|
+
export declare const LCUtils: any;
|
|
9
|
+
export declare const LCResourceCache: any;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;AAc/C,eAAe,cAAc,CAAC;AAG9B,eAAO,MAAM,QAAQ,KAA0B,CAAC;AAChD,eAAO,MAAM,OAAO,KAAyB,CAAC;AAC9C,eAAO,MAAM,QAAQ,KAA0B,CAAC;AAChD,eAAO,MAAM,YAAY,KAA8B,CAAC;AACxD,eAAO,MAAM,gBAAgB,KAAkC,CAAC;AAChE,eAAO,MAAM,OAAO,KAAyB,CAAC;AAC9C,eAAO,MAAM,eAAe,KAAiC,CAAC"}
|
package/lib/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.fixed-aspect-ratio[data-v-b6cd8c05]{transform-origin:0 0;position:absolute;left:50%;top:0;transition:transform .2s ease-in-out,width .2s ease-in-out,height .2s ease-in-out}.fixed-aspect-ratio.is-full[data-v-b6cd8c05]{left:0;top:0}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zxl-common-utils",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "A Vue 3 utility library with common tools, components and helpers",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"vue3",
|
|
9
|
+
"typescript",
|
|
10
|
+
"visualization",
|
|
11
|
+
"components",
|
|
12
|
+
"utils"
|
|
13
|
+
],
|
|
14
|
+
"author": "zxl",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "./lib/index.js",
|
|
17
|
+
"module": "./lib/index.js",
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./lib/index.js",
|
|
22
|
+
"require": "./lib/index.js",
|
|
23
|
+
"types": "./lib/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"lib"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "vite",
|
|
31
|
+
"build": "vue-tsc -b && vite build",
|
|
32
|
+
"preview": "vite preview",
|
|
33
|
+
"build:lib": "vite build --config vite.lib.config.ts",
|
|
34
|
+
"build:types": "vue-tsc --project tsconfig.lib.json",
|
|
35
|
+
"prepublishOnly": "npm run build:lib && npm run build:types",
|
|
36
|
+
"deploy": "node scripts/deploy.mjs",
|
|
37
|
+
"deploy:patch": "node scripts/deploy.mjs 0.0.1",
|
|
38
|
+
"deploy:minor": "node scripts/deploy.mjs 0.1.0",
|
|
39
|
+
"deploy:major": "node scripts/deploy.mjs 1.0.0",
|
|
40
|
+
"auto-export": "node scripts/runAutoExport.mjs",
|
|
41
|
+
"format": "prettier --write .",
|
|
42
|
+
"format:check": "prettier --check ."
|
|
43
|
+
},
|
|
44
|
+
"config": {
|
|
45
|
+
"git-tag-version": false
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"vue": "^3.5.24"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@types/lodash-es": "^4.17.12",
|
|
52
|
+
"lodash-es": "^4.18.1",
|
|
53
|
+
"vue": "^3.5.24"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^24.10.1",
|
|
57
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
58
|
+
"@vue/tsconfig": "^0.8.1",
|
|
59
|
+
"prettier": "^3.7.1",
|
|
60
|
+
"typescript": "~5.9.3",
|
|
61
|
+
"vite": "^7.2.4",
|
|
62
|
+
"vite-plugin-compression": "^0.5.1",
|
|
63
|
+
"vue-tsc": "^3.1.4"
|
|
64
|
+
}
|
|
65
|
+
}
|