fix(feat): add locales and refine responsive landing page UI

This commit is contained in:
SeekingGamer
2026-05-15 12:11:50 +08:00
parent ce1095088d
commit ff7e4395ea
22 changed files with 1315 additions and 289 deletions

View File

@@ -31,6 +31,42 @@ const {
(() => {
const header = document.getElementById('site-header');
const getOffset = () => header ? header.offsetHeight : 0;
let activeScrollAnimation = 0;
const easeInCubic = (t: number) => t * t * t;
const animateScrollTo = (targetTop: number) => {
const startTop = window.scrollY;
const distance = targetTop - startTop;
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
window.scrollTo(0, targetTop);
return;
}
if (activeScrollAnimation) {
cancelAnimationFrame(activeScrollAnimation);
}
const duration = Math.min(1300, Math.max(650, Math.abs(distance) * 0.7));
const startTime = performance.now();
const step = (now: number) => {
const elapsed = now - startTime;
const progress = Math.min(elapsed / duration, 1);
const easedProgress = easeInCubic(progress);
window.scrollTo(0, startTop + distance * easedProgress);
if (progress < 1) {
activeScrollAnimation = requestAnimationFrame(step);
} else {
activeScrollAnimation = 0;
}
};
activeScrollAnimation = requestAnimationFrame(step);
};
document.querySelectorAll('a[href^="#"]').forEach(link => {
link.addEventListener('click', e => {
@@ -40,7 +76,7 @@ const {
if (!target) return;
e.preventDefault();
const top = target.getBoundingClientRect().top + window.scrollY - getOffset();
window.scrollTo({ top, behavior: 'smooth' });
animateScrollTo(top);
});
});