From 43fdc71eeb31b84fb62f0f3ce3ace18cde622b9b Mon Sep 17 00:00:00 2001 From: zihanjian Date: Tue, 3 Jun 2025 20:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96URL=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E7=9A=84?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=9C=A8=E9=9D=9E?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E5=9F=9F=E5=90=8D=E8=AE=BF=E9=97=AE=E6=97=B6?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E9=87=8D=E5=AE=9A=E5=90=91=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=9C=A8=E6=9C=AC=E5=9C=B0=E7=8E=AF=E5=A2=83=E4=B8=AD?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E9=87=8D=E5=AE=9A=E5=90=91=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E5=BC=80=E5=8F=91=E4=BD=93=E9=AA=8C=E3=80=82=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=9B=BE=E5=83=8F=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=B0=B4=E5=8D=B0=E7=BB=98=E5=88=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E7=AE=80=E5=8C=96=E4=B8=8B=E8=BD=BD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=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 | 14 +++++++++++-- src/utils/imageDownloader.ts | 40 ------------------------------------ 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index ef40359..97bb26f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -757,10 +757,18 @@ export default function Home() { // 检查是否在浏览器环境中 if (typeof window !== 'undefined') { const currentUrl = window.location.href; + const currentHostname = window.location.hostname; const targetDomain = 'https://perlerbeads.zippland.com/'; - // 检查当前URL是否不是目标域名 - if (!currentUrl.startsWith(targetDomain)) { + // 排除localhost和127.0.0.1等本地开发环境 + const isLocalhost = currentHostname === 'localhost' || + currentHostname === '127.0.0.1' || + currentHostname.startsWith('192.168.') || + currentHostname.startsWith('10.') || + currentHostname.endsWith('.local'); + + // 检查当前URL是否不是目标域名,且不是本地开发环境 + if (!currentUrl.startsWith(targetDomain) && !isLocalhost) { console.log(`当前URL: ${currentUrl}`); console.log(`目标URL: ${targetDomain}`); console.log('正在重定向到官方域名...'); @@ -783,6 +791,8 @@ export default function Home() { // 执行重定向 window.location.replace(redirectUrl); + } else if (isLocalhost) { + console.log(`检测到本地开发环境 (${currentHostname}),跳过重定向`); } } }, []); // 只在组件首次挂载时执行 diff --git a/src/utils/imageDownloader.ts b/src/utils/imageDownloader.ts index a0c81e4..f0c95d1 100644 --- a/src/utils/imageDownloader.ts +++ b/src/utils/imageDownloader.ts @@ -421,44 +421,6 @@ export async function downloadImage({ M * downloadCellSize ); - // 添加水印 - 小红书标识,防止被截图去除 - // 主水印:放在网格右下角,带背景设计,清晰明显 - const watermarkFontSize = Math.max(12, Math.floor(downloadCellSize * 0.7)); - - // 计算主水印位置和尺寸 - const mainWatermarkText = '小红书@七卡瓦'; - ctx.font = `600 ${watermarkFontSize}px system-ui, -apple-system, sans-serif`; - const textMetrics = ctx.measureText(mainWatermarkText); - const textWidth = textMetrics.width; - const textHeight = watermarkFontSize; - - const mainWatermarkX = extraLeftMargin + axisLabelSize + N * downloadCellSize - textWidth - 15; - const mainWatermarkY = titleBarHeight + extraTopMargin + axisLabelSize + M * downloadCellSize - 15; - - // 绘制水印背景 - 半透明白色背景,增强可读性 - const bgPadding = 6; - ctx.fillStyle = 'rgba(255, 255, 255, 0.85)'; - ctx.beginPath(); - ctx.roundRect( - mainWatermarkX - bgPadding, - mainWatermarkY - textHeight - bgPadding, - textWidth + bgPadding * 2, - textHeight + bgPadding * 2, - 4 - ); - ctx.fill(); - - // 绘制水印边框 - 细边框增加设计感 - ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)'; - ctx.lineWidth = 1; - ctx.stroke(); - - // 绘制水印文字 - 深色,清晰可见 - ctx.fillStyle = '#374151'; // 深灰色,清晰但不刺眼 - ctx.textAlign = 'left'; - ctx.textBaseline = 'bottom'; - ctx.fillText(mainWatermarkText, mainWatermarkX, mainWatermarkY); - // 副水印:放在网格左上角,简洁版本 const secondaryWatermarkFontSize = Math.max(10, Math.floor(downloadCellSize * 0.5)); const secondaryText = '@七卡瓦'; @@ -490,8 +452,6 @@ export async function downloadImage({ ctx.textBaseline = 'bottom'; ctx.fillText(secondaryText, secondaryWatermarkX, secondaryWatermarkY); - - // 绘制统计信息 if (includeStats && colorCounts) { const colorKeys = Object.keys(colorCounts).sort(sortColorKeys);