From 77b928c44218e3d2edbdc14e2cde8494bf25c6f8 Mon Sep 17 00:00:00 2001 From: chenchun Date: Mon, 31 Aug 2026 20:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=83=8C=E6=99=AF=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=E7=BB=84=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/globals.css | 14 +++--- app/layout.tsx | 4 +- components/dom/BackgroundGrid.tsx | 75 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 components/dom/BackgroundGrid.tsx diff --git a/app/globals.css b/app/globals.css index 8293035..39bf52b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -38,16 +38,18 @@ body { color: #000; } -/* 核心:点阵网格背景 */ -.bg-dot-grid { - background-size: 24px 24px; - background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px); -} - .no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; } .no-scrollbar::-webkit-scrollbar { display: none; +} + +html, body { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE and Edge */ +} +html::-webkit-scrollbar, body::-webkit-scrollbar { + display: none; /* Chrome, Safari and Opera */ } \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index c0c450f..ed0fe13 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,7 @@ import localFont from "next/font/local"; import "./globals.css"; import SmoothScroller from "@/components/dom/SmoothScroller"; import Header from "@/components/dom/Header"; +import BackgroundGrid from "@/components/dom/BackgroundGrid"; const tiktokSans = localFont({ src: "./fonts/TikTokSans.ttf", @@ -34,7 +35,8 @@ export default function RootLayout({ }>) { return ( - + +
{children} diff --git a/components/dom/BackgroundGrid.tsx b/components/dom/BackgroundGrid.tsx new file mode 100644 index 0000000..15abe64 --- /dev/null +++ b/components/dom/BackgroundGrid.tsx @@ -0,0 +1,75 @@ +'use client'; + +import { useEffect, useState } from 'react'; + +export default function BackgroundGrid() { + const [size, setSize] = useState({ w: 375, h: 812 }); + + useEffect(() => { + const updateSize = () => { + setSize({ w: window.innerWidth, h: window.innerHeight }); + }; + updateSize(); + window.addEventListener('resize', updateSize); + return () => window.removeEventListener('resize', updateSize); + }, []); + + const { w, h } = size; + + // Calculate grid lines + // Responsive padding: lg is px-14 (56px), mobile is px-4 (16px) + const isDesktop = w >= 1024; + const paddingX = isDesktop ? 56 : 16; + const edgeOffset = paddingX + 0.5; // +0.5 for crisp SVG rendering + + const cols = 3; // Left, Center, Right + const rows = Math.ceil(h / 450) + 1; + + const vLines = Array.from({ length: cols }).map((_, i) => { + if (i === 0) return edgeOffset; + if (i === cols - 1) return w - edgeOffset; + return w / 2; + }); + + const hLines = Array.from({ length: rows }).map((_, i) => (i + 1) * 442); + + // Generate paths + let vPath = ''; + let hPath = ''; + let crossPath = ''; + + const crossSize = 6; // 12px total width/height for the cross + + vLines.forEach(x => { + hLines.forEach((y, i) => { + const startY = i === 0 ? 0 : hLines[i - 1] + 12; + const endY = y - 12; + vPath += `M${x} ${startY}V${endY} `; + + crossPath += `M${x} ${y - crossSize}V${y + crossSize} `; + crossPath += `M${x - crossSize} ${y}H${x + crossSize} `; + }); + const lastY = hLines[hLines.length - 1] + 12; + vPath += `M${x} ${lastY}V${h} `; + }); + + hLines.forEach(y => { + vLines.forEach((x, i) => { + const startX = i === 0 ? 0 : vLines[i - 1] + 12; + const endX = x - 12; + hPath += `M${startX} ${y}H${endX} `; + }); + const lastX = vLines[vLines.length - 1] + 12; + hPath += `M${lastX} ${y}H${w} `; + }); + + return ( +
+ + + + + +
+ ); +}