删除无用静态文件✅
This commit is contained in:
parent
18ae1b240b
commit
7dab27d0a3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,49 +0,0 @@
|
|||||||
/* Generated By cn-font-split@7.0.0 https://www.npmjs.com/package/cn-font-split
|
|
||||||
CreateTime: 2025-01-22 06:30:42.077 UTC;
|
|
||||||
Macintosh en CopyrightNotice Copyright (c) 2016 Apple Inc. All rights reserved.
|
|
||||||
Macintosh en FontFamilyName SF Mono
|
|
||||||
Macintosh en FontSubfamilyName Regular
|
|
||||||
Macintosh en UniqueFontID SF Mono Regular; 12.0d0e2; 2016-05-11
|
|
||||||
Macintosh en FullFontName SF Mono Regular
|
|
||||||
Macintosh en VersionString 12.0d0e2
|
|
||||||
Macintosh en PostScriptFontName SFMono-Regular
|
|
||||||
Macintosh en Trademark Apple Inc.
|
|
||||||
Macintosh en ManufacturerName Apple Inc.
|
|
||||||
Macintosh en DesignerName Apple Inc.
|
|
||||||
Macintosh en Description Apple Inc.
|
|
||||||
Macintosh en VendorURL http://www.apple.com/
|
|
||||||
Macintosh en DesignerURL http://www.apple.com/
|
|
||||||
Macintosh en LicenseDescription This SF Mono Font (the “Apple Font”) is licensed to you by Apple Inc. (“Apple”) in consideration of your agreement to the following terms. If you do not agree with these terms, do not use the Apple Font.
|
|
||||||
|
|
||||||
You may use the Apple Font solely in conjunction with Apple-branded applications, including, but not limited to, Xcode, Terminal.app and Console.app. You may not embed or use the Apple Font in or with any other software applications or programs or other products and you may not use the Apple Font to create, develop, display or otherwise distribute any content, documentation, artwork or any other work product.
|
|
||||||
|
|
||||||
You may use the Apple Font only for the purposes described in this License or as otherwise expressly permitted by Apple in writing.
|
|
||||||
Macintosh en LicenseURL http://www.apple.com/
|
|
||||||
Macintosh en TypographicSubfamilyName Regular
|
|
||||||
Windows en CopyrightNotice Copyright (c) 2016 Apple Inc. All rights reserved.
|
|
||||||
Windows en FontFamilyName SF Mono
|
|
||||||
Windows en FontSubfamilyName Regular
|
|
||||||
Windows en UniqueFontID SF Mono Regular; 12.0d0e2; 2016-05-11
|
|
||||||
Windows en FullFontName SF Mono Regular
|
|
||||||
Windows en VersionString 12.0d0e2
|
|
||||||
Windows en PostScriptFontName SFMono-Regular
|
|
||||||
Windows en Trademark Apple Inc.
|
|
||||||
Windows en ManufacturerName Apple Inc.
|
|
||||||
Windows en DesignerName Apple Inc.
|
|
||||||
Windows en Description Apple Inc.
|
|
||||||
Windows en VendorURL http://www.apple.com/
|
|
||||||
Windows en DesignerURL http://www.apple.com/
|
|
||||||
Windows en LicenseDescription This SF Mono Font (the “Apple Font”) is licensed to you by Apple Inc. (“Apple”) in consideration of your agreement to the following terms. If you do not agree with these terms, do not use the Apple Font.
|
|
||||||
|
|
||||||
You may use the Apple Font solely in conjunction with Apple-branded applications, including, but not limited to, Xcode, Terminal.app and Console.app. You may not embed or use the Apple Font in or with any other software applications or programs or other products and you may not use the Apple Font to create, develop, display or otherwise distribute any content, documentation, artwork or any other work product.
|
|
||||||
|
|
||||||
You may use the Apple Font only for the purposes described in this License or as otherwise expressly permitted by Apple in writing.
|
|
||||||
Windows en LicenseURL http://www.apple.com/
|
|
||||||
Windows en TypographicSubfamilyName Regular
|
|
||||||
*/
|
|
||||||
|
|
||||||
@font-face {font-family:"SF Mono";src:local("SF Mono"),url("./7b7639662c8705e085df31c8d19a2bc5.woff2") format("woff2");font-style: normal;font-display: swap;font-weight: 400;unicode-range:U+E3F;}
|
|
||||||
@font-face {font-family:"SF Mono";src:local("SF Mono"),url("./ff502c1ca7e766043f2953a56610b30d.woff2") format("woff2");font-style: normal;font-display: swap;font-weight: 400;unicode-range:U+2BC,U+2C6-2C7,U+2D8-2DD,U+300-304,U+306-30C,U+30F,U+311,U+31B,U+323-328,U+32D-32E,U+330-331,U+1E00-1E99,U+1EA0-1EF9,U+2011-2014,U+2018-201A,U+201C-201E,U+2020-2023,U+2026,U+2030,U+2032-2034,U+2039-203A,U+2043-2044,U+2071,U+207F,U+20A1-20A7,U+20A9-20AE,U+20B1-20B5,U+20B8-20BA,U+20BC-20BF,U+2116,U+2122,U+2126,U+2190-2193,U+2196-2199,U+2202,U+2206,U+220F,U+2211-2212,U+2219-221A,U+221E,U+222B,U+2248,U+2260,U+2264-2265,U+2500-259F,U+25B8,U+25CA,U+25E6,U+2713,U+2717,U+275B-275E,U+2934-2937,U+F6C3,U+F6D5-F6D8,U+F8FF,U+FB01-FB02;}
|
|
||||||
@font-face {font-family:"SF Mono";src:local("SF Mono"),url("./d04ef4ae415c7ca9d80dc480a5cf8c38.woff2") format("woff2");font-style: normal;font-display: swap;font-weight: 400;unicode-range:U+401-40C,U+40E-44F,U+451-45C,U+45E-45F,U+490-491;}
|
|
||||||
@font-face {font-family:"SF Mono";src:local("SF Mono"),url("./51127c9dc37d007e5df070ff7f97f774.woff2") format("woff2");font-style: normal;font-display: swap;font-weight: 400;unicode-range:U+37E,U+384-38A,U+38C,U+38E-3A1,U+3A3-3CE;}
|
|
||||||
@font-face {font-family:"SF Mono";src:local("SF Mono"),url("./383a02fb9802d7a69ec2ad4029e51c1d.woff2") format("woff2");font-style: normal;font-display: swap;font-weight: 400;unicode-range:U+20-7E,U+A1-AC,U+AE-B1,U+B4-B8,U+BA-137,U+139-148,U+14C-17E,U+192,U+1A0-1A1,U+1AF-1B0,U+1C4-1DC,U+1DE-1E3,U+1E6-1ED,U+1F1-1F5,U+1F8-21B,U+21E-21F,U+226-233,U+237;}
|
|
||||||
BIN
public/assets/font/SFMonoRegular/063c86.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/063c86.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/09a6e7.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/09a6e7.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/280d9c.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/280d9c.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/48e551.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/48e551.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/670656.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/670656.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/85845e.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/85845e.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/acce90.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/acce90.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/b87b2f.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/b87b2f.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/bc9564.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/bc9564.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/c26931.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/c26931.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/e7158f.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/e7158f.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/ef4ea2.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/ef4ea2.woff2
Normal file
Binary file not shown.
BIN
public/assets/font/SFMonoRegular/f4ed7b.woff2
Normal file
BIN
public/assets/font/SFMonoRegular/f4ed7b.woff2
Normal file
Binary file not shown.
45
public/assets/font/SFMonoRegular/result.css
Normal file
45
public/assets/font/SFMonoRegular/result.css
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* Generated By cn-font-split@7.5.5 https://www.npmjs.com/package/cn-font-split
|
||||||
|
CreateTime: 2025-04-02T10:04:36.324929+00:00;
|
||||||
|
Macintosh en CopyrightNotice Copyright (c) 2016-2017 Apple Inc. All rights reserved.
|
||||||
|
Macintosh en FontFamilyName SF Mono
|
||||||
|
Macintosh en FontSubfamilyName Regular
|
||||||
|
Macintosh en UniqueFontID SF Mono Regular; 13.1d0e1; 2017-05-04
|
||||||
|
Macintosh en FullFontName SF Mono Regular
|
||||||
|
Macintosh en VersionString 13.1d0e1
|
||||||
|
Macintosh en PostScriptFontName SFMono-Regular
|
||||||
|
Macintosh en Trademark Apple Inc.
|
||||||
|
Macintosh en ManufacturerName Apple Inc.
|
||||||
|
Macintosh en DesignerName Apple Inc.
|
||||||
|
Macintosh en Description Apple Inc.
|
||||||
|
Macintosh en VendorURL http://www.apple.com/
|
||||||
|
Macintosh en DesignerURL http://www.apple.com/
|
||||||
|
Macintosh en LicenseDescription This SF Mono Font (the “Apple Font”) is licensed to you by Apple Inc. (“Apple”) in consideration of your agreement to the following terms. If you do not agree with these terms, do not use the Apple Font.
|
||||||
|
|
||||||
|
You may use the Apple Font solely in conjunction with Apple-branded applications, including, but not limited to, Xcode, Terminal.app and Console.app. You may not embed or use the Apple Font in or with any other software applications or programs or other products and you may not use the Apple Font to create, develop, display or otherwise distribute any content, documentation, artwork or any other work product.
|
||||||
|
|
||||||
|
You may use the Apple Font only for the purposes described in this License or as otherwise expressly permitted by Apple in writing.
|
||||||
|
Macintosh en LicenseURL http://www.apple.com/
|
||||||
|
Macintosh en TypographicSubfamilyName Regular
|
||||||
|
Windows en CopyrightNotice Copyright (c) 2016-2017 Apple Inc. All rights reserved.
|
||||||
|
Windows en FontFamilyName SF Mono
|
||||||
|
Windows en FontSubfamilyName Regular
|
||||||
|
Windows en UniqueFontID SF Mono Regular; 13.1d0e1; 2017-05-04
|
||||||
|
Windows en FullFontName SF Mono Regular
|
||||||
|
Windows en VersionString 13.1d0e1
|
||||||
|
Windows en PostScriptFontName SFMono-Regular
|
||||||
|
Windows en Trademark Apple Inc.
|
||||||
|
Windows en ManufacturerName Apple Inc.
|
||||||
|
Windows en DesignerName Apple Inc.
|
||||||
|
Windows en Description Apple Inc.
|
||||||
|
Windows en VendorURL http://www.apple.com/
|
||||||
|
Windows en DesignerURL http://www.apple.com/
|
||||||
|
Windows en LicenseDescription This SF Mono Font (the “Apple Font”) is licensed to you by Apple Inc. (“Apple”) in consideration of your agreement to the following terms. If you do not agree with these terms, do not use the Apple Font.
|
||||||
|
|
||||||
|
You may use the Apple Font solely in conjunction with Apple-branded applications, including, but not limited to, Xcode, Terminal.app and Console.app. You may not embed or use the Apple Font in or with any other software applications or programs or other products and you may not use the Apple Font to create, develop, display or otherwise distribute any content, documentation, artwork or any other work product.
|
||||||
|
|
||||||
|
You may use the Apple Font only for the purposes described in this License or as otherwise expressly permitted by Apple in writing.
|
||||||
|
Windows en LicenseURL http://www.apple.com/
|
||||||
|
Windows en TypographicSubfamilyName Regular
|
||||||
|
*/
|
||||||
|
|
||||||
|
@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./063c86.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+25BE,U+25C0,U+25C2,U+25CA,U+25E6,U+2713,U+2717,U+275B-275E,U+2934-2937,U+F6D5-F6D8,U+F8FF,U+FB01-FB02;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./670656.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+1ECB-1EF9,U+2011-2013,U+201A,U+201E,U+2020-2023,U+2030,U+2032-2034,U+2039-203A,U+2043-2044,U+2071,U+207F,U+20A1-20AE,U+20B1-20B5,U+20B8-20BA,U+20BC-20BF,U+2116,U+2122,U+2126,U+2190-2194,U+2196-2199,U+2202,U+2206,U+220F,U+2211-2212,U+2219-221A,U+221E,U+222B,U+2248,U+2260,U+2264-2265,U+2423,U+2501,U+2503-251B,U+251D-259F,U+25B2,U+25B4,U+25B6,U+25B8,U+25BC;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./280d9c.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+300-304,U+306-30C,U+30F,U+311,U+31B,U+323-328,U+32D-32E,U+330-331,U+1E00-1E99,U+1EA0-1ECA;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./85845e.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+E3F;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./48e551.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+2500,U+2502,U+251C;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./acce90.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+2014,U+2018-2019,U+201C-201D,U+2026;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./bc9564.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+400-45F,U+462-463,U+472-475,U+48A-4FF,U+510-513,U+51C-51D,U+524-527,U+52E-52F;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./f4ed7b.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+37E,U+384-38A,U+38C,U+38E-3A1,U+3A3-3CE;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./e7158f.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+2BC,U+2C6-2C7,U+2D8-2DD;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./ef4ea2.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+192,U+1A0-1A1,U+1AF-1B0,U+1C4-1DC,U+1DE-1E3,U+1E6-1ED,U+1F1-1F5,U+1F8-21B,U+21E-21F,U+226-233,U+237;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./c26931.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+100-137,U+139-148,U+14C-17E;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./b87b2f.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+A1-AC,U+AE-B1,U+B4-B8,U+BA-FF;}@font-face{font-family:"SF Mono";src:local("SFMonoRegular"),url("./09a6e7.woff2")format("woff2");font-style:normal;font-display:swap;font-weight:400;unicode-range:U+20-7E;}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
@import url('./SFMono-Regular/result.css');
|
@import url('./SFMonoRegular/result.css');
|
||||||
/* 鸿蒙字体分包 */
|
/* 鸿蒙字体分包 */
|
||||||
@import url('./HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular/result.css');
|
@import url('./HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular/result.css');
|
||||||
@import url('./HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Medium/result.css');
|
@import url('./HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Medium/result.css');
|
||||||
|
|||||||
BIN
public/assets/images/home-banner.webp
Normal file
BIN
public/assets/images/home-banner.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
189
public/assets/js/vhCaiqi.js
Normal file
189
public/assets/js/vhCaiqi.js
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const confettiEffect = (() => {
|
||||||
|
// 状态对象
|
||||||
|
const state = {
|
||||||
|
canvas: null,
|
||||||
|
ctx: null,
|
||||||
|
W: 0,
|
||||||
|
H: 0,
|
||||||
|
isStart: false,
|
||||||
|
mp: 150,
|
||||||
|
particles: [],
|
||||||
|
angle: 0,
|
||||||
|
tiltAngle: 0,
|
||||||
|
confettiActive: true,
|
||||||
|
animationComplete: true,
|
||||||
|
animationHandler: null,
|
||||||
|
particleColors: {
|
||||||
|
colorOptions: [
|
||||||
|
"DodgerBlue", "OliveDrab", "Gold", "pink",
|
||||||
|
"SlateBlue", "lightblue", "Violet", "PaleGreen",
|
||||||
|
"SteelBlue", "SandyBrown", "Chocolate", "Crimson"
|
||||||
|
],
|
||||||
|
colorIndex: 0,
|
||||||
|
colorIncrementer: 0,
|
||||||
|
getColor: function () {
|
||||||
|
if (++this.colorIncrementer % 10 === 0) {
|
||||||
|
this.colorIndex = (this.colorIndex + 1) % this.colorOptions.length;
|
||||||
|
}
|
||||||
|
return this.colorOptions[this.colorIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 粒子构造函数
|
||||||
|
function createParticle(color, W, H, mp) {
|
||||||
|
return {
|
||||||
|
x: Math.random() * W,
|
||||||
|
y: Math.random() * H - H,
|
||||||
|
r: random(10, 30),
|
||||||
|
d: Math.random() * mp + 10,
|
||||||
|
color: color,
|
||||||
|
tilt: Math.floor(10 * Math.random()) - 10,
|
||||||
|
tiltAngleIncremental: 0.07 * Math.random() + 0.05,
|
||||||
|
tiltAngle: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 工具函数
|
||||||
|
function random(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 核心方法
|
||||||
|
function setGlobals() {
|
||||||
|
state.canvas = document.querySelector(".vh-aside-item.user > canvas");
|
||||||
|
state.ctx = state.canvas.getContext("2d");
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResize() {
|
||||||
|
[state.W, state.H] = [state.canvas.width, state.canvas.height];
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeButton() {
|
||||||
|
const elements = document.querySelectorAll('.vh-aside-item.user');
|
||||||
|
elements.forEach(el => {
|
||||||
|
el.addEventListener('mouseenter', restartConfetti);
|
||||||
|
el.addEventListener('mouseleave', deactivateConfetti);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeConfetti() {
|
||||||
|
state.particles = Array.from({ length: state.mp }, () =>
|
||||||
|
createParticle(
|
||||||
|
state.particleColors.getColor(),
|
||||||
|
state.W,
|
||||||
|
state.H,
|
||||||
|
state.mp
|
||||||
|
)
|
||||||
|
);
|
||||||
|
state.animationComplete = false;
|
||||||
|
startConfetti();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 动画相关方法
|
||||||
|
function animate() {
|
||||||
|
if (state.animationComplete) return;
|
||||||
|
handleResize();
|
||||||
|
state.ctx.clearRect(0, 0, state.W, state.H);
|
||||||
|
state.particles.forEach(p => drawParticle(p, state.ctx));
|
||||||
|
updateParticles();
|
||||||
|
state.animationHandler = requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawParticle(p, ctx) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = p.r / 2;
|
||||||
|
ctx.strokeStyle = p.color;
|
||||||
|
ctx.moveTo(p.x + p.tilt + p.r / 4, p.y);
|
||||||
|
ctx.lineTo(p.x + p.tilt, p.y + p.tilt + p.r / 4);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateParticles() {
|
||||||
|
state.angle += 0.01;
|
||||||
|
state.tiltAngle += 0.1;
|
||||||
|
|
||||||
|
const activeParticles = state.particles.reduce((count, p, i) => {
|
||||||
|
if (state.animationComplete) return count;
|
||||||
|
if (!state.confettiActive && p.y < -15) p.y = state.H + 100;
|
||||||
|
else {
|
||||||
|
stepParticle(p, i);
|
||||||
|
if (p.y <= state.H) count++;
|
||||||
|
checkReposition(p, i);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
if (activeParticles === 0) stopConfetti();
|
||||||
|
}
|
||||||
|
|
||||||
|
function stepParticle(p, i) {
|
||||||
|
p.tiltAngle += p.tiltAngleIncremental;
|
||||||
|
p.y += (Math.cos(state.angle + p.d) + 3 + p.r / 2) / 2;
|
||||||
|
p.x += Math.sin(state.angle);
|
||||||
|
p.tilt = 15 * Math.sin(p.tiltAngle - i / 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkReposition(p, i) {
|
||||||
|
if (!(p.x > state.W + 20 || p.x < -20 || p.y > state.H)) return;
|
||||||
|
|
||||||
|
const shouldReposition = (i % 5 > 0 || i % 2 === 0)
|
||||||
|
? { x: Math.random() * state.W, y: -10 }
|
||||||
|
: Math.sin(state.angle) > 0
|
||||||
|
? { x: -5, y: Math.random() * state.H }
|
||||||
|
: { x: state.W + 5, y: Math.random() * state.H };
|
||||||
|
|
||||||
|
repositionParticle(p, shouldReposition.x, shouldReposition.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function repositionParticle(p, x, y) {
|
||||||
|
Object.assign(p, { x, y, tilt: Math.floor(10 * Math.random()) - 10 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// 控制方法
|
||||||
|
function startConfetti() {
|
||||||
|
[state.W, state.H] = [window.innerWidth, window.innerHeight];
|
||||||
|
if (!state.animationComplete) animate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopConfetti() {
|
||||||
|
state.animationComplete = true;
|
||||||
|
state.ctx?.clearRect(0, 0, state.W, state.H);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearTimers() {
|
||||||
|
cancelAnimationFrame(state.animationHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateConfetti() {
|
||||||
|
state.confettiActive = false;
|
||||||
|
clearTimers();
|
||||||
|
stopConfetti();
|
||||||
|
state.isStart = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function restartConfetti() {
|
||||||
|
if (state.isStart) return;
|
||||||
|
handleResize();
|
||||||
|
state.isStart = true;
|
||||||
|
clearTimers();
|
||||||
|
setTimeout(() => {
|
||||||
|
state.confettiActive = true;
|
||||||
|
state.animationComplete = false;
|
||||||
|
initializeConfetti();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 公共接口
|
||||||
|
return {
|
||||||
|
init: () => {
|
||||||
|
setGlobals();
|
||||||
|
initializeButton();
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
confettiEffect.init();
|
||||||
|
});
|
||||||
54
public/assets/js/vhPaopao.js
Normal file
54
public/assets/js/vhPaopao.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const vhPaopaoInit = (element, options) => {
|
||||||
|
const config = Object.assign({ radius: 10, density: 0.3, clearOffset: 0.2 }, options);
|
||||||
|
let width, height, ctx, active = true;
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const particles = [];
|
||||||
|
// 初始化画布
|
||||||
|
const initCanvas = () => {
|
||||||
|
width = element.offsetWidth;
|
||||||
|
height = element.offsetHeight;
|
||||||
|
Object.assign(canvas.style, { top: '0', zIndex: '0', position: 'absolute', 'pointer-events': 'none' });
|
||||||
|
element.append(canvas);
|
||||||
|
element.parentElement.style.overflow = 'hidden';
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 粒子类
|
||||||
|
class Particle {
|
||||||
|
constructor() { this.reset() }
|
||||||
|
reset() {
|
||||||
|
this.x = Math.random() * width;
|
||||||
|
this.y = height + 100 * Math.random();
|
||||||
|
this.alpha = 0.1 + Math.random() * config.clearOffset;
|
||||||
|
this.scale = 0.1 + 0.3 * Math.random();
|
||||||
|
this.speed = Math.random();
|
||||||
|
this.color = config.color === "random" ? `rgba(${Math.random() * 255 | 0},0,0,${Math.random().toFixed(2)})` : config.color;
|
||||||
|
}
|
||||||
|
draw() {
|
||||||
|
if (this.alpha <= 0) this.reset();
|
||||||
|
this.y -= this.speed;
|
||||||
|
this.alpha -= 0.0005;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.scale * config.radius, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = this.color;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 初始化
|
||||||
|
initCanvas();
|
||||||
|
// 动画循环
|
||||||
|
const animate = () => { active && ctx.clearRect(0, 0, width, height); particles.forEach(p => p.draw()); requestAnimationFrame(animate); };
|
||||||
|
Array.from({ length: width * config.density | 0 }, () => particles.push(new Particle()));
|
||||||
|
animate();
|
||||||
|
// 事件监听
|
||||||
|
window.addEventListener('scroll', () => active = document.documentElement.scrollTop <= height);
|
||||||
|
window.addEventListener('resize', () => { width = element.clientWidth; height = element.clientHeight; canvas.width = width; canvas.height = height; });
|
||||||
|
};
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
const target = document.querySelector('main.main > .header-main');
|
||||||
|
target && vhPaopaoInit(target, { radius: 10, density: 0.2, color: "rgba(255,255,255,.4)", clearOffset: 0.99 });
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user