From fe53c60f78a4c904a0e7ba408830d7f4a775735b Mon Sep 17 00:00:00 2001 From: Hikaru Date: Mon, 17 Aug 2026 12:08:46 +0800 Subject: [PATCH] style: apply Codacy quick fixes across components and vite config --- src/components/CookieConsent.tsx | 8 ++++---- src/components/Footer.tsx | 2 +- src/components/Nav.tsx | 8 ++++---- src/components/ScrollTop.tsx | 2 +- src/components/Toast.tsx | 2 +- src/pages/Team.tsx | 6 +++--- vite.config.ts | 12 ++++++------ 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/CookieConsent.tsx b/src/components/CookieConsent.tsx index 35589e2..71292c5 100644 --- a/src/components/CookieConsent.tsx +++ b/src/components/CookieConsent.tsx @@ -15,7 +15,7 @@ export function CookieConsent({ lang }: { lang: Lang }) { useEffect(() => { initConsentMode(); if (choice === 'accepted') grantAnalyticsConsent(); - return () => window.clearTimeout(timerRef.current); + return () => { window.clearTimeout(timerRef.current); }; }, [choice]); const showBanner = choice === null || visible; @@ -31,7 +31,7 @@ export function CookieConsent({ lang }: { lang: Lang }) { setVisible(true); }; window.addEventListener(COOKIE_SETTINGS_EVENT, onOpen); - return () => window.removeEventListener(COOKIE_SETTINGS_EVENT, onOpen); + return () => { window.removeEventListener(COOKIE_SETTINGS_EVENT, onOpen); }; }, []); if (!showBanner) return null; @@ -66,10 +66,10 @@ export function CookieConsent({ lang }: { lang: Lang }) {

- -
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 53615b0..42fbc4b 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -15,7 +15,7 @@ export function Footer({ disclaimer, cookieSettingsLabel }: { disclaimer?: strin

© 2026 熵序前言(上海)教育科技有限公司. All Rights Reserved.

- + 沪ICP备2026033811号 {cookieSettingsLabel && ( diff --git a/src/components/Nav.tsx b/src/components/Nav.tsx index 586dbf2..5d5d442 100644 --- a/src/components/Nav.tsx +++ b/src/components/Nav.tsx @@ -47,7 +47,7 @@ export function Nav({ if (!e.matches) setMenuOpen(false); }; mq.addEventListener('change', onChange); - return () => mq.removeEventListener('change', onChange); + return () => { mq.removeEventListener('change', onChange); }; }, []); useEffect(() => { @@ -97,7 +97,7 @@ export function Nav({ ?.querySelector('.nav-overlay-link') ?.focus({ preventScroll: true }); }); - return () => cancelAnimationFrame(id); + return () => { cancelAnimationFrame(id); }; } if (wasOpenRef.current) { wasOpenRef.current = false; @@ -127,7 +127,7 @@ export function Nav({ href={logoHref} className="nav-logo" aria-label="Entropy" - onClick={() => setMenuOpen(false)} + onClick={() => { setMenuOpen(false); }} > Entropy @@ -166,7 +166,7 @@ export function Nav({ aria-label={menuOpen ? '关闭菜单' : '打开菜单'} aria-expanded={menuOpen} aria-controls="nav-overlay" - onClick={() => setMenuOpen((open) => !open)} + onClick={() => { setMenuOpen((open) => !open); }} > diff --git a/src/components/ScrollTop.tsx b/src/components/ScrollTop.tsx index 541f66b..e92ff86 100644 --- a/src/components/ScrollTop.tsx +++ b/src/components/ScrollTop.tsx @@ -7,7 +7,7 @@ export function ScrollTop({ visible }: { visible: boolean }) { diff --git a/src/components/Toast.tsx b/src/components/Toast.tsx index d217cf3..add6ceb 100644 --- a/src/components/Toast.tsx +++ b/src/components/Toast.tsx @@ -41,7 +41,7 @@ export function ToastProvider({ children }: { children: React.ReactNode }) { onOpenChange={(open) => { if (!open) closeToast(toast.id); }} - onSwipeEnd={() => closeToast(toast.id)} + onSwipeEnd={() => { closeToast(toast.id); }} onAnimationEnd={() => { if (!toast.open) removeToast(toast.id); }} diff --git a/src/pages/Team.tsx b/src/pages/Team.tsx index 8092957..0c0ffd0 100644 --- a/src/pages/Team.tsx +++ b/src/pages/Team.tsx @@ -99,7 +99,7 @@ function TeamCard({ return (
onToggle(active ? null : member.avatar) : undefined} + onClick={interactive ? () => { onToggle(active ? null : member.avatar); } : undefined} onKeyDown={ interactive ? (e) => { @@ -121,7 +121,7 @@ function TeamCard({ alt={nickname} loading="lazy" decoding="async" - onError={() => setImgFailed(true)} + onError={() => { setImgFailed(true); }} /> )}
@@ -160,7 +160,7 @@ export function Team() { // Lenis 的 scrollTo 自动应用 scroll-margin-top;refresh=true 确保滚动上限已更新 scrollToTarget(target, 0, true); }, 120); - return () => clearTimeout(timer); + return () => { clearTimeout(timer); }; }, [ready]); const handleToggleLang = () => { diff --git a/vite.config.ts b/vite.config.ts index 270a365..fb44dae 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -57,12 +57,12 @@ function mpa404Fallback(): Plugin { configureServer(server) { const { root, publicDir } = server.config; server.middlewares.use(async (req: IncomingMessage, res: ServerResponse, next: Next) => { - if (!isHtmlNavigation(req)) return next(); + if (!isHtmlNavigation(req)) { next(); return; } const urlPath = requestPath(req); - if (knownPages.includes(urlPath)) return next(); - if (publicDir && fs.existsSync(path.join(publicDir, urlPath))) return next(); + if (knownPages.includes(urlPath)) { next(); return; } + if (publicDir && fs.existsSync(path.join(publicDir, urlPath))) { next(); return; } const source = path.join(root, '404.html'); - if (!fs.existsSync(source)) return next(); + if (!fs.existsSync(source)) { next(); return; } const html = fs.readFileSync(source, 'utf-8'); res.statusCode = 404; res.setHeader('Content-Type', 'text/html'); @@ -76,9 +76,9 @@ function mpa404Fallback(): Plugin { if (!isHtmlNavigation(req)) return next(); const urlPath = requestPath(req); if (knownPages.includes(urlPath)) return next(); - if (fs.existsSync(path.join(outDir, urlPath))) return next(); + if (fs.existsSync(path.join(outDir, urlPath))) { next(); return; } const file = path.join(outDir, '404.html'); - if (!fs.existsSync(file)) return next(); + if (!fs.existsSync(file)) { next(); return; } res.statusCode = 404; res.setHeader('Content-Type', 'text/html'); res.end(fs.readFileSync(file, 'utf-8'));