cos-design 2.2.0 → 2.4.0
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/CHANGELOG.md +36 -0
- package/README.md +10 -1
- package/dist/components/charge/index.d.ts +11 -0
- package/dist/components/confetti/index.d.ts +15 -0
- package/dist/components/countdown/index.d.ts +13 -0
- package/dist/components/fireworks/index.d.ts +5 -1
- package/dist/components/flipCounter/index.d.ts +13 -0
- package/dist/components/glitchText/index.d.ts +15 -0
- package/dist/components/index.d.ts +11 -1
- package/dist/components/meteorRain/index.d.ts +9 -0
- package/dist/components/returnCity/index.d.ts +6 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +634 -345
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,113 +1,258 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { jsx as
|
|
3
|
-
import './index.css';var
|
|
4
|
-
canvasClock: "cos-canvasClock",
|
|
5
|
-
canvasTarget: "cos-canvasTarget"
|
|
6
|
-
},
|
|
7
|
-
let
|
|
8
|
-
e.clearRect(0, 0,
|
|
1
|
+
import { forwardRef as e, useCallback as t, useEffect as n, useImperativeHandle as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
import './index.css';var u = {
|
|
4
|
+
canvasClock: "cos-canvasClock-QvdV3",
|
|
5
|
+
canvasTarget: "cos-canvasTarget-x-odC"
|
|
6
|
+
}, d = ({ width: e = 400, height: r = 400 }) => {
|
|
7
|
+
let i = a(null), o = Math.min(e, r), s = o / 2 - 16, l = o / 2, d = t((e) => {
|
|
8
|
+
e.clearRect(0, 0, o, o), e.save(), e.translate(l, l), e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
|
|
9
9
|
for (let t = 0; t < 60; t++) {
|
|
10
|
-
let n = t / 60 * Math.PI * 2, r =
|
|
11
|
-
e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) *
|
|
10
|
+
let n = t / 60 * Math.PI * 2, r = s - (t % 5 == 0 ? 14 : 8);
|
|
11
|
+
e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * s, Math.sin(n) * s), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
|
|
12
12
|
}
|
|
13
|
-
e.fillStyle = "#111827", e.font = `bold ${Math.floor(
|
|
13
|
+
e.fillStyle = "#111827", e.font = `bold ${Math.floor(o / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
|
|
14
14
|
for (let t = 1; t <= 12; t++) {
|
|
15
|
-
let n = t / 12 * Math.PI * 2 - Math.PI / 2, r =
|
|
15
|
+
let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = s - 32;
|
|
16
16
|
e.fillText(String(t), Math.cos(n) * r, Math.sin(n) * r);
|
|
17
17
|
}
|
|
18
|
-
let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(),
|
|
18
|
+
let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), c = (t, n, r, i, a) => {
|
|
19
19
|
e.save(), e.rotate(t), e.beginPath(), e.moveTo(0, r), e.lineTo(n, 0), e.lineTo(0, -r), e.closePath(), e.fillStyle = i, e.shadowColor = a, e.shadowBlur = 4, e.fill(), e.restore();
|
|
20
|
-
},
|
|
21
|
-
|
|
20
|
+
}, u = (n + r / 60) / 12 * Math.PI * 2 - Math.PI / 2, d = (r + i / 60) / 60 * Math.PI * 2 - Math.PI / 2, f = (i + a / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
|
|
21
|
+
c(u, s * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), c(d, s * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), c(f, s * .85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), e.beginPath(), e.arc(0, 0, 5, 0, Math.PI * 2), e.fillStyle = "#111827", e.fill(), e.restore();
|
|
22
22
|
}, [
|
|
23
|
-
u,
|
|
24
23
|
l,
|
|
25
|
-
|
|
24
|
+
s,
|
|
25
|
+
o
|
|
26
26
|
]);
|
|
27
|
-
return
|
|
28
|
-
let e =
|
|
27
|
+
return n(() => {
|
|
28
|
+
let e = i.current;
|
|
29
29
|
if (!e) return;
|
|
30
30
|
let t = window.devicePixelRatio || 1;
|
|
31
|
-
e.width =
|
|
31
|
+
e.width = o * t, e.height = o * t;
|
|
32
32
|
let n = e.getContext("2d");
|
|
33
33
|
if (!n) return;
|
|
34
34
|
n.setTransform(t, 0, 0, t, 0, 0);
|
|
35
|
-
let r = 0,
|
|
36
|
-
d(n), r = requestAnimationFrame(
|
|
35
|
+
let r = 0, a = () => {
|
|
36
|
+
d(n), r = requestAnimationFrame(a);
|
|
37
37
|
};
|
|
38
|
-
return
|
|
39
|
-
}, [d,
|
|
40
|
-
className:
|
|
38
|
+
return a(), () => cancelAnimationFrame(r);
|
|
39
|
+
}, [d, o]), /* @__PURE__ */ c("div", {
|
|
40
|
+
className: u.canvasClock,
|
|
41
41
|
style: {
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
42
|
+
width: o,
|
|
43
|
+
height: o
|
|
44
44
|
},
|
|
45
|
-
children: /* @__PURE__ */
|
|
46
|
-
ref:
|
|
47
|
-
className:
|
|
45
|
+
children: /* @__PURE__ */ c("canvas", {
|
|
46
|
+
ref: i,
|
|
47
|
+
className: u.canvasTarget,
|
|
48
48
|
style: {
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
49
|
+
width: o,
|
|
50
|
+
height: o
|
|
51
51
|
}
|
|
52
52
|
})
|
|
53
53
|
});
|
|
54
|
-
},
|
|
55
|
-
chargeContainer: "cos-chargeContainer",
|
|
56
|
-
contrast: "cos-contrast",
|
|
57
|
-
hueRotate: "cos-hueRotate",
|
|
58
|
-
text: "cos-text",
|
|
59
|
-
moveUp: "cos-moveUp",
|
|
60
|
-
circle: "cos-circle",
|
|
61
|
-
circleRotate: "cos-circleRotate",
|
|
62
|
-
button: "cos-button"
|
|
63
|
-
},
|
|
64
|
-
let { initQuantity:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
}, f = {
|
|
55
|
+
chargeContainer: "cos-chargeContainer-4t9qo",
|
|
56
|
+
contrast: "cos-contrast-PNep9",
|
|
57
|
+
hueRotate: "cos-hueRotate-bMJ-k",
|
|
58
|
+
text: "cos-text-2k7eH",
|
|
59
|
+
moveUp: "cos-moveUp-1Vz9j",
|
|
60
|
+
circle: "cos-circle-m4vwX",
|
|
61
|
+
circleRotate: "cos-circleRotate-bgFw5",
|
|
62
|
+
button: "cos-button-myCst"
|
|
63
|
+
}, p = (e) => {
|
|
64
|
+
let { initQuantity: t = 0, value: r, onChange: i, autoCharge: s = !0, interval: u = 500, step: d = .01 } = e, p = r !== void 0, [m, h] = o(t), g = p ? r : m, _ = a(g);
|
|
65
|
+
n(() => {
|
|
66
|
+
_.current = g;
|
|
67
|
+
}, [g]), n(() => {
|
|
68
|
+
if (!s) return;
|
|
69
|
+
let e = window.setInterval(() => {
|
|
70
|
+
let e = Number((_.current + d).toFixed(2));
|
|
71
|
+
p ? i?.(e) : h(e);
|
|
72
|
+
}, u);
|
|
73
|
+
return () => clearInterval(e);
|
|
74
|
+
}, [
|
|
75
|
+
s,
|
|
76
|
+
u,
|
|
77
|
+
p,
|
|
78
|
+
i,
|
|
79
|
+
d
|
|
80
|
+
]);
|
|
81
|
+
let v = g ? g.toString().padEnd(4, "0") : "0";
|
|
82
|
+
return /* @__PURE__ */ c("div", {
|
|
83
|
+
className: f.chargeContainer,
|
|
84
|
+
children: /* @__PURE__ */ l("div", {
|
|
85
|
+
className: f.contrast,
|
|
74
86
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
className:
|
|
77
|
-
children: [
|
|
87
|
+
/* @__PURE__ */ l("div", {
|
|
88
|
+
className: f.text,
|
|
89
|
+
children: [v, "%"]
|
|
78
90
|
}),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */ i("div", { className: c.button })
|
|
91
|
+
/* @__PURE__ */ c("span", {}),
|
|
92
|
+
/* @__PURE__ */ c("span", {}),
|
|
93
|
+
/* @__PURE__ */ c("span", {}),
|
|
94
|
+
/* @__PURE__ */ c("span", {}),
|
|
95
|
+
/* @__PURE__ */ c("span", {}),
|
|
96
|
+
/* @__PURE__ */ c("span", {}),
|
|
97
|
+
/* @__PURE__ */ c("span", {}),
|
|
98
|
+
/* @__PURE__ */ c("span", {}),
|
|
99
|
+
/* @__PURE__ */ c("span", {}),
|
|
100
|
+
/* @__PURE__ */ c("span", {}),
|
|
101
|
+
/* @__PURE__ */ c("span", {}),
|
|
102
|
+
/* @__PURE__ */ c("span", {}),
|
|
103
|
+
/* @__PURE__ */ c("span", {}),
|
|
104
|
+
/* @__PURE__ */ c("span", {}),
|
|
105
|
+
/* @__PURE__ */ c("div", { className: f.circle }),
|
|
106
|
+
/* @__PURE__ */ c("div", { className: f.button })
|
|
96
107
|
]
|
|
97
108
|
})
|
|
98
109
|
});
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
canvas: "cos-canvas",
|
|
102
|
-
hint: "cos-hint"
|
|
103
|
-
},
|
|
110
|
+
}, m = {
|
|
111
|
+
confetti: "cos-confetti-MeNtU",
|
|
112
|
+
canvas: "cos-canvas-0T3Vs",
|
|
113
|
+
hint: "cos-hint-sGHEi"
|
|
114
|
+
}, h = [
|
|
115
|
+
"#ff6b6b",
|
|
116
|
+
"#ffd93d",
|
|
117
|
+
"#6bcb77",
|
|
118
|
+
"#4d96ff",
|
|
119
|
+
"#a66cff",
|
|
120
|
+
"#ff85c0",
|
|
121
|
+
"#38bdf8"
|
|
122
|
+
], g = () => h[Math.floor(Math.random() * h.length)], _ = (e, t, n) => {
|
|
123
|
+
let r = e / 2, i = t * .6;
|
|
124
|
+
return Array.from({ length: n }, () => {
|
|
125
|
+
let e = (Math.random() - .5) * Math.PI, t = Math.random() * 12 + 6;
|
|
126
|
+
return {
|
|
127
|
+
x: r + (Math.random() - .5) * 40,
|
|
128
|
+
y: i,
|
|
129
|
+
vx: Math.cos(e) * t,
|
|
130
|
+
vy: Math.sin(e) * t - Math.random() * 8,
|
|
131
|
+
rotation: Math.random() * 360,
|
|
132
|
+
rotationSpeed: (Math.random() - .5) * 12,
|
|
133
|
+
color: g(),
|
|
134
|
+
width: Math.random() * 8 + 4,
|
|
135
|
+
height: Math.random() * 6 + 3,
|
|
136
|
+
alpha: 1,
|
|
137
|
+
gravity: Math.random() * .15 + .12
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}, v = e(({ width: e = 800, height: i = 400, auto: o = !0, particleCount: s = 120 }, u) => {
|
|
141
|
+
let d = a(null), f = a([]), p = a(0), h = t(() => {
|
|
142
|
+
f.current.push(..._(e, i, s));
|
|
143
|
+
}, [
|
|
144
|
+
i,
|
|
145
|
+
s,
|
|
146
|
+
e
|
|
147
|
+
]);
|
|
148
|
+
return r(u, () => ({ burst: h }), [h]), n(() => {
|
|
149
|
+
let t = d.current;
|
|
150
|
+
if (!t) return;
|
|
151
|
+
let n = window.devicePixelRatio || 1;
|
|
152
|
+
t.width = e * n, t.height = i * n;
|
|
153
|
+
let r = t.getContext("2d");
|
|
154
|
+
if (!r) return;
|
|
155
|
+
r.setTransform(n, 0, 0, n, 0, 0), o && h();
|
|
156
|
+
let a = () => {
|
|
157
|
+
p.current = requestAnimationFrame(a), r.clearRect(0, 0, e, i), f.current = f.current.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += e.gravity, e.vx *= .99, e.rotation += e.rotationSpeed, e.alpha -= .008, e.alpha <= 0 || e.y > i + 20 ? !1 : (r.save(), r.translate(e.x, e.y), r.rotate(e.rotation * Math.PI / 180), r.globalAlpha = e.alpha, r.fillStyle = e.color, r.fillRect(-e.width / 2, -e.height / 2, e.width, e.height), r.restore(), !0)));
|
|
158
|
+
};
|
|
159
|
+
return a(), () => cancelAnimationFrame(p.current);
|
|
160
|
+
}, [
|
|
161
|
+
o,
|
|
162
|
+
h,
|
|
163
|
+
i,
|
|
164
|
+
e
|
|
165
|
+
]), /* @__PURE__ */ l("div", {
|
|
166
|
+
className: m.confetti,
|
|
167
|
+
style: {
|
|
168
|
+
width: e,
|
|
169
|
+
height: i
|
|
170
|
+
},
|
|
171
|
+
children: [/* @__PURE__ */ c("canvas", {
|
|
172
|
+
ref: d,
|
|
173
|
+
className: m.canvas,
|
|
174
|
+
style: {
|
|
175
|
+
width: e,
|
|
176
|
+
height: i
|
|
177
|
+
},
|
|
178
|
+
onClick: h
|
|
179
|
+
}), /* @__PURE__ */ c("p", {
|
|
180
|
+
className: m.hint,
|
|
181
|
+
children: "点击画布再次喷射"
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
v.displayName = "Confetti";
|
|
186
|
+
var y = {
|
|
187
|
+
countdown: "cos-countdown-5ZKKP",
|
|
188
|
+
unit: "cos-unit-dth8N",
|
|
189
|
+
value: "cos-value-yVzcP",
|
|
190
|
+
label: "cos-label-pAMEs",
|
|
191
|
+
ended: "cos-ended-c0dsD",
|
|
192
|
+
pulse: "cos-pulse-krQd-"
|
|
193
|
+
}, b = (e) => e instanceof Date ? e.getTime() : typeof e == "number" ? e : new Date(e).getTime(), x = (e) => {
|
|
194
|
+
let t = Math.max(0, e - Date.now()), n = Math.floor(t / 1e3);
|
|
195
|
+
return {
|
|
196
|
+
total: t,
|
|
197
|
+
days: Math.floor(n / 86400),
|
|
198
|
+
hours: Math.floor(n % 86400 / 3600),
|
|
199
|
+
minutes: Math.floor(n % 3600 / 60),
|
|
200
|
+
seconds: n % 60
|
|
201
|
+
};
|
|
202
|
+
}, S = [
|
|
203
|
+
{
|
|
204
|
+
key: "days",
|
|
205
|
+
label: "天"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "hours",
|
|
209
|
+
label: "时"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
key: "minutes",
|
|
213
|
+
label: "分"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: "seconds",
|
|
217
|
+
label: "秒"
|
|
218
|
+
}
|
|
219
|
+
], C = ({ targetDate: e, onEnd: t, showLabels: r = !0, color: s = "#f472b6" }) => {
|
|
220
|
+
let u = i(() => b(e), [e]), [, d] = o(0), f = a(!1), p = x(u);
|
|
221
|
+
return n(() => {
|
|
222
|
+
f.current = !1;
|
|
223
|
+
let e = window.setInterval(() => d((e) => e + 1), 1e3);
|
|
224
|
+
return () => clearInterval(e);
|
|
225
|
+
}, [u]), n(() => {
|
|
226
|
+
p.total <= 0 && !f.current && (f.current = !0, t?.());
|
|
227
|
+
}, [p.total, t]), /* @__PURE__ */ l("div", {
|
|
228
|
+
className: y.countdown,
|
|
229
|
+
style: { "--countdown-color": s },
|
|
230
|
+
children: [S.map(({ key: e, label: t }) => /* @__PURE__ */ l("div", {
|
|
231
|
+
className: y.unit,
|
|
232
|
+
children: [/* @__PURE__ */ c("div", {
|
|
233
|
+
className: y.value,
|
|
234
|
+
children: String(p[e]).padStart(2, "0")
|
|
235
|
+
}), r && /* @__PURE__ */ c("span", {
|
|
236
|
+
className: y.label,
|
|
237
|
+
children: t
|
|
238
|
+
})]
|
|
239
|
+
}, e)), p.total <= 0 && /* @__PURE__ */ c("p", {
|
|
240
|
+
className: y.ended,
|
|
241
|
+
children: "时间到!"
|
|
242
|
+
})]
|
|
243
|
+
});
|
|
244
|
+
}, w = {
|
|
245
|
+
fireworks: "cos-fireworks-fsSqL",
|
|
246
|
+
canvas: "cos-canvas-spL8G",
|
|
247
|
+
hint: "cos-hint-5XDRH"
|
|
248
|
+
}, T = [
|
|
104
249
|
"#ff6b6b",
|
|
105
250
|
"#ffd93d",
|
|
106
251
|
"#6bcb77",
|
|
107
252
|
"#4d96ff",
|
|
108
253
|
"#a66cff",
|
|
109
254
|
"#ff85c0"
|
|
110
|
-
],
|
|
255
|
+
], E = .12, D = 240, O = () => T[Math.floor(Math.random() * T.length)], k = (e, t, n) => {
|
|
111
256
|
let r = 60 + Math.floor(Math.random() * 30);
|
|
112
257
|
return Array.from({ length: r }, () => {
|
|
113
258
|
let r = Math.random() * Math.PI * 2, i = Math.random() * 4 + 2;
|
|
@@ -117,206 +262,340 @@ import './index.css';var o = {
|
|
|
117
262
|
vx: Math.cos(r) * i,
|
|
118
263
|
vy: Math.sin(r) * i,
|
|
119
264
|
alpha: 1,
|
|
120
|
-
color: Math.random() > .3 ? n :
|
|
265
|
+
color: Math.random() > .3 ? n : O(),
|
|
121
266
|
decay: Math.random() * .015 + .01
|
|
122
267
|
};
|
|
123
268
|
});
|
|
124
|
-
},
|
|
125
|
-
let
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
x:
|
|
129
|
-
y:
|
|
269
|
+
}, A = e(({ width: e = 800, height: i = 500, auto: o = !0 }, s) => {
|
|
270
|
+
let u = a(null), d = a([]), f = a(0), p = t((t) => {
|
|
271
|
+
let n = t ?? Math.random() * e * .6 + e * .2;
|
|
272
|
+
d.current.push({
|
|
273
|
+
x: n,
|
|
274
|
+
y: i,
|
|
130
275
|
vy: -(Math.random() * 4 + 6),
|
|
131
|
-
targetY: Math.random() *
|
|
132
|
-
color:
|
|
276
|
+
targetY: Math.random() * i * .35 + i * .15,
|
|
277
|
+
color: O(),
|
|
133
278
|
exploded: !1,
|
|
134
|
-
particles: []
|
|
279
|
+
particles: [],
|
|
280
|
+
age: 0
|
|
135
281
|
});
|
|
136
|
-
}, [
|
|
137
|
-
return
|
|
138
|
-
let
|
|
139
|
-
if (!
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
let
|
|
143
|
-
if (!
|
|
144
|
-
|
|
145
|
-
let
|
|
146
|
-
|
|
282
|
+
}, [i, e]);
|
|
283
|
+
return r(s, () => ({ launch: p }), [p]), n(() => {
|
|
284
|
+
let t = u.current;
|
|
285
|
+
if (!t) return;
|
|
286
|
+
let n = window.devicePixelRatio || 1;
|
|
287
|
+
t.width = e * n, t.height = i * n;
|
|
288
|
+
let r = t.getContext("2d");
|
|
289
|
+
if (!r) return;
|
|
290
|
+
r.setTransform(n, 0, 0, n, 0, 0);
|
|
291
|
+
let a = 0, s = () => {
|
|
292
|
+
f.current = requestAnimationFrame(s), r.fillStyle = "rgb(15 23 42 / 25%)", r.fillRect(0, 0, e, i), o && Math.random() < .03 && p(), d.current = d.current.filter((e) => {
|
|
293
|
+
if (!e.exploded) {
|
|
294
|
+
e.age += 1, e.y += e.vy, e.vy += E, r.beginPath(), r.arc(e.x, e.y, 2.5, 0, Math.PI * 2), r.fillStyle = e.color, r.fill();
|
|
295
|
+
let t = e.vy >= 0, n = e.y <= e.targetY, i = e.y < 0, a = e.age >= D;
|
|
296
|
+
return (t || n || i || a) && (e.exploded = !0, e.particles = k(e.x, e.y, e.color)), !0;
|
|
297
|
+
}
|
|
298
|
+
return e.particles = e.particles.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += .06, e.alpha -= e.decay, e.alpha <= 0 ? !1 : (r.beginPath(), r.arc(e.x, e.y, 2, 0, Math.PI * 2), r.fillStyle = e.color, r.globalAlpha = e.alpha, r.fill(), r.globalAlpha = 1, !0))), e.particles.length > 0;
|
|
299
|
+
});
|
|
147
300
|
};
|
|
148
|
-
return
|
|
149
|
-
cancelAnimationFrame(
|
|
301
|
+
return s(), o && (a = window.setInterval(() => p(), 1200)), () => {
|
|
302
|
+
cancelAnimationFrame(f.current), clearInterval(a);
|
|
150
303
|
};
|
|
151
304
|
}, [
|
|
152
|
-
s,
|
|
153
305
|
o,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
306
|
+
i,
|
|
307
|
+
p,
|
|
308
|
+
e
|
|
309
|
+
]), /* @__PURE__ */ l("div", {
|
|
310
|
+
className: w.fireworks,
|
|
158
311
|
style: {
|
|
159
|
-
width:
|
|
160
|
-
height:
|
|
312
|
+
width: e,
|
|
313
|
+
height: i
|
|
161
314
|
},
|
|
162
|
-
children: [/* @__PURE__ */
|
|
163
|
-
ref:
|
|
164
|
-
className:
|
|
315
|
+
children: [/* @__PURE__ */ c("canvas", {
|
|
316
|
+
ref: u,
|
|
317
|
+
className: w.canvas,
|
|
165
318
|
style: {
|
|
166
|
-
width:
|
|
167
|
-
height:
|
|
319
|
+
width: e,
|
|
320
|
+
height: i
|
|
168
321
|
},
|
|
169
322
|
onClick: (e) => {
|
|
170
323
|
let t = e.currentTarget.getBoundingClientRect();
|
|
171
|
-
|
|
324
|
+
p(e.clientX - t.left);
|
|
172
325
|
}
|
|
173
|
-
}), /* @__PURE__ */
|
|
174
|
-
className:
|
|
326
|
+
}), /* @__PURE__ */ c("p", {
|
|
327
|
+
className: w.hint,
|
|
175
328
|
children: "点击画布燃放烟花"
|
|
176
329
|
})]
|
|
177
330
|
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
331
|
+
});
|
|
332
|
+
A.displayName = "Fireworks";
|
|
333
|
+
var j = {
|
|
334
|
+
flipCounter: "cos-flipCounter-3LuI0",
|
|
335
|
+
digit: "cos-digit-yJRPy",
|
|
336
|
+
digitCard: "cos-digitCard-zZUzt",
|
|
337
|
+
staticTop: "cos-staticTop-aLQcm",
|
|
338
|
+
staticBottom: "cos-staticBottom-9y0gu",
|
|
339
|
+
flap: "cos-flap-i3YKR",
|
|
340
|
+
flapTop: "cos-flapTop-70z-k",
|
|
341
|
+
flapBottom: "cos-flapBottom-zhMZe",
|
|
342
|
+
isFlipping: "cos-isFlipping-EVEdI",
|
|
343
|
+
"fold-top": "cos-fold-top-v-6XJ",
|
|
344
|
+
"unfold-bottom": "cos-unfold-bottom-e2gzU"
|
|
345
|
+
}, M = (e, t) => Math.max(0, Math.floor(e)).toString().padStart(t, "0").slice(-t), N = ({ digit: e, color: t, duration: r }) => {
|
|
346
|
+
let i = a(e), [u, d] = o(!1), [f, p] = o(e);
|
|
347
|
+
n(() => {
|
|
348
|
+
if (e === i.current) return;
|
|
349
|
+
p(i.current), d(!0), i.current = e;
|
|
350
|
+
let t = window.setTimeout(() => d(!1), r);
|
|
351
|
+
return () => clearTimeout(t);
|
|
352
|
+
}, [e, r]);
|
|
353
|
+
let m = u ? f : e;
|
|
354
|
+
return /* @__PURE__ */ c("div", {
|
|
355
|
+
className: j.digit,
|
|
356
|
+
style: {
|
|
357
|
+
"--flip-color": t,
|
|
358
|
+
"--flip-duration": `${r}ms`
|
|
359
|
+
},
|
|
360
|
+
children: /* @__PURE__ */ l("div", {
|
|
361
|
+
className: `${j.digitCard} ${u ? j.isFlipping : ""}`,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ c("div", {
|
|
364
|
+
className: j.staticTop,
|
|
365
|
+
children: /* @__PURE__ */ c("span", { children: m })
|
|
366
|
+
}),
|
|
367
|
+
/* @__PURE__ */ c("div", {
|
|
368
|
+
className: j.staticBottom,
|
|
369
|
+
children: /* @__PURE__ */ c("span", { children: m })
|
|
370
|
+
}),
|
|
371
|
+
u && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
|
|
372
|
+
className: `${j.flap} ${j.flapTop}`,
|
|
373
|
+
children: /* @__PURE__ */ c("span", { children: f })
|
|
374
|
+
}), /* @__PURE__ */ c("div", {
|
|
375
|
+
className: `${j.flap} ${j.flapBottom}`,
|
|
376
|
+
children: /* @__PURE__ */ c("span", { children: e })
|
|
377
|
+
})] })
|
|
378
|
+
]
|
|
379
|
+
})
|
|
380
|
+
});
|
|
381
|
+
}, P = ({ value: e, digits: t = 4, color: n = "#38bdf8", duration: r = 600 }) => {
|
|
382
|
+
let i = M(e, t).split("");
|
|
383
|
+
return /* @__PURE__ */ c("div", {
|
|
384
|
+
className: j.flipCounter,
|
|
385
|
+
children: i.map((e, t) => /* @__PURE__ */ c(N, {
|
|
386
|
+
digit: e,
|
|
387
|
+
color: n,
|
|
388
|
+
duration: r
|
|
389
|
+
}, t))
|
|
390
|
+
});
|
|
391
|
+
}, F = {
|
|
392
|
+
glitchText: "cos-glitchText-dZ-sR",
|
|
393
|
+
text: "cos-text-JsPHN",
|
|
394
|
+
"glitch-1": "cos-glitch-1-s9pqH",
|
|
395
|
+
"glitch-2": "cos-glitch-2-GhFB-"
|
|
396
|
+
}, I = ({ text: e = "GLITCH", color: t = "#f8fafc", glitchColor1: n = "#ff00de", glitchColor2: r = "#00f0ff", fontSize: i = 64 }) => /* @__PURE__ */ c("div", {
|
|
397
|
+
className: F.glitchText,
|
|
398
|
+
children: /* @__PURE__ */ c("h1", {
|
|
399
|
+
className: F.text,
|
|
400
|
+
"data-text": e,
|
|
401
|
+
style: {
|
|
402
|
+
fontSize: i,
|
|
403
|
+
"--glitch-color": t,
|
|
404
|
+
"--glitch-c1": n,
|
|
405
|
+
"--glitch-c2": r
|
|
406
|
+
},
|
|
407
|
+
children: e
|
|
408
|
+
})
|
|
409
|
+
}), L = {
|
|
410
|
+
matrixRain: "cos-matrixRain-qg9HC",
|
|
411
|
+
canvas: "cos-canvas--AvpG",
|
|
412
|
+
overlay: "cos-overlay-knj3b",
|
|
413
|
+
title: "cos-title-sDfhs",
|
|
414
|
+
flicker: "cos-flicker-smHxl",
|
|
415
|
+
subtitle: "cos-subtitle-CWheW"
|
|
416
|
+
}, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", z = ({ width: e = 800, height: t = 500, density: r = .6, color: i = "#00ff41" }) => {
|
|
417
|
+
let o = a(null);
|
|
418
|
+
return n(() => {
|
|
419
|
+
let n = o.current;
|
|
420
|
+
if (!n) return;
|
|
421
|
+
let a = window.devicePixelRatio || 1;
|
|
422
|
+
n.width = e * a, n.height = t * a;
|
|
423
|
+
let s = n.getContext("2d");
|
|
424
|
+
if (!s) return;
|
|
425
|
+
s.setTransform(a, 0, 0, a, 0, 0);
|
|
426
|
+
let c = Math.floor(e / 16 * r), l = Array.from({ length: c }, () => Math.random() * -50), u = 0, d = () => {
|
|
427
|
+
s.fillStyle = "rgb(0 0 0 / 8%)", s.fillRect(0, 0, e, t), s.fillStyle = i, s.font = "16px monospace", l.forEach((e, n) => {
|
|
428
|
+
let a = R[Math.floor(Math.random() * 53)], o = n / r * 16;
|
|
429
|
+
s.fillStyle = i, s.fillText(a, o, e * 16), e * 16 > t && Math.random() > .975 && (l[n] = 0), l[n] += 1;
|
|
199
430
|
}), u = requestAnimationFrame(d);
|
|
200
431
|
};
|
|
201
432
|
return d(), () => cancelAnimationFrame(u);
|
|
202
433
|
}, [
|
|
203
|
-
|
|
204
|
-
o,
|
|
434
|
+
i,
|
|
205
435
|
r,
|
|
436
|
+
t,
|
|
206
437
|
e
|
|
207
|
-
]), /* @__PURE__ */
|
|
208
|
-
className:
|
|
438
|
+
]), /* @__PURE__ */ l("div", {
|
|
439
|
+
className: L.matrixRain,
|
|
209
440
|
style: {
|
|
210
441
|
width: e,
|
|
211
|
-
height:
|
|
442
|
+
height: t
|
|
212
443
|
},
|
|
213
|
-
children: [/* @__PURE__ */
|
|
214
|
-
ref:
|
|
215
|
-
className:
|
|
444
|
+
children: [/* @__PURE__ */ c("canvas", {
|
|
445
|
+
ref: o,
|
|
446
|
+
className: L.canvas,
|
|
216
447
|
style: {
|
|
217
448
|
width: e,
|
|
218
|
-
height:
|
|
449
|
+
height: t
|
|
219
450
|
}
|
|
220
|
-
}), /* @__PURE__ */
|
|
221
|
-
className:
|
|
222
|
-
children: [/* @__PURE__ */
|
|
223
|
-
className:
|
|
451
|
+
}), /* @__PURE__ */ l("div", {
|
|
452
|
+
className: L.overlay,
|
|
453
|
+
children: [/* @__PURE__ */ c("h2", {
|
|
454
|
+
className: L.title,
|
|
224
455
|
children: "MATRIX"
|
|
225
|
-
}), /* @__PURE__ */
|
|
226
|
-
className:
|
|
456
|
+
}), /* @__PURE__ */ c("p", {
|
|
457
|
+
className: L.subtitle,
|
|
227
458
|
children: "数字雨效果"
|
|
228
459
|
})]
|
|
229
460
|
})]
|
|
230
461
|
});
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
462
|
+
}, B = {
|
|
463
|
+
meteorRain: "cos-meteorRain-v8RNI",
|
|
464
|
+
canvas: "cos-canvas-hyFMr"
|
|
465
|
+
}, V = ({ width: e = 800, height: t = 500, meteorCount: r = 8 }) => {
|
|
466
|
+
let i = a(null), o = a([]), s = a(0);
|
|
467
|
+
return n(() => {
|
|
468
|
+
o.current = Array.from({ length: r }, () => ({
|
|
469
|
+
x: Math.random() * e,
|
|
470
|
+
y: Math.random() * t * .5,
|
|
471
|
+
length: Math.random() * 60 + 40,
|
|
472
|
+
speed: Math.random() * 6 + 4,
|
|
473
|
+
opacity: Math.random() * .5 + .3
|
|
474
|
+
}));
|
|
475
|
+
}, [
|
|
476
|
+
t,
|
|
477
|
+
r,
|
|
478
|
+
e
|
|
479
|
+
]), n(() => {
|
|
480
|
+
let n = i.current;
|
|
481
|
+
if (!n) return;
|
|
482
|
+
let r = window.devicePixelRatio || 1;
|
|
483
|
+
n.width = e * r, n.height = t * r;
|
|
484
|
+
let a = n.getContext("2d");
|
|
485
|
+
if (!a) return;
|
|
486
|
+
a.setTransform(r, 0, 0, r, 0, 0);
|
|
487
|
+
let c = () => {
|
|
488
|
+
s.current = requestAnimationFrame(c), a.fillStyle = "rgb(15 23 42 / 15%)", a.fillRect(0, 0, e, t), o.current.forEach((n) => {
|
|
489
|
+
n.x += n.speed, n.y += n.speed * .6, (n.x > e + n.length || n.y > t + n.length) && (n.x = -n.length, n.y = Math.random() * t * .4, n.length = Math.random() * 60 + 40, n.speed = Math.random() * 6 + 4, n.opacity = Math.random() * .5 + .3);
|
|
490
|
+
let r = a.createLinearGradient(n.x, n.y, n.x - n.length, n.y - n.length * .6);
|
|
491
|
+
r.addColorStop(0, `rgb(255 255 255 / ${n.opacity})`), r.addColorStop(1, "rgb(255 255 255 / 0)"), a.beginPath(), a.strokeStyle = r, a.lineWidth = 2, a.moveTo(n.x, n.y), a.lineTo(n.x - n.length, n.y - n.length * .6), a.stroke();
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
return c(), () => cancelAnimationFrame(s.current);
|
|
495
|
+
}, [t, e]), /* @__PURE__ */ c("div", {
|
|
496
|
+
className: B.meteorRain,
|
|
497
|
+
style: {
|
|
498
|
+
width: e,
|
|
499
|
+
height: t
|
|
500
|
+
},
|
|
501
|
+
children: /* @__PURE__ */ c("canvas", {
|
|
502
|
+
ref: i,
|
|
503
|
+
className: B.canvas,
|
|
504
|
+
style: {
|
|
505
|
+
width: e,
|
|
506
|
+
height: t
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
|
+
}, H = {
|
|
511
|
+
neonText: "cos-neonText-JMP7i",
|
|
512
|
+
text: "cos-text-GTO-0",
|
|
513
|
+
flicker: "cos-flicker-nXceV",
|
|
514
|
+
"neon-flicker": "cos-neon-flicker-uDkmM",
|
|
515
|
+
reflection: "cos-reflection-aEYj6"
|
|
516
|
+
}, U = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ l("div", {
|
|
517
|
+
className: H.neonText,
|
|
518
|
+
children: [/* @__PURE__ */ c("h1", {
|
|
519
|
+
className: `${H.text} ${r ? H.flicker : ""}`,
|
|
241
520
|
style: {
|
|
242
521
|
fontSize: n,
|
|
243
522
|
"--neon-color": t
|
|
244
523
|
},
|
|
245
524
|
children: e
|
|
246
|
-
}), /* @__PURE__ */
|
|
247
|
-
className:
|
|
525
|
+
}), /* @__PURE__ */ c("p", {
|
|
526
|
+
className: H.reflection,
|
|
248
527
|
style: {
|
|
249
528
|
fontSize: n * .35,
|
|
250
529
|
color: t
|
|
251
530
|
},
|
|
252
531
|
children: e
|
|
253
532
|
})]
|
|
254
|
-
}),
|
|
255
|
-
particleNetwork: "cos-particleNetwork",
|
|
256
|
-
canvas: "cos-canvas",
|
|
257
|
-
hint: "cos-hint"
|
|
258
|
-
},
|
|
259
|
-
let u =
|
|
533
|
+
}), W = {
|
|
534
|
+
particleNetwork: "cos-particleNetwork-GSZq-",
|
|
535
|
+
canvas: "cos-canvas-E-BGP",
|
|
536
|
+
hint: "cos-hint-LEO5o"
|
|
537
|
+
}, G = ({ width: e = 800, height: r = 500, particleCount: i = 60, linkDistance: o = 120, color: s = "#38bdf8" }) => {
|
|
538
|
+
let u = a(null), d = a([]), f = a({
|
|
260
539
|
x: -1e3,
|
|
261
540
|
y: -1e3
|
|
262
|
-
}), p =
|
|
263
|
-
d.current = Array.from({ length:
|
|
264
|
-
x: Math.random() *
|
|
265
|
-
y: Math.random() *
|
|
541
|
+
}), p = t(() => {
|
|
542
|
+
d.current = Array.from({ length: i }, () => ({
|
|
543
|
+
x: Math.random() * e,
|
|
544
|
+
y: Math.random() * r,
|
|
266
545
|
vx: (Math.random() - .5) * 1.2,
|
|
267
546
|
vy: (Math.random() - .5) * 1.2,
|
|
268
547
|
radius: Math.random() * 2 + 1
|
|
269
548
|
}));
|
|
270
549
|
}, [
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
550
|
+
r,
|
|
551
|
+
i,
|
|
552
|
+
e
|
|
274
553
|
]);
|
|
275
|
-
return
|
|
554
|
+
return n(() => {
|
|
276
555
|
p();
|
|
277
|
-
}, [p]),
|
|
278
|
-
let
|
|
279
|
-
if (!
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
let
|
|
283
|
-
if (!
|
|
284
|
-
|
|
285
|
-
let
|
|
286
|
-
|
|
287
|
-
let
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
let
|
|
291
|
-
Math.sqrt(
|
|
556
|
+
}, [p]), n(() => {
|
|
557
|
+
let t = u.current;
|
|
558
|
+
if (!t) return;
|
|
559
|
+
let n = window.devicePixelRatio || 1;
|
|
560
|
+
t.width = e * n, t.height = r * n;
|
|
561
|
+
let i = t.getContext("2d");
|
|
562
|
+
if (!i) return;
|
|
563
|
+
i.setTransform(n, 0, 0, n, 0, 0);
|
|
564
|
+
let a = 0, c = () => {
|
|
565
|
+
i.fillStyle = "#0f172a", i.fillRect(0, 0, e, r);
|
|
566
|
+
let t = d.current, n = f.current;
|
|
567
|
+
t.forEach((t) => {
|
|
568
|
+
t.x += t.vx, t.y += t.vy, (t.x < 0 || t.x > e) && (t.vx *= -1), (t.y < 0 || t.y > r) && (t.vy *= -1);
|
|
569
|
+
let i = n.x - t.x, a = n.y - t.y;
|
|
570
|
+
Math.sqrt(i * i + a * a) < 150 && (t.vx -= i * 3e-4, t.vy -= a * 3e-4);
|
|
292
571
|
});
|
|
293
|
-
for (let
|
|
294
|
-
let
|
|
295
|
-
|
|
572
|
+
for (let e = 0; e < t.length; e++) for (let n = e + 1; n < t.length; n++) {
|
|
573
|
+
let r = t[e].x - t[n].x, a = t[e].y - t[n].y, c = Math.sqrt(r * r + a * a);
|
|
574
|
+
c < o && (i.beginPath(), i.moveTo(t[e].x, t[e].y), i.lineTo(t[n].x, t[n].y), i.strokeStyle = s, i.globalAlpha = 1 - c / o, i.lineWidth = .8, i.stroke(), i.globalAlpha = 1);
|
|
296
575
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}),
|
|
576
|
+
t.forEach((e) => {
|
|
577
|
+
i.beginPath(), i.arc(e.x, e.y, e.radius, 0, Math.PI * 2), i.fillStyle = s, i.fill();
|
|
578
|
+
}), a = requestAnimationFrame(c);
|
|
300
579
|
};
|
|
301
|
-
return
|
|
580
|
+
return c(), () => cancelAnimationFrame(a);
|
|
302
581
|
}, [
|
|
303
|
-
|
|
304
|
-
|
|
582
|
+
s,
|
|
583
|
+
r,
|
|
305
584
|
p,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
]), /* @__PURE__ */
|
|
309
|
-
className:
|
|
585
|
+
o,
|
|
586
|
+
e
|
|
587
|
+
]), /* @__PURE__ */ l("div", {
|
|
588
|
+
className: W.particleNetwork,
|
|
310
589
|
style: {
|
|
311
|
-
width:
|
|
312
|
-
height:
|
|
590
|
+
width: e,
|
|
591
|
+
height: r
|
|
313
592
|
},
|
|
314
|
-
children: [/* @__PURE__ */
|
|
593
|
+
children: [/* @__PURE__ */ c("canvas", {
|
|
315
594
|
ref: u,
|
|
316
|
-
className:
|
|
595
|
+
className: W.canvas,
|
|
317
596
|
style: {
|
|
318
|
-
width:
|
|
319
|
-
height:
|
|
597
|
+
width: e,
|
|
598
|
+
height: r
|
|
320
599
|
},
|
|
321
600
|
onMouseMove: (e) => {
|
|
322
601
|
let t = e.currentTarget.getBoundingClientRect();
|
|
@@ -331,54 +610,64 @@ import './index.css';var o = {
|
|
|
331
610
|
y: -1e3
|
|
332
611
|
};
|
|
333
612
|
}
|
|
334
|
-
}), /* @__PURE__ */
|
|
335
|
-
className:
|
|
613
|
+
}), /* @__PURE__ */ c("p", {
|
|
614
|
+
className: W.hint,
|
|
336
615
|
children: "移动鼠标与粒子互动"
|
|
337
616
|
})]
|
|
338
617
|
});
|
|
339
|
-
},
|
|
340
|
-
returnCityContainer: "cos-returnCityContainer",
|
|
341
|
-
star: "cos-star",
|
|
342
|
-
glassWrap: "cos-glassWrap",
|
|
343
|
-
rotate: "cos-rotate",
|
|
344
|
-
glassItem: "cos-glassItem"
|
|
345
|
-
},
|
|
346
|
-
let
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
618
|
+
}, K = {
|
|
619
|
+
returnCityContainer: "cos-returnCityContainer-6XTxj",
|
|
620
|
+
star: "cos-star-a59Dx",
|
|
621
|
+
glassWrap: "cos-glassWrap-golMO",
|
|
622
|
+
rotate: "cos-rotate-7X9Jj",
|
|
623
|
+
glassItem: "cos-glassItem-OwlFI"
|
|
624
|
+
}, q = ({ starCount: e, glassCount: t = 6, glassRadius: r = 150 }) => {
|
|
625
|
+
let i = a(null), o = a(null);
|
|
626
|
+
return n(() => {
|
|
627
|
+
let n = i.current, a = o.current;
|
|
628
|
+
if (!n || !a) return;
|
|
629
|
+
let s = [], c = [], l = [], u = e ?? Math.floor(document.documentElement.clientWidth / 20);
|
|
630
|
+
for (let e = 0; e < u; e++) {
|
|
631
|
+
let e = window.setTimeout(() => {
|
|
632
|
+
let e = document.createElement("div");
|
|
633
|
+
e.className = K.star;
|
|
634
|
+
let t = document.body.clientWidth, r = document.body.clientHeight;
|
|
635
|
+
e.style.top = `${Math.random() * r}px`, e.style.left = `${Math.random() * t}px`, n.append(e), c.push(e);
|
|
636
|
+
}, Math.random() * 2e3);
|
|
637
|
+
s.push(e);
|
|
638
|
+
}
|
|
639
|
+
for (let e = 0; e < t; e++) {
|
|
356
640
|
let n = document.createElement("div");
|
|
357
|
-
n.className =
|
|
641
|
+
n.className = K.glassItem, n.style.transform = `rotateY(${360 / t * e}deg) translateZ(${r}px)`, a.appendChild(n), l.push(n);
|
|
642
|
+
let i = window.setTimeout(() => {
|
|
358
643
|
n.style.top = "0px", n.style.opacity = "1";
|
|
359
|
-
},
|
|
644
|
+
}, e * 300);
|
|
645
|
+
s.push(i);
|
|
360
646
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
647
|
+
return () => {
|
|
648
|
+
s.forEach(clearTimeout), c.forEach((e) => e.remove()), l.forEach((e) => e.remove());
|
|
649
|
+
};
|
|
650
|
+
}, [
|
|
651
|
+
e,
|
|
652
|
+
t,
|
|
653
|
+
r
|
|
654
|
+
]), /* @__PURE__ */ c("div", {
|
|
655
|
+
ref: i,
|
|
656
|
+
className: K.returnCityContainer,
|
|
657
|
+
children: /* @__PURE__ */ c("div", {
|
|
658
|
+
ref: o,
|
|
659
|
+
className: K.glassWrap
|
|
371
660
|
})
|
|
372
661
|
});
|
|
373
|
-
},
|
|
374
|
-
turntable: "cos-turntable",
|
|
375
|
-
wheelWrap: "cos-wheelWrap",
|
|
376
|
-
canvas: "cos-canvas",
|
|
377
|
-
pointer: "cos-pointer",
|
|
378
|
-
spinBtn: "cos-spinBtn",
|
|
379
|
-
result: "cos-result",
|
|
380
|
-
"fade-in": "cos-fade-in"
|
|
381
|
-
},
|
|
662
|
+
}, J = {
|
|
663
|
+
turntable: "cos-turntable-dkc32",
|
|
664
|
+
wheelWrap: "cos-wheelWrap-n7lhc",
|
|
665
|
+
canvas: "cos-canvas-A1-4x",
|
|
666
|
+
pointer: "cos-pointer-Rk1S9",
|
|
667
|
+
spinBtn: "cos-spinBtn-l9JIC",
|
|
668
|
+
result: "cos-result-H8q2c",
|
|
669
|
+
"fade-in": "cos-fade-in-U9bUC"
|
|
670
|
+
}, Y = [
|
|
382
671
|
"#FF6B6B",
|
|
383
672
|
"#4ECDC4",
|
|
384
673
|
"#FFE66D",
|
|
@@ -387,177 +676,177 @@ import './index.css';var o = {
|
|
|
387
676
|
"#F472B6",
|
|
388
677
|
"#34D399",
|
|
389
678
|
"#FB923C"
|
|
390
|
-
],
|
|
679
|
+
], X = [
|
|
391
680
|
{ label: "一等奖" },
|
|
392
681
|
{ label: "二等奖" },
|
|
393
682
|
{ label: "三等奖" },
|
|
394
683
|
{ label: "谢谢参与" },
|
|
395
684
|
{ label: "优惠券" },
|
|
396
685
|
{ label: "再来一次" }
|
|
397
|
-
],
|
|
398
|
-
let f =
|
|
399
|
-
let
|
|
400
|
-
if (!t) return;
|
|
401
|
-
let n = t.getContext("2d");
|
|
686
|
+
], Z = (e) => 1 - (1 - e) ** 3, ee = ({ prizes: e = X, size: r = 360, spinDuration: i = 4e3, spinRounds: s = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
|
|
687
|
+
let f = a(null), p = a(0), m = a(0), h = a(1), [g, _] = o(!1), [v, y] = o(null), b = r + 48, x = (e, t) => t.color ?? Y[e % Y.length], S = t((t) => {
|
|
688
|
+
let n = f.current;
|
|
402
689
|
if (!n) return;
|
|
403
|
-
let
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
690
|
+
let i = n.getContext("2d");
|
|
691
|
+
if (!i) return;
|
|
692
|
+
let a = b / 2, o = r / 2, s = Math.PI * 2 / e.length;
|
|
693
|
+
i.clearRect(0, 0, b, b), i.save(), i.translate(a, a), i.rotate(t), e.forEach((e, t) => {
|
|
694
|
+
let n = t * s - Math.PI / 2, a = n + s, c = x(t, e);
|
|
695
|
+
i.beginPath(), i.moveTo(0, 0), i.arc(0, 0, o, n, a), i.closePath(), i.fillStyle = c, i.fill(), i.strokeStyle = "rgb(255 255 255 / 35%)", i.lineWidth = 2, i.stroke(), i.save(), i.rotate(n + s / 2), i.textAlign = "right", i.fillStyle = "#fff", i.font = `bold ${Math.max(12, Math.floor(r / 22))}px system-ui, sans-serif`, i.shadowColor = "rgb(0 0 0 / 30%)", i.shadowBlur = 4, i.fillText(e.label, o - 18, 6), i.restore();
|
|
696
|
+
}), i.beginPath(), i.arc(0, 0, o, 0, Math.PI * 2), i.strokeStyle = "#fbbf24", i.lineWidth = 6, i.stroke(), i.beginPath(), i.arc(0, 0, o - 4, 0, Math.PI * 2), i.strokeStyle = "#f59e0b", i.lineWidth = 2, i.stroke(), i.restore(), i.save(), i.translate(a, a);
|
|
408
697
|
for (let e = 0; e < 12; e++) {
|
|
409
|
-
let t = e / 12 * Math.PI * 2,
|
|
410
|
-
|
|
698
|
+
let t = e / 12 * Math.PI * 2, n = Math.cos(t) * (o + 14), r = Math.sin(t) * (o + 14);
|
|
699
|
+
i.beginPath(), i.arc(n, r, 3, 0, Math.PI * 2), i.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", i.fill();
|
|
411
700
|
}
|
|
412
|
-
|
|
701
|
+
i.restore();
|
|
413
702
|
}, [
|
|
414
703
|
b,
|
|
415
|
-
|
|
416
|
-
|
|
704
|
+
e,
|
|
705
|
+
r
|
|
417
706
|
]);
|
|
418
|
-
|
|
707
|
+
n(() => {
|
|
419
708
|
let e = f.current;
|
|
420
709
|
if (!e) return;
|
|
421
710
|
let t = window.devicePixelRatio || 1;
|
|
422
711
|
h.current = t, e.width = b * t, e.height = b * t;
|
|
423
712
|
let n = e.getContext("2d");
|
|
424
713
|
n && n.setTransform(t, 0, 0, t, 0, 0), S(p.current);
|
|
425
|
-
}, [b, S]),
|
|
714
|
+
}, [b, S]), n(() => () => {
|
|
426
715
|
m.current && cancelAnimationFrame(m.current);
|
|
427
716
|
}, []);
|
|
428
|
-
let C = (
|
|
429
|
-
let
|
|
430
|
-
return Math.floor((360 -
|
|
717
|
+
let C = (t) => {
|
|
718
|
+
let n = 360 / e.length, r = (180 / Math.PI * t % 360 + 360) % 360;
|
|
719
|
+
return Math.floor((360 - r + n / 2) % 360 / n) % e.length;
|
|
431
720
|
};
|
|
432
|
-
return /* @__PURE__ */
|
|
433
|
-
className:
|
|
721
|
+
return /* @__PURE__ */ l("div", {
|
|
722
|
+
className: J.turntable,
|
|
434
723
|
style: {
|
|
435
724
|
width: b,
|
|
436
725
|
height: b + 80
|
|
437
726
|
},
|
|
438
|
-
children: [/* @__PURE__ */
|
|
439
|
-
className:
|
|
727
|
+
children: [/* @__PURE__ */ l("div", {
|
|
728
|
+
className: J.wheelWrap,
|
|
440
729
|
style: {
|
|
441
730
|
width: b,
|
|
442
731
|
height: b
|
|
443
732
|
},
|
|
444
733
|
children: [
|
|
445
|
-
/* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */
|
|
734
|
+
/* @__PURE__ */ c("div", { className: J.pointer }),
|
|
735
|
+
/* @__PURE__ */ c("canvas", {
|
|
447
736
|
ref: f,
|
|
448
|
-
className:
|
|
737
|
+
className: J.canvas,
|
|
449
738
|
style: {
|
|
450
739
|
width: b,
|
|
451
740
|
height: b
|
|
452
741
|
}
|
|
453
742
|
}),
|
|
454
|
-
/* @__PURE__ */
|
|
743
|
+
/* @__PURE__ */ c("button", {
|
|
455
744
|
type: "button",
|
|
456
|
-
className:
|
|
745
|
+
className: J.spinBtn,
|
|
457
746
|
onClick: () => {
|
|
458
|
-
if (g ||
|
|
747
|
+
if (g || e.length === 0) return;
|
|
459
748
|
_(!0), y(null);
|
|
460
|
-
let
|
|
461
|
-
let
|
|
462
|
-
if (p.current = u, S(u),
|
|
749
|
+
let t = Math.PI * 2 / e.length, n = Math.floor(Math.random() * e.length) * t + t / 2, r = p.current, a = r + s * Math.PI * 2 + (Math.PI * 2 - n) - r % (Math.PI * 2), o = r, c = performance.now(), l = (t) => {
|
|
750
|
+
let n = t - c, r = Math.min(n / i, 1), s = Z(r), u = o + (a - o) * s;
|
|
751
|
+
if (p.current = u, S(u), r < 1) m.current = requestAnimationFrame(l);
|
|
463
752
|
else {
|
|
464
|
-
let
|
|
465
|
-
p.current = u, _(!1), y(
|
|
753
|
+
let t = C(u), n = e[t];
|
|
754
|
+
p.current = u, _(!1), y(n), d?.(n, t);
|
|
466
755
|
}
|
|
467
756
|
};
|
|
468
|
-
m.current = requestAnimationFrame(
|
|
757
|
+
m.current = requestAnimationFrame(l);
|
|
469
758
|
},
|
|
470
759
|
disabled: g,
|
|
471
760
|
children: g ? "抽奖中..." : u
|
|
472
761
|
})
|
|
473
762
|
]
|
|
474
|
-
}), v && !g && /* @__PURE__ */
|
|
475
|
-
className:
|
|
476
|
-
children: ["恭喜获得:", /* @__PURE__ */
|
|
763
|
+
}), v && !g && /* @__PURE__ */ l("p", {
|
|
764
|
+
className: J.result,
|
|
765
|
+
children: ["恭喜获得:", /* @__PURE__ */ c("strong", { children: v.label })]
|
|
477
766
|
})]
|
|
478
767
|
});
|
|
479
|
-
},
|
|
480
|
-
typewriter: "cos-typewriter",
|
|
481
|
-
terminal: "cos-terminal",
|
|
482
|
-
dots: "cos-dots",
|
|
483
|
-
text: "cos-text",
|
|
484
|
-
prompt: "cos-prompt",
|
|
485
|
-
cursor: "cos-cursor",
|
|
486
|
-
blink: "cos-blink"
|
|
487
|
-
},
|
|
768
|
+
}, Q = {
|
|
769
|
+
typewriter: "cos-typewriter-7UhOL",
|
|
770
|
+
terminal: "cos-terminal-NWNVN",
|
|
771
|
+
dots: "cos-dots-oulNg",
|
|
772
|
+
text: "cos-text-ICV5T",
|
|
773
|
+
prompt: "cos-prompt-Y4hVD",
|
|
774
|
+
cursor: "cos-cursor-m8hGi",
|
|
775
|
+
blink: "cos-blink-XykM7"
|
|
776
|
+
}, te = [
|
|
488
777
|
"Hello, cos-design!",
|
|
489
778
|
"欢迎来到组件库 ✨",
|
|
490
779
|
"Build something fun 🚀"
|
|
491
|
-
],
|
|
492
|
-
let [
|
|
493
|
-
return
|
|
494
|
-
let
|
|
495
|
-
if (!f &&
|
|
496
|
-
else if (f &&
|
|
780
|
+
], ne = ({ texts: e = te, speed: t = 100, deleteSpeed: r = 50, pause: i = 2e3 }) => {
|
|
781
|
+
let [a, s] = o(""), [u, d] = o(0), [f, p] = o(!1);
|
|
782
|
+
return n(() => {
|
|
783
|
+
let n = e[u % e.length], o;
|
|
784
|
+
if (!f && a === n) o = setTimeout(() => p(!0), i);
|
|
785
|
+
else if (f && a === "") o = setTimeout(() => {
|
|
497
786
|
p(!1), d((t) => (t + 1) % e.length);
|
|
498
787
|
}, 0);
|
|
499
788
|
else {
|
|
500
|
-
let e = f ?
|
|
501
|
-
|
|
789
|
+
let e = f ? n.slice(0, a.length - 1) : n.slice(0, a.length + 1);
|
|
790
|
+
o = setTimeout(() => s(e), f ? r : t);
|
|
502
791
|
}
|
|
503
|
-
return () => clearTimeout(
|
|
792
|
+
return () => clearTimeout(o);
|
|
504
793
|
}, [
|
|
505
|
-
|
|
794
|
+
a,
|
|
506
795
|
f,
|
|
507
796
|
u,
|
|
508
797
|
e,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
]), /* @__PURE__ */
|
|
513
|
-
className:
|
|
514
|
-
children: /* @__PURE__ */
|
|
515
|
-
className:
|
|
516
|
-
children: [/* @__PURE__ */
|
|
517
|
-
className:
|
|
798
|
+
t,
|
|
799
|
+
r,
|
|
800
|
+
i
|
|
801
|
+
]), /* @__PURE__ */ c("div", {
|
|
802
|
+
className: Q.typewriter,
|
|
803
|
+
children: /* @__PURE__ */ l("div", {
|
|
804
|
+
className: Q.terminal,
|
|
805
|
+
children: [/* @__PURE__ */ l("div", {
|
|
806
|
+
className: Q.dots,
|
|
518
807
|
children: [
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
808
|
+
/* @__PURE__ */ c("span", {}),
|
|
809
|
+
/* @__PURE__ */ c("span", {}),
|
|
810
|
+
/* @__PURE__ */ c("span", {})
|
|
522
811
|
]
|
|
523
|
-
}), /* @__PURE__ */
|
|
524
|
-
className:
|
|
812
|
+
}), /* @__PURE__ */ l("p", {
|
|
813
|
+
className: Q.text,
|
|
525
814
|
children: [
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
className:
|
|
815
|
+
/* @__PURE__ */ c("span", {
|
|
816
|
+
className: Q.prompt,
|
|
528
817
|
children: ">"
|
|
529
818
|
}),
|
|
530
|
-
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
className:
|
|
819
|
+
a,
|
|
820
|
+
/* @__PURE__ */ c("span", {
|
|
821
|
+
className: Q.cursor,
|
|
533
822
|
children: "|"
|
|
534
823
|
})
|
|
535
824
|
]
|
|
536
825
|
})]
|
|
537
826
|
})
|
|
538
827
|
});
|
|
539
|
-
},
|
|
540
|
-
waveButton: "cos-waveButton",
|
|
541
|
-
btn: "cos-btn",
|
|
542
|
-
label: "cos-label",
|
|
543
|
-
wave: "cos-wave",
|
|
544
|
-
ripple: "cos-ripple"
|
|
545
|
-
},
|
|
546
|
-
className:
|
|
547
|
-
children: /* @__PURE__ */
|
|
828
|
+
}, $ = {
|
|
829
|
+
waveButton: "cos-waveButton-Aa7G-",
|
|
830
|
+
btn: "cos-btn-WJrEN",
|
|
831
|
+
label: "cos-label-9BHOU",
|
|
832
|
+
wave: "cos-wave-GycLU",
|
|
833
|
+
ripple: "cos-ripple-5ZFpr"
|
|
834
|
+
}, re = ({ text: e = "点我试试", onClick: t, color: n = "#38bdf8" }) => /* @__PURE__ */ c("div", {
|
|
835
|
+
className: $.waveButton,
|
|
836
|
+
children: /* @__PURE__ */ l("button", {
|
|
548
837
|
type: "button",
|
|
549
|
-
className:
|
|
838
|
+
className: $.btn,
|
|
550
839
|
style: { "--wave-color": n },
|
|
551
840
|
onClick: t,
|
|
552
841
|
children: [
|
|
553
|
-
/* @__PURE__ */
|
|
554
|
-
/* @__PURE__ */
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
-
className:
|
|
842
|
+
/* @__PURE__ */ c("span", { className: $.wave }),
|
|
843
|
+
/* @__PURE__ */ c("span", { className: $.wave }),
|
|
844
|
+
/* @__PURE__ */ c("span", {
|
|
845
|
+
className: $.label,
|
|
557
846
|
children: e
|
|
558
847
|
})
|
|
559
848
|
]
|
|
560
849
|
})
|
|
561
850
|
});
|
|
562
851
|
//#endregion
|
|
563
|
-
export {
|
|
852
|
+
export { d as CanvasClock, p as Charge, v as Confetti, C as Countdown, A as Fireworks, P as FlipCounter, I as GlitchText, z as MatrixRain, V as MeteorRain, U as NeonText, G as ParticleNetwork, q as ReturnCity, ee as Turntable, ne as Typewriter, re as WaveButton };
|