Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c8a68b064 | ||
|
|
9ffb113ca5 | ||
|
|
e34ec79d5a |
No files matched your search
+2
-2
@@ -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=fixed98
|
||||
|
||||
# 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=fixed98
|
||||
|
||||
# 从构建器中复制 standalone 输出
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
|
||||
@@ -242,9 +242,16 @@ docker compose -f docker-compose.redis.yml down
|
||||
## 🐳 Docker 镜像
|
||||
|
||||
```bash
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:latest
|
||||
# 公网可拉(匿名)
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:latest # 固定版本
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:fixed96
|
||||
|
||||
# 腾讯云 TCR(东京,公网匿名)
|
||||
docker pull jpccr.ccs.tencentyun.com/jinghui/katelyatv:latest
|
||||
```
|
||||
|
||||
当前版本:**v-fixed96**
|
||||
|
||||
## 🔗 源码
|
||||
|
||||
- Gitea:https://gitea.88531.cn/jinghui/katelyatv
|
||||
|
||||
+41
-2
@@ -83,10 +83,32 @@ 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;
|
||||
document.cookie = `__v6dest=${which}; path=/; max-age=31536000; samesite=lax`;
|
||||
// 去掉 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 +126,24 @@ 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;
|
||||
document.cookie = '__v6dest=v6; path=/; max-age=31536000; samesite=lax';
|
||||
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 (
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 线路'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
'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;
|
||||
// middleware 已记住线路(cookie)即视为已选择,不再重复弹
|
||||
if (/(^|;\s*)__v6dest=/.test(document.cookie)) return;
|
||||
if (localStorage.getItem('__v6dest')) return; // 已记住线路,不打扰
|
||||
sessionStorage.setItem('__v6back', location.pathname + location.search + location.hash);
|
||||
location.replace('/ipv6');
|
||||
} catch {}
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
@@ -49,6 +49,19 @@ export async function middleware(request: NextRequest) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// 首访线路选择(源码化,替代旧 patches/patch_license.js 的 V6-PROBE):
|
||||
// 公网 IPv4 入口且未记住线路(cookie __v6dest 缺失)时,先跳 /ipv6 选择页再回来
|
||||
const hostName = (request.headers.get('host') || request.nextUrl.hostname || '').split(':')[0];
|
||||
if (
|
||||
hostName === 'tv.88531.cn' &&
|
||||
pathname !== '/warning' &&
|
||||
!request.cookies.get('__v6dest')
|
||||
) {
|
||||
const u = new URL('/ipv6', request.url);
|
||||
u.searchParams.set('back', pathname + request.nextUrl.search);
|
||||
return NextResponse.redirect(u);
|
||||
}
|
||||
|
||||
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
||||
|
||||
if (!process.env.AUTH_PASSWORD) {
|
||||
|
||||
Reference in new issue
Block a user