feat: 首访自动跳转 IPv4/IPv6 线路选择页 (v-fixed97)
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s
Release / release (push) Canceled after 0s
Release / docker (push) Canceled after 0s

This commit is contained in:
3970260761 committed 2026-11-09 16:37:12 +08:00
1 parent e34ec79d5a
commit 9ffb113ca5
5 files changed
+61 -4

No files matched your search

+2 -2
View File
@@ -33,7 +33,7 @@ COPY . .
RUN find ./src -type f -name "route.ts" -print0 \
| xargs -0 sed -i "s/export const runtime = 'edge';/export const runtime = 'nodejs';/g"
ENV DOCKER_ENV=true
ENV NEXT_PUBLIC_SITE_VERSION=fixed96
ENV NEXT_PUBLIC_SITE_VERSION=fixed97
# For Docker builds, force dynamic rendering to read runtime environment variables.
RUN sed -i "/const inter = Inter({ subsets: \['latin'] });/a export const dynamic = 'force-dynamic';" src/app/layout.tsx
@@ -52,7 +52,7 @@ ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0
ENV PORT=3000
ENV DOCKER_ENV=true
ENV NEXT_PUBLIC_SITE_VERSION=fixed96
ENV NEXT_PUBLIC_SITE_VERSION=fixed97
# 从构建器中复制 standalone 输出
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
+39 -2
View File
@@ -83,10 +83,31 @@ export default function IPv6Page() {
const choose = (which: 'v4' | 'v6') => {
const dest = which === 'v4' ? H.v4 : H.v6;
let targetBack = back;
try {
const s = sessionStorage.getItem('__v6back');
if (s) { targetBack = s; sessionStorage.removeItem('__v6back'); }
} catch (e) { /* ignore */ }
try { localStorage.setItem('__v6dest', which); } catch (e) { // ignore
// ignore
}
window.location.href = dest + back + window.location.search + window.location.hash;
// 去掉 search 里的 back 参数,避免透传到目标地址
const qs = new URLSearchParams(window.location.search);
qs.delete('back');
const searchStr = qs.toString() ? '?' + qs.toString() : '';
const u = new URL(dest);
const m = /^([^?#]*)(\?[^#]*)?(#.*)?$/.exec(targetBack) || [];
u.pathname = m[1] || '/';
if (m[2]) {
const q2 = new URLSearchParams(m[2].slice(1));
q2.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
}
if (searchStr) {
const q3 = new URLSearchParams(searchStr.slice(1));
q3.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
}
if (m[3]) u.hash = m[3];
window.location.href = u.toString();
};
const reprobe = () => {
@@ -104,7 +125,23 @@ export default function IPv6Page() {
try { localStorage.setItem('__v6dest', 'v6'); } catch (e) { // ignore
// ignore
}
window.location.href = H.v6 + back + window.location.search + window.location.hash;
let targetBack = back;
try {
const s = sessionStorage.getItem('__v6back');
if (s) { targetBack = s; sessionStorage.removeItem('__v6back'); }
} catch (e) { /* ignore */ }
const u = new URL(H.v6);
const m = /^([^?#]*)(\?[^#]*)?(#.*)?$/.exec(targetBack) || [];
u.pathname = m[1] || '/';
if (m[2]) {
const q2 = new URLSearchParams(m[2].slice(1));
q2.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
}
const qs = new URLSearchParams(window.location.search);
qs.delete('back');
qs.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
if (m[3]) u.hash = m[3];
window.location.href = u.toString();
};
return (
+2
View File
@@ -8,6 +8,7 @@ import { getConfig } from '@/lib/config';
import { SiteProvider } from '../components/SiteProvider';
import { ThemeProvider } from '../components/ThemeProvider';
import Ipv6FirstVisitGate from '../components/Ipv6FirstVisitGate';
const inter = Inter({ subsets: ['latin'] });
@@ -114,6 +115,7 @@ export default async function RootLayout({
disableTransitionOnChange
>
<SiteProvider siteName={siteName} announcement={announcement}>
<Ipv6FirstVisitGate />
{children}
</SiteProvider>
</ThemeProvider>
+1
View File
@@ -9,6 +9,7 @@ export default function Ipv6Button({ forceShow = false, compact = false, light =
return (
<button
onClick={() => {
try { sessionStorage.setItem('__v6back', location.pathname + location.search + location.hash); } catch {}
location.href = '/ipv6';
}}
title='切换 IPv4 / IPv6 线路'
+17
View File
@@ -0,0 +1,17 @@
'use client';
// 首次访问公网入口时跳转到 /ipv6 线路选择页(源码化恢复:旧版 patch_license.js V6-PROBE 在迁移时未搬入源码)
import { useEffect } from 'react';
export default function Ipv6FirstVisitGate() {
useEffect(() => {
try {
if (location.hostname !== 'tv.88531.cn') return; // 仅公网 IPv4 入口;LAN/IPv6 线路不跳转(避免循环)
if (location.pathname === '/ipv6') return;
if (localStorage.getItem('__v6dest')) return; // 已记住线路,不打扰
sessionStorage.setItem('__v6back', location.pathname + location.search + location.hash);
location.replace('/ipv6');
} catch {}
}, []);
return null;
}