From 6b0710fc82b05f1ebd352754192b122ffa5dd9da Mon Sep 17 00:00:00 2001 From: zihanjian Date: Tue, 3 Jun 2025 18:10:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EURL=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=E6=A3=80=E6=9F=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E7=94=A8=E6=88=B7=E5=9C=A8=E9=9D=9E=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=AE=BF=E9=97=AE=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E5=88=B0=E5=AE=98=E6=96=B9=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E5=92=8C=E5=AE=89=E5=85=A8=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/page.tsx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/app/page.tsx b/src/app/page.tsx index 82a1a86..ef40359 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -752,6 +752,41 @@ export default function Home() { setIsMounted(true); }, []); + // 添加URL重定向检查 + useEffect(() => { + // 检查是否在浏览器环境中 + if (typeof window !== 'undefined') { + const currentUrl = window.location.href; + const targetDomain = 'https://perlerbeads.zippland.com/'; + + // 检查当前URL是否不是目标域名 + if (!currentUrl.startsWith(targetDomain)) { + console.log(`当前URL: ${currentUrl}`); + console.log(`目标URL: ${targetDomain}`); + console.log('正在重定向到官方域名...'); + + // 保留当前路径和查询参数 + const currentPath = window.location.pathname; + const currentSearch = window.location.search; + const currentHash = window.location.hash; + + // 构建完整的目标URL + let redirectUrl = targetDomain; + + // 如果不是根路径,添加路径 + if (currentPath && currentPath !== '/') { + redirectUrl = redirectUrl.replace(/\/$/, '') + currentPath; + } + + // 添加查询参数和哈希 + redirectUrl += currentSearch + currentHash; + + // 执行重定向 + window.location.replace(redirectUrl); + } + } + }, []); // 只在组件首次挂载时执行 + // --- Download function (ensure filename includes palette) --- const handleDownloadRequest = (options?: GridDownloadOptions) => { // 调用移动到utils/imageDownloader.ts中的downloadImage函数