'use client'; import { useEffect, useState } from 'react'; const V6 = 'https://tv6.88531.cn:4443'; const PROBE_URL = 'https://tv6.88531.cn:4443/api/license-config?_='; // 首次访问的线路推荐:不阻塞数据加载,检测到支持 IPv6 时浮层提示用户可切换 export default function LineRecommender() { const [show, setShow] = useState(false); useEffect(() => { try { // 已记住线路 / 不在 v6 入口 / 已提示过 → 不再弹 if (window.location.hostname === 'tv6.88531.cn') return; if (localStorage.getItem('__v6dest')) return; if (localStorage.getItem('__v6hint')) return; const cached = JSON.parse(localStorage.getItem('__v6probe') || 'null'); if (cached && Date.now() - cached.t < 120000) { if (cached.ok) setShow(true); return; } const c = new AbortController(); const ti = setTimeout(() => c.abort(), 5000); fetch(PROBE_URL + Date.now(), { mode: 'cors', signal: c.signal, cache: 'no-store', credentials: 'omit' }) .then((r) => { clearTimeout(ti); return r.json(); }) .then((jj) => { const ok = !!(jj && jj.code === 200 && jj.data); try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok })); } catch (e) { /* ignore */ } if (ok) setShow(true); }) .catch(() => { clearTimeout(ti); }); } catch (e) { /* ignore */ } }, []); if (!show) return null; const dismiss = (pick?: 'v6' | 'v4') => { try { localStorage.setItem('__v6hint', '1'); if (pick === 'v6') { localStorage.setItem('__v6dest', 'v6'); document.cookie = '__v6dest=v6; path=/; max-age=31536000; samesite=lax'; window.location.href = V6 + window.location.pathname + window.location.search; return; } if (pick === 'v4') { localStorage.setItem('__v6dest', 'v4'); document.cookie = '__v6dest=v4; path=/; max-age=31536000; samesite=lax'; } } catch (e) { /* ignore */ } setShow(false); }; return (

✅ 检测到你的网络支持 IPv6

推荐切换到 IPv6 线路,观影更流畅。

); }