cos-design 2.1.0 → 2.2.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 +10 -0
- package/README.md +31 -2
- package/dist/components/canvasClock/index.d.ts +7 -0
- package/dist/components/charge/index.d.ts +6 -0
- package/dist/components/fireworks/index.d.ts +9 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/matrixRain/index.d.ts +11 -0
- package/dist/components/neonText/index.d.ts +13 -0
- package/dist/components/particleNetwork/index.d.ts +13 -0
- package/dist/components/returnCity/index.d.ts +6 -0
- package/dist/components/turntable/index.d.ts +21 -0
- package/dist/components/typewriter/index.d.ts +13 -0
- package/dist/components/waveButton/index.d.ts +11 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -114
- package/dist/index.js +563 -428
- package/package.json +34 -29
package/dist/index.js
CHANGED
|
@@ -1,428 +1,563 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import './index.css';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
],
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
3
|
+
import './index.css';var o = {
|
|
4
|
+
canvasClock: "cos-canvasClock",
|
|
5
|
+
canvasTarget: "cos-canvasTarget"
|
|
6
|
+
}, s = ({ width: r = 400, height: a = 400 }) => {
|
|
7
|
+
let s = n(null), c = Math.min(r, a), l = c / 2 - 16, u = c / 2, d = e((e) => {
|
|
8
|
+
e.clearRect(0, 0, c, c), e.save(), e.translate(u, u), e.beginPath(), e.arc(0, 0, l, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
|
|
9
|
+
for (let t = 0; t < 60; t++) {
|
|
10
|
+
let n = t / 60 * Math.PI * 2, r = l - (t % 5 == 0 ? 14 : 8);
|
|
11
|
+
e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * l, Math.sin(n) * l), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
|
|
12
|
+
}
|
|
13
|
+
e.fillStyle = "#111827", e.font = `bold ${Math.floor(c / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
|
|
14
|
+
for (let t = 1; t <= 12; t++) {
|
|
15
|
+
let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = l - 32;
|
|
16
|
+
e.fillText(String(t), Math.cos(n) * r, Math.sin(n) * r);
|
|
17
|
+
}
|
|
18
|
+
let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), o = (t, n, r, i, a) => {
|
|
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
|
+
}, s = (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
|
+
o(s, l * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), o(d, l * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), o(f, l * .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
|
+
}, [
|
|
23
|
+
u,
|
|
24
|
+
l,
|
|
25
|
+
c
|
|
26
|
+
]);
|
|
27
|
+
return t(() => {
|
|
28
|
+
let e = s.current;
|
|
29
|
+
if (!e) return;
|
|
30
|
+
let t = window.devicePixelRatio || 1;
|
|
31
|
+
e.width = c * t, e.height = c * t;
|
|
32
|
+
let n = e.getContext("2d");
|
|
33
|
+
if (!n) return;
|
|
34
|
+
n.setTransform(t, 0, 0, t, 0, 0);
|
|
35
|
+
let r = 0, i = () => {
|
|
36
|
+
d(n), r = requestAnimationFrame(i);
|
|
37
|
+
};
|
|
38
|
+
return i(), () => cancelAnimationFrame(r);
|
|
39
|
+
}, [d, c]), /* @__PURE__ */ i("div", {
|
|
40
|
+
className: o.canvasClock,
|
|
41
|
+
style: {
|
|
42
|
+
width: c,
|
|
43
|
+
height: c
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ i("canvas", {
|
|
46
|
+
ref: s,
|
|
47
|
+
className: o.canvasTarget,
|
|
48
|
+
style: {
|
|
49
|
+
width: c,
|
|
50
|
+
height: c
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}, c = {
|
|
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
|
+
}, l = (e) => {
|
|
64
|
+
let { initQuantity: n = 0 } = e, [o, s] = r(n);
|
|
65
|
+
return t(() => {
|
|
66
|
+
let e = o;
|
|
67
|
+
setInterval(() => {
|
|
68
|
+
e = Number(Number(e += .01).toFixed(2)), s(e);
|
|
69
|
+
}, 500);
|
|
70
|
+
}, []), /* @__PURE__ */ i("div", {
|
|
71
|
+
className: c.chargeContainer,
|
|
72
|
+
children: /* @__PURE__ */ a("div", {
|
|
73
|
+
className: c.contrast,
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ a("div", {
|
|
76
|
+
className: c.text,
|
|
77
|
+
children: [o ? o.toString().padEnd(4, "0") : 0, "%"]
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ i("span", {}),
|
|
80
|
+
/* @__PURE__ */ i("span", {}),
|
|
81
|
+
/* @__PURE__ */ i("span", {}),
|
|
82
|
+
/* @__PURE__ */ i("span", {}),
|
|
83
|
+
/* @__PURE__ */ i("span", {}),
|
|
84
|
+
/* @__PURE__ */ i("span", {}),
|
|
85
|
+
/* @__PURE__ */ i("span", {}),
|
|
86
|
+
/* @__PURE__ */ i("span", {}),
|
|
87
|
+
/* @__PURE__ */ i("span", {}),
|
|
88
|
+
/* @__PURE__ */ i("span", {}),
|
|
89
|
+
/* @__PURE__ */ i("span", {}),
|
|
90
|
+
/* @__PURE__ */ i("span", {}),
|
|
91
|
+
/* @__PURE__ */ i("span", {}),
|
|
92
|
+
/* @__PURE__ */ i("span", {}),
|
|
93
|
+
/* @__PURE__ */ i("span", {}),
|
|
94
|
+
/* @__PURE__ */ i("div", { className: c.circle }),
|
|
95
|
+
/* @__PURE__ */ i("div", { className: c.button })
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}, u = {
|
|
100
|
+
fireworks: "cos-fireworks",
|
|
101
|
+
canvas: "cos-canvas",
|
|
102
|
+
hint: "cos-hint"
|
|
103
|
+
}, d = [
|
|
104
|
+
"#ff6b6b",
|
|
105
|
+
"#ffd93d",
|
|
106
|
+
"#6bcb77",
|
|
107
|
+
"#4d96ff",
|
|
108
|
+
"#a66cff",
|
|
109
|
+
"#ff85c0"
|
|
110
|
+
], f = () => d[Math.floor(Math.random() * d.length)], p = (e, t, n) => {
|
|
111
|
+
let r = 60 + Math.floor(Math.random() * 30);
|
|
112
|
+
return Array.from({ length: r }, () => {
|
|
113
|
+
let r = Math.random() * Math.PI * 2, i = Math.random() * 4 + 2;
|
|
114
|
+
return {
|
|
115
|
+
x: e,
|
|
116
|
+
y: t,
|
|
117
|
+
vx: Math.cos(r) * i,
|
|
118
|
+
vy: Math.sin(r) * i,
|
|
119
|
+
alpha: 1,
|
|
120
|
+
color: Math.random() > .3 ? n : f(),
|
|
121
|
+
decay: Math.random() * .015 + .01
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}, m = ({ width: r = 800, height: o = 500, auto: s = !0 }) => {
|
|
125
|
+
let c = n(null), l = n([]), d = n(0), m = e((e) => {
|
|
126
|
+
let t = e ?? Math.random() * r * .6 + r * .2;
|
|
127
|
+
l.current.push({
|
|
128
|
+
x: t,
|
|
129
|
+
y: o,
|
|
130
|
+
vy: -(Math.random() * 4 + 6),
|
|
131
|
+
targetY: Math.random() * o * .4 + o * .1,
|
|
132
|
+
color: f(),
|
|
133
|
+
exploded: !1,
|
|
134
|
+
particles: []
|
|
135
|
+
});
|
|
136
|
+
}, [o, r]);
|
|
137
|
+
return t(() => {
|
|
138
|
+
let e = c.current;
|
|
139
|
+
if (!e) return;
|
|
140
|
+
let t = window.devicePixelRatio || 1;
|
|
141
|
+
e.width = r * t, e.height = o * t;
|
|
142
|
+
let n = e.getContext("2d");
|
|
143
|
+
if (!n) return;
|
|
144
|
+
n.setTransform(t, 0, 0, t, 0, 0);
|
|
145
|
+
let i = 0, a = () => {
|
|
146
|
+
d.current = requestAnimationFrame(a), n.fillStyle = "rgb(15 23 42 / 25%)", n.fillRect(0, 0, r, o), s && Math.random() < .03 && m(), l.current = l.current.filter((e) => e.exploded ? (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 : (n.beginPath(), n.arc(e.x, e.y, 2, 0, Math.PI * 2), n.fillStyle = e.color, n.globalAlpha = e.alpha, n.fill(), n.globalAlpha = 1, !0))), e.particles.length > 0) : (e.y += e.vy, e.vy *= .98, n.beginPath(), n.arc(e.x, e.y, 2.5, 0, Math.PI * 2), n.fillStyle = e.color, n.fill(), (e.vy >= 0 || e.y <= e.targetY) && (e.exploded = !0, e.particles = p(e.x, e.y, e.color)), !0));
|
|
147
|
+
};
|
|
148
|
+
return a(), s && (i = window.setInterval(() => m(), 1200)), () => {
|
|
149
|
+
cancelAnimationFrame(d.current), clearInterval(i);
|
|
150
|
+
};
|
|
151
|
+
}, [
|
|
152
|
+
s,
|
|
153
|
+
o,
|
|
154
|
+
m,
|
|
155
|
+
r
|
|
156
|
+
]), /* @__PURE__ */ a("div", {
|
|
157
|
+
className: u.fireworks,
|
|
158
|
+
style: {
|
|
159
|
+
width: r,
|
|
160
|
+
height: o
|
|
161
|
+
},
|
|
162
|
+
children: [/* @__PURE__ */ i("canvas", {
|
|
163
|
+
ref: c,
|
|
164
|
+
className: u.canvas,
|
|
165
|
+
style: {
|
|
166
|
+
width: r,
|
|
167
|
+
height: o
|
|
168
|
+
},
|
|
169
|
+
onClick: (e) => {
|
|
170
|
+
let t = e.currentTarget.getBoundingClientRect();
|
|
171
|
+
m(e.clientX - t.left);
|
|
172
|
+
}
|
|
173
|
+
}), /* @__PURE__ */ i("p", {
|
|
174
|
+
className: u.hint,
|
|
175
|
+
children: "点击画布燃放烟花"
|
|
176
|
+
})]
|
|
177
|
+
});
|
|
178
|
+
}, h = {
|
|
179
|
+
matrixRain: "cos-matrixRain",
|
|
180
|
+
canvas: "cos-canvas",
|
|
181
|
+
overlay: "cos-overlay",
|
|
182
|
+
title: "cos-title",
|
|
183
|
+
flicker: "cos-flicker",
|
|
184
|
+
subtitle: "cos-subtitle"
|
|
185
|
+
}, g = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", _ = ({ width: e = 800, height: r = 500, density: o = .6, color: s = "#00ff41" }) => {
|
|
186
|
+
let c = n(null);
|
|
187
|
+
return t(() => {
|
|
188
|
+
let t = c.current;
|
|
189
|
+
if (!t) return;
|
|
190
|
+
let n = window.devicePixelRatio || 1;
|
|
191
|
+
t.width = e * n, t.height = r * n;
|
|
192
|
+
let i = t.getContext("2d");
|
|
193
|
+
if (!i) return;
|
|
194
|
+
i.setTransform(n, 0, 0, n, 0, 0);
|
|
195
|
+
let a = Math.floor(e / 16 * o), l = Array.from({ length: a }, () => Math.random() * -50), u = 0, d = () => {
|
|
196
|
+
i.fillStyle = "rgb(0 0 0 / 8%)", i.fillRect(0, 0, e, r), i.fillStyle = s, i.font = "16px monospace", l.forEach((e, t) => {
|
|
197
|
+
let n = g[Math.floor(Math.random() * 53)], a = t / o * 16;
|
|
198
|
+
i.fillStyle = s, i.fillText(n, a, e * 16), e * 16 > r && Math.random() > .975 && (l[t] = 0), l[t] += 1;
|
|
199
|
+
}), u = requestAnimationFrame(d);
|
|
200
|
+
};
|
|
201
|
+
return d(), () => cancelAnimationFrame(u);
|
|
202
|
+
}, [
|
|
203
|
+
s,
|
|
204
|
+
o,
|
|
205
|
+
r,
|
|
206
|
+
e
|
|
207
|
+
]), /* @__PURE__ */ a("div", {
|
|
208
|
+
className: h.matrixRain,
|
|
209
|
+
style: {
|
|
210
|
+
width: e,
|
|
211
|
+
height: r
|
|
212
|
+
},
|
|
213
|
+
children: [/* @__PURE__ */ i("canvas", {
|
|
214
|
+
ref: c,
|
|
215
|
+
className: h.canvas,
|
|
216
|
+
style: {
|
|
217
|
+
width: e,
|
|
218
|
+
height: r
|
|
219
|
+
}
|
|
220
|
+
}), /* @__PURE__ */ a("div", {
|
|
221
|
+
className: h.overlay,
|
|
222
|
+
children: [/* @__PURE__ */ i("h2", {
|
|
223
|
+
className: h.title,
|
|
224
|
+
children: "MATRIX"
|
|
225
|
+
}), /* @__PURE__ */ i("p", {
|
|
226
|
+
className: h.subtitle,
|
|
227
|
+
children: "数字雨效果"
|
|
228
|
+
})]
|
|
229
|
+
})]
|
|
230
|
+
});
|
|
231
|
+
}, v = {
|
|
232
|
+
neonText: "cos-neonText",
|
|
233
|
+
text: "cos-text",
|
|
234
|
+
flicker: "cos-flicker",
|
|
235
|
+
"neon-flicker": "cos-neon-flicker",
|
|
236
|
+
reflection: "cos-reflection"
|
|
237
|
+
}, y = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ a("div", {
|
|
238
|
+
className: v.neonText,
|
|
239
|
+
children: [/* @__PURE__ */ i("h1", {
|
|
240
|
+
className: `${v.text} ${r ? v.flicker : ""}`,
|
|
241
|
+
style: {
|
|
242
|
+
fontSize: n,
|
|
243
|
+
"--neon-color": t
|
|
244
|
+
},
|
|
245
|
+
children: e
|
|
246
|
+
}), /* @__PURE__ */ i("p", {
|
|
247
|
+
className: v.reflection,
|
|
248
|
+
style: {
|
|
249
|
+
fontSize: n * .35,
|
|
250
|
+
color: t
|
|
251
|
+
},
|
|
252
|
+
children: e
|
|
253
|
+
})]
|
|
254
|
+
}), b = {
|
|
255
|
+
particleNetwork: "cos-particleNetwork",
|
|
256
|
+
canvas: "cos-canvas",
|
|
257
|
+
hint: "cos-hint"
|
|
258
|
+
}, x = ({ width: r = 800, height: o = 500, particleCount: s = 60, linkDistance: c = 120, color: l = "#38bdf8" }) => {
|
|
259
|
+
let u = n(null), d = n([]), f = n({
|
|
260
|
+
x: -1e3,
|
|
261
|
+
y: -1e3
|
|
262
|
+
}), p = e(() => {
|
|
263
|
+
d.current = Array.from({ length: s }, () => ({
|
|
264
|
+
x: Math.random() * r,
|
|
265
|
+
y: Math.random() * o,
|
|
266
|
+
vx: (Math.random() - .5) * 1.2,
|
|
267
|
+
vy: (Math.random() - .5) * 1.2,
|
|
268
|
+
radius: Math.random() * 2 + 1
|
|
269
|
+
}));
|
|
270
|
+
}, [
|
|
271
|
+
o,
|
|
272
|
+
s,
|
|
273
|
+
r
|
|
274
|
+
]);
|
|
275
|
+
return t(() => {
|
|
276
|
+
p();
|
|
277
|
+
}, [p]), t(() => {
|
|
278
|
+
let e = u.current;
|
|
279
|
+
if (!e) return;
|
|
280
|
+
let t = window.devicePixelRatio || 1;
|
|
281
|
+
e.width = r * t, e.height = o * t;
|
|
282
|
+
let n = e.getContext("2d");
|
|
283
|
+
if (!n) return;
|
|
284
|
+
n.setTransform(t, 0, 0, t, 0, 0);
|
|
285
|
+
let i = 0, a = () => {
|
|
286
|
+
n.fillStyle = "#0f172a", n.fillRect(0, 0, r, o);
|
|
287
|
+
let e = d.current, t = f.current;
|
|
288
|
+
e.forEach((e) => {
|
|
289
|
+
e.x += e.vx, e.y += e.vy, (e.x < 0 || e.x > r) && (e.vx *= -1), (e.y < 0 || e.y > o) && (e.vy *= -1);
|
|
290
|
+
let n = t.x - e.x, i = t.y - e.y;
|
|
291
|
+
Math.sqrt(n * n + i * i) < 150 && (e.vx -= n * 3e-4, e.vy -= i * 3e-4);
|
|
292
|
+
});
|
|
293
|
+
for (let t = 0; t < e.length; t++) for (let r = t + 1; r < e.length; r++) {
|
|
294
|
+
let i = e[t].x - e[r].x, a = e[t].y - e[r].y, o = Math.sqrt(i * i + a * a);
|
|
295
|
+
o < c && (n.beginPath(), n.moveTo(e[t].x, e[t].y), n.lineTo(e[r].x, e[r].y), n.strokeStyle = l, n.globalAlpha = 1 - o / c, n.lineWidth = .8, n.stroke(), n.globalAlpha = 1);
|
|
296
|
+
}
|
|
297
|
+
e.forEach((e) => {
|
|
298
|
+
n.beginPath(), n.arc(e.x, e.y, e.radius, 0, Math.PI * 2), n.fillStyle = l, n.fill();
|
|
299
|
+
}), i = requestAnimationFrame(a);
|
|
300
|
+
};
|
|
301
|
+
return a(), () => cancelAnimationFrame(i);
|
|
302
|
+
}, [
|
|
303
|
+
l,
|
|
304
|
+
o,
|
|
305
|
+
p,
|
|
306
|
+
c,
|
|
307
|
+
r
|
|
308
|
+
]), /* @__PURE__ */ a("div", {
|
|
309
|
+
className: b.particleNetwork,
|
|
310
|
+
style: {
|
|
311
|
+
width: r,
|
|
312
|
+
height: o
|
|
313
|
+
},
|
|
314
|
+
children: [/* @__PURE__ */ i("canvas", {
|
|
315
|
+
ref: u,
|
|
316
|
+
className: b.canvas,
|
|
317
|
+
style: {
|
|
318
|
+
width: r,
|
|
319
|
+
height: o
|
|
320
|
+
},
|
|
321
|
+
onMouseMove: (e) => {
|
|
322
|
+
let t = e.currentTarget.getBoundingClientRect();
|
|
323
|
+
f.current = {
|
|
324
|
+
x: e.clientX - t.left,
|
|
325
|
+
y: e.clientY - t.top
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
onMouseLeave: () => {
|
|
329
|
+
f.current = {
|
|
330
|
+
x: -1e3,
|
|
331
|
+
y: -1e3
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}), /* @__PURE__ */ i("p", {
|
|
335
|
+
className: b.hint,
|
|
336
|
+
children: "移动鼠标与粒子互动"
|
|
337
|
+
})]
|
|
338
|
+
});
|
|
339
|
+
}, S = {
|
|
340
|
+
returnCityContainer: "cos-returnCityContainer",
|
|
341
|
+
star: "cos-star",
|
|
342
|
+
glassWrap: "cos-glassWrap",
|
|
343
|
+
rotate: "cos-rotate",
|
|
344
|
+
glassItem: "cos-glassItem"
|
|
345
|
+
}, C = () => {
|
|
346
|
+
let e = (e, t) => {
|
|
347
|
+
for (let n = 0; n < t; n++) setTimeout(function() {
|
|
348
|
+
let t = document.createElement("div");
|
|
349
|
+
t.className = S.star;
|
|
350
|
+
let n = document.body.clientWidth, r = document.body.clientHeight, i = Math.random() * n + "px", a = Math.random() * r + "px";
|
|
351
|
+
t.style.top = a, t.style.left = i, e.append(t);
|
|
352
|
+
}, Math.random() * 2e3);
|
|
353
|
+
}, n = () => {
|
|
354
|
+
let e = document.getElementById("glassWrap");
|
|
355
|
+
if (e) for (let t = 0; t < 6; t++) {
|
|
356
|
+
let n = document.createElement("div");
|
|
357
|
+
n.className = S.glassItem, n.style.transform = `rotateY(${360 / 6 * t}deg) translateZ(150px)`, e.appendChild(n), setTimeout(() => {
|
|
358
|
+
n.style.top = "0px", n.style.opacity = "1";
|
|
359
|
+
}, t * 300);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return t(() => {
|
|
363
|
+
let t = document.getElementById("returnCityContainer");
|
|
364
|
+
t && e(t, document.documentElement.clientWidth / 20), n();
|
|
365
|
+
}, []), /* @__PURE__ */ i("div", {
|
|
366
|
+
id: "returnCityContainer",
|
|
367
|
+
className: S.returnCityContainer,
|
|
368
|
+
children: /* @__PURE__ */ i("div", {
|
|
369
|
+
id: "glassWrap",
|
|
370
|
+
className: S.glassWrap
|
|
371
|
+
})
|
|
372
|
+
});
|
|
373
|
+
}, w = {
|
|
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
|
+
}, T = [
|
|
382
|
+
"#FF6B6B",
|
|
383
|
+
"#4ECDC4",
|
|
384
|
+
"#FFE66D",
|
|
385
|
+
"#A78BFA",
|
|
386
|
+
"#60A5FA",
|
|
387
|
+
"#F472B6",
|
|
388
|
+
"#34D399",
|
|
389
|
+
"#FB923C"
|
|
390
|
+
], E = [
|
|
391
|
+
{ label: "一等奖" },
|
|
392
|
+
{ label: "二等奖" },
|
|
393
|
+
{ label: "三等奖" },
|
|
394
|
+
{ label: "谢谢参与" },
|
|
395
|
+
{ label: "优惠券" },
|
|
396
|
+
{ label: "再来一次" }
|
|
397
|
+
], D = (e) => 1 - (1 - e) ** 3, O = ({ prizes: o = E, size: s = 360, spinDuration: c = 4e3, spinRounds: l = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
|
|
398
|
+
let f = n(null), p = n(0), m = n(0), h = n(1), [g, _] = r(!1), [v, y] = r(null), b = s + 48, x = (e, t) => t.color ?? T[e % T.length], S = e((e) => {
|
|
399
|
+
let t = f.current;
|
|
400
|
+
if (!t) return;
|
|
401
|
+
let n = t.getContext("2d");
|
|
402
|
+
if (!n) return;
|
|
403
|
+
let r = b / 2, i = s / 2, a = Math.PI * 2 / o.length;
|
|
404
|
+
n.clearRect(0, 0, b, b), n.save(), n.translate(r, r), n.rotate(e), o.forEach((e, t) => {
|
|
405
|
+
let r = t * a - Math.PI / 2, o = r + a, c = x(t, e);
|
|
406
|
+
n.beginPath(), n.moveTo(0, 0), n.arc(0, 0, i, r, o), n.closePath(), n.fillStyle = c, n.fill(), n.strokeStyle = "rgb(255 255 255 / 35%)", n.lineWidth = 2, n.stroke(), n.save(), n.rotate(r + a / 2), n.textAlign = "right", n.fillStyle = "#fff", n.font = `bold ${Math.max(12, Math.floor(s / 22))}px system-ui, sans-serif`, n.shadowColor = "rgb(0 0 0 / 30%)", n.shadowBlur = 4, n.fillText(e.label, i - 18, 6), n.restore();
|
|
407
|
+
}), n.beginPath(), n.arc(0, 0, i, 0, Math.PI * 2), n.strokeStyle = "#fbbf24", n.lineWidth = 6, n.stroke(), n.beginPath(), n.arc(0, 0, i - 4, 0, Math.PI * 2), n.strokeStyle = "#f59e0b", n.lineWidth = 2, n.stroke(), n.restore(), n.save(), n.translate(r, r);
|
|
408
|
+
for (let e = 0; e < 12; e++) {
|
|
409
|
+
let t = e / 12 * Math.PI * 2, r = Math.cos(t) * (i + 14), a = Math.sin(t) * (i + 14);
|
|
410
|
+
n.beginPath(), n.arc(r, a, 3, 0, Math.PI * 2), n.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", n.fill();
|
|
411
|
+
}
|
|
412
|
+
n.restore();
|
|
413
|
+
}, [
|
|
414
|
+
b,
|
|
415
|
+
o,
|
|
416
|
+
s
|
|
417
|
+
]);
|
|
418
|
+
t(() => {
|
|
419
|
+
let e = f.current;
|
|
420
|
+
if (!e) return;
|
|
421
|
+
let t = window.devicePixelRatio || 1;
|
|
422
|
+
h.current = t, e.width = b * t, e.height = b * t;
|
|
423
|
+
let n = e.getContext("2d");
|
|
424
|
+
n && n.setTransform(t, 0, 0, t, 0, 0), S(p.current);
|
|
425
|
+
}, [b, S]), t(() => () => {
|
|
426
|
+
m.current && cancelAnimationFrame(m.current);
|
|
427
|
+
}, []);
|
|
428
|
+
let C = (e) => {
|
|
429
|
+
let t = 360 / o.length, n = (180 / Math.PI * e % 360 + 360) % 360;
|
|
430
|
+
return Math.floor((360 - n + t / 2) % 360 / t) % o.length;
|
|
431
|
+
};
|
|
432
|
+
return /* @__PURE__ */ a("div", {
|
|
433
|
+
className: w.turntable,
|
|
434
|
+
style: {
|
|
435
|
+
width: b,
|
|
436
|
+
height: b + 80
|
|
437
|
+
},
|
|
438
|
+
children: [/* @__PURE__ */ a("div", {
|
|
439
|
+
className: w.wheelWrap,
|
|
440
|
+
style: {
|
|
441
|
+
width: b,
|
|
442
|
+
height: b
|
|
443
|
+
},
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ i("div", { className: w.pointer }),
|
|
446
|
+
/* @__PURE__ */ i("canvas", {
|
|
447
|
+
ref: f,
|
|
448
|
+
className: w.canvas,
|
|
449
|
+
style: {
|
|
450
|
+
width: b,
|
|
451
|
+
height: b
|
|
452
|
+
}
|
|
453
|
+
}),
|
|
454
|
+
/* @__PURE__ */ i("button", {
|
|
455
|
+
type: "button",
|
|
456
|
+
className: w.spinBtn,
|
|
457
|
+
onClick: () => {
|
|
458
|
+
if (g || o.length === 0) return;
|
|
459
|
+
_(!0), y(null);
|
|
460
|
+
let e = Math.PI * 2 / o.length, t = Math.floor(Math.random() * o.length) * e + e / 2, n = p.current, r = n + l * Math.PI * 2 + (Math.PI * 2 - t) - n % (Math.PI * 2), i = n, a = performance.now(), s = (e) => {
|
|
461
|
+
let t = e - a, n = Math.min(t / c, 1), l = D(n), u = i + (r - i) * l;
|
|
462
|
+
if (p.current = u, S(u), n < 1) m.current = requestAnimationFrame(s);
|
|
463
|
+
else {
|
|
464
|
+
let e = C(u), t = o[e];
|
|
465
|
+
p.current = u, _(!1), y(t), d?.(t, e);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
m.current = requestAnimationFrame(s);
|
|
469
|
+
},
|
|
470
|
+
disabled: g,
|
|
471
|
+
children: g ? "抽奖中..." : u
|
|
472
|
+
})
|
|
473
|
+
]
|
|
474
|
+
}), v && !g && /* @__PURE__ */ a("p", {
|
|
475
|
+
className: w.result,
|
|
476
|
+
children: ["恭喜获得:", /* @__PURE__ */ i("strong", { children: v.label })]
|
|
477
|
+
})]
|
|
478
|
+
});
|
|
479
|
+
}, k = {
|
|
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
|
+
}, A = [
|
|
488
|
+
"Hello, cos-design!",
|
|
489
|
+
"欢迎来到组件库 ✨",
|
|
490
|
+
"Build something fun 🚀"
|
|
491
|
+
], j = ({ texts: e = A, speed: n = 100, deleteSpeed: o = 50, pause: s = 2e3 }) => {
|
|
492
|
+
let [c, l] = r(""), [u, d] = r(0), [f, p] = r(!1);
|
|
493
|
+
return t(() => {
|
|
494
|
+
let t = e[u % e.length], r;
|
|
495
|
+
if (!f && c === t) r = setTimeout(() => p(!0), s);
|
|
496
|
+
else if (f && c === "") r = setTimeout(() => {
|
|
497
|
+
p(!1), d((t) => (t + 1) % e.length);
|
|
498
|
+
}, 0);
|
|
499
|
+
else {
|
|
500
|
+
let e = f ? t.slice(0, c.length - 1) : t.slice(0, c.length + 1);
|
|
501
|
+
r = setTimeout(() => l(e), f ? o : n);
|
|
502
|
+
}
|
|
503
|
+
return () => clearTimeout(r);
|
|
504
|
+
}, [
|
|
505
|
+
c,
|
|
506
|
+
f,
|
|
507
|
+
u,
|
|
508
|
+
e,
|
|
509
|
+
n,
|
|
510
|
+
o,
|
|
511
|
+
s
|
|
512
|
+
]), /* @__PURE__ */ i("div", {
|
|
513
|
+
className: k.typewriter,
|
|
514
|
+
children: /* @__PURE__ */ a("div", {
|
|
515
|
+
className: k.terminal,
|
|
516
|
+
children: [/* @__PURE__ */ a("div", {
|
|
517
|
+
className: k.dots,
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ i("span", {}),
|
|
520
|
+
/* @__PURE__ */ i("span", {}),
|
|
521
|
+
/* @__PURE__ */ i("span", {})
|
|
522
|
+
]
|
|
523
|
+
}), /* @__PURE__ */ a("p", {
|
|
524
|
+
className: k.text,
|
|
525
|
+
children: [
|
|
526
|
+
/* @__PURE__ */ i("span", {
|
|
527
|
+
className: k.prompt,
|
|
528
|
+
children: ">"
|
|
529
|
+
}),
|
|
530
|
+
c,
|
|
531
|
+
/* @__PURE__ */ i("span", {
|
|
532
|
+
className: k.cursor,
|
|
533
|
+
children: "|"
|
|
534
|
+
})
|
|
535
|
+
]
|
|
536
|
+
})]
|
|
537
|
+
})
|
|
538
|
+
});
|
|
539
|
+
}, M = {
|
|
540
|
+
waveButton: "cos-waveButton",
|
|
541
|
+
btn: "cos-btn",
|
|
542
|
+
label: "cos-label",
|
|
543
|
+
wave: "cos-wave",
|
|
544
|
+
ripple: "cos-ripple"
|
|
545
|
+
}, N = ({ text: e = "点我试试", onClick: t, color: n = "#38bdf8" }) => /* @__PURE__ */ i("div", {
|
|
546
|
+
className: M.waveButton,
|
|
547
|
+
children: /* @__PURE__ */ a("button", {
|
|
548
|
+
type: "button",
|
|
549
|
+
className: M.btn,
|
|
550
|
+
style: { "--wave-color": n },
|
|
551
|
+
onClick: t,
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ i("span", { className: M.wave }),
|
|
554
|
+
/* @__PURE__ */ i("span", { className: M.wave }),
|
|
555
|
+
/* @__PURE__ */ i("span", {
|
|
556
|
+
className: M.label,
|
|
557
|
+
children: e
|
|
558
|
+
})
|
|
559
|
+
]
|
|
560
|
+
})
|
|
561
|
+
});
|
|
562
|
+
//#endregion
|
|
563
|
+
export { s as CanvasClock, l as Charge, m as Fireworks, _ as MatrixRain, y as NeonText, x as ParticleNetwork, C as ReturnCity, O as Turntable, j as Typewriter, N as WaveButton };
|