fix(layout): IPv6按钮顶栏内正常排版不遮挡 + 窄屏收缩;relay/my-ip/用户菜单等本次改动入库

This commit is contained in:
3970260761 committed 2026-11-11 15:03:56 +08:00
1 parent ea4e3deb50
commit 7b22e53d1a
8 files changed
+1050 -106

No files matched your search

+2
View File
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. See [standa
## Version 2026.11.01-it-tools-pro
### 📦 本次更新(2026-11-01)
- **顶栏排版修复**:「⚡ IPv6 直连」按钮改为顶栏内正常排列(不再绝对定位悬浮),与「授权应用」等控件不重叠;窄屏(≤900px)自动收缩为纯图标并收紧间距,任何窗口宽度都不溢出、不遮挡
- **热门地点扩容 + 测速历史快照**:热门地点延迟新增「百度」与「本省·运营商门户」(按你的 IPv4 归属自动匹配联通 10010 / 电信 189 / 移动 10086 / 广电 10099,悬停显示完整运营商与省份,未知运营商不插行);测速历史表新增「热门地点延迟快照」列——每次测速自动附带当时全部地点延迟(百度/本省运营商/镜像站/海外),跨线路、跨时间直接对照
- **代理 / VPN 检测**(免费不授权):本机IP查询页新增检测区——出口 IP 归属判定(proxycheck.io 数据库,区分家庭宽带/VPN/代理/数据中心/企业网络,IPv4+IPv6 分别判定)+ WebRTC STUN 泄漏实测(浏览器实测公网候选地址,若与主 IP 不一致则提示可能的真实出口,另显示本机内网 IP);浏览器无法直读系统代理开关,判定仅供参考,可一键重新检测
- **本机IP查询**(`/my-ip`,免费不授权):打开即显示**用户自己设备**的公网 IPv4 / IPv6 地址与中文归属地(多源容错、一键复制、不显示任何服务器信息);自动测量到 9 个热门地点(本站/清华TUNA/阿里云/腾讯云/华为云/中科大/香港Fedora/日本JAIST/Cloudflare)的延迟
- **IPv6 直连通道**:新增 `itv6.88531.cn`(4443 端口,双栈 nginx + DDNS);支持 IPv6 的用户页面横幅一键切换直连,访问速度更快;不支持的用户给出五步开启教程
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -381,7 +381,7 @@ tools:
my-ip:
title: 本机IP查询
description: 查询你设备的公网IPv4/IPv6地址与所属地(IPv6不支持时提供开启教程),代理/VPN检测(出口IP归属判定+WebRTC泄漏实测),本站已支持IPv6直连,测连接热门地点延迟,一键测试你到本站服务器的下载/上传网速并自动记录历史。
description: 查询你设备的公网IPv4/IPv6地址与所属地(IPv6不支持时提供开启教程),代理/VPN检测(出口IP归属判定+WebRTC泄漏实测),热门地点延迟实测(百度、本省运营商门户、全国镜像站与海外节点),测速历史自动记录延迟快照,本站已支持IPv6直连,一键测试你到本站服务器的下载/上传网速。
hash-text:
title: Hash 文本
+49 -67
View File
@@ -7,76 +7,34 @@ import { useCloudSync } from '@/composable/cloud-sync';
const { isLoggedIn, username, isAdmin, login, register, logout } = useUserAuth();
const { syncNow } = useCloudSync();
// ---- Cloudflare Turnstile ----
const CF_SITEKEY = '0x4AAAAAAFUO0U-CvL78Vr6y';
const cfToken = ref('');
const cfReady = ref(false);
let cfWidgetId = '';
// ---- 本地图片验证码(服务端出图,不依赖外网) ----
const captchaId = ref('');
const captchaImg = ref('');
const captchaCode = ref('');
declare global {
interface Window {
turnstile?: any;
__cfOnload?: () => void;
}
}
function loadTurnstileScript(): Promise<void> {
if (window.turnstile) {
return Promise.resolve();
}
return new Promise((resolve) => {
window.__cfOnload = () => resolve();
const s = document.createElement('script');
s.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js?onload=__cfOnload&render=explicit';
s.async = true;
document.head.appendChild(s);
});
}
function resetCf() {
cfToken.value = '';
if (window.turnstile && cfWidgetId) {
try {
window.turnstile.reset(cfWidgetId);
async function loadCaptcha() {
captchaCode.value = '';
try {
const res = await fetch('/relay/user/captcha');
const body = await res.json().catch(() => ({} as any));
if (body?.code === 200 && body.data?.id) {
captchaId.value = body.data.id;
captchaImg.value = `data:image/png;base64,${body.data.img}`;
}
catch { /* ignore */ }
}
}
async function mountCf() {
await loadTurnstileScript();
// wait until container is in DOM (modal just opened)
await new Promise(r => setTimeout(r, 80));
const el = document.querySelector('.cf-container');
if (!el || cfWidgetId) {
return;
}
cfWidgetId = window.turnstile.render(el as HTMLElement, {
sitekey: CF_SITEKEY,
theme: 'light',
size: 'flexible',
callback: (token: string) => {
cfToken.value = token;
},
'expired-callback': () => {
cfToken.value = '';
},
'error-callback': () => {
cfToken.value = '';
},
});
cfReady.value = true;
catch { /* 静默:提交时服务端会再校验 */ }
}
const showLogin = ref(false);
watch(showLogin, (v) => {
if (v) {
mountCf().catch(() => {});
loadCaptcha().catch(() => {});
}
else {
cfWidgetId = '';
cfToken.value = '';
captchaId.value = '';
captchaImg.value = '';
captchaCode.value = '';
}
});
const mode = ref<'login' | 'register'>('login');
@@ -105,10 +63,10 @@ async function submit() {
busy.value = true;
try {
if (mode.value === 'login') {
await login(formUser.value.trim(), formPass.value, cfToken.value);
await login(formUser.value.trim(), formPass.value, captchaId.value, captchaCode.value.trim());
}
else {
await register(formUser.value.trim(), formPass.value, cfToken.value);
await register(formUser.value.trim(), formPass.value, captchaId.value, captchaCode.value.trim());
}
showLogin.value = false;
formPass.value = '';
@@ -119,7 +77,8 @@ async function submit() {
}
catch (e: any) {
error.value = String(e?.message || e);
resetCf();
// 验证码单次有效,失败后必须换一张
loadCaptcha().catch(() => {});
}
finally {
busy.value = false;
@@ -182,8 +141,10 @@ function switchMode() {
<input v-model="formPass" class="user-input" type="password" placeholder="密码(至少 6 位)" :autocomplete="mode === 'login' ? 'current-password' : 'new-password'" @keyup.enter="submit">
<input v-if="mode === 'register'" v-model="formPass2" class="user-input" type="password" placeholder="确认密码" autocomplete="new-password" @keyup.enter="submit">
<div class="cf-wrap" :style="{ opacity: cfToken ? 0.4 : 1 }">
<div class="cf-container" />
<div class="captcha-row">
<input v-model="captchaCode" class="user-input captcha-input" placeholder="验证码(4位)" autocomplete="off" @keyup.enter="submit">
<img v-if="captchaImg" class="captcha-img" :src="captchaImg" alt="验证码" title="点击换一张" @click="loadCaptcha">
<a v-else href="javascript:;" class="captcha-reload" @click="loadCaptcha">获取验证码</a>
</div>
<div v-if="error" class="user-error">
@@ -198,7 +159,7 @@ function switchMode() {
<c-button size="small" @click="showLogin = false">
取消
</c-button>
<c-button size="small" type="primary" ml-8px :disabled="busy || !formUser || !formPass || !cfToken" @click="submit">
<c-button size="small" type="primary" ml-8px :disabled="busy || !formUser || !formPass || !captchaCode.trim() || !captchaId" @click="submit">
{{ busy ? '请稍候…' : (mode === 'login' ? '登录' : '注册并登录') }}
</c-button>
</div>
@@ -263,9 +224,30 @@ function switchMode() {
}
}
.cf-wrap {
.captcha-row {
display: flex;
gap: 8px;
align-items: center;
margin: 2px 0 8px;
transition: opacity 0.2s;
.captcha-input {
flex: 1;
margin: 0;
}
.captcha-img {
height: 40px;
border-radius: 4px;
cursor: pointer;
flex-shrink: 0;
}
.captcha-reload {
flex-shrink: 0;
font-size: 13px;
color: #18a058;
white-space: nowrap;
}
}
.user-mask {
+4 -4
View File
@@ -52,11 +52,11 @@ export function useUserAuth() {
const username = computed(() => state.value?.username ?? '');
const isAdmin = computed(() => state.value?.role === 'admin');
async function login(u: string, p: string, cfToken = '') {
async function login(u: string, p: string, captchaId = '', captchaCode = '') {
const { status, body } = await apiFetch('/user/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...licenseHeaders() },
body: JSON.stringify({ username: u, password: p, cf_token: cfToken }),
body: JSON.stringify({ username: u, password: p, captcha_id: captchaId, captcha_code: captchaCode }),
});
if (status !== 200) {
throw new Error(body.message || '登录失败');
@@ -66,11 +66,11 @@ export function useUserAuth() {
return body.data.username;
}
async function register(u: string, p: string, cfToken = '') {
async function register(u: string, p: string, captchaId = '', captchaCode = '') {
const { status, body } = await apiFetch('/user/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...licenseHeaders() },
body: JSON.stringify({ username: u, password: p, cf_token: cfToken }),
body: JSON.stringify({ username: u, password: p, captcha_id: captchaId, captcha_code: captchaCode }),
});
if (status !== 200) {
throw new Error(body.message || '注册失败');
+87
View File
@@ -49,6 +49,51 @@ const tools = computed<ToolCategory[]>(() => [
...toolsByCategory.value,
]);
// ---- 全站 IPv6 切换(公网入口 it.88531.cn ⇄ itv6.88531.cn:4443) ----
const V6_HOST = 'itv6.88531.cn';
const V6_PORT = 4443;
const onV6Host = ref(location.hostname === V6_HOST);
const onPublicHost = ['it.88531.cn', V6_HOST].includes(location.hostname);
const v6ok = ref(false);
const v6Switching = ref(false);
async function probeV6() {
// 结果缓存 10 分钟,避免每次开页都探测
try {
const c = JSON.parse(localStorage.getItem('it_v6_probe') || 'null');
if (c && typeof c.ok === 'boolean' && Date.now() - (c.ts || 0) < 600000) {
v6ok.value = c.ok;
return;
}
}
catch { /* 探测 */ }
let ok = false;
try {
const ctl = new AbortController();
const timer = setTimeout(() => ctl.abort(), 4000);
// api6.ipify.org 仅 AAAA:能连通即说明本机有 IPv6 出口
const r = await fetch('https://api6.ipify.org?format=json', { signal: ctl.signal, cache: 'no-store' });
clearTimeout(timer);
const j = await r.json();
ok = typeof j?.ip === 'string' && j.ip.includes(':');
}
catch { ok = false; }
v6ok.value = ok;
try { localStorage.setItem('it_v6_probe', JSON.stringify({ ok, ts: Date.now() })); }
catch { /* ignore */ }
}
function switchV6() {
if (v6Switching.value) {
return;
}
v6Switching.value = true;
const path = location.pathname + location.search + location.hash;
location.href = onV6Host.value
? `https://it.88531.cn${path}`
: `https://${V6_HOST}:${V6_PORT}${path}`;
}
// 右下角回到顶部火箭
const showTop = ref(false);
// 页面可能有多层 .n-layout-scroll-container(嵌套 n-layout),外层往往不滚、内层才滚;
@@ -70,6 +115,9 @@ function bindTopScroll() {
});
}
onMounted(() => {
if (onPublicHost) {
probeV6().catch(() => {});
}
// 等布局渲染后再绑定滚动容器(内层容器可能晚于挂载出现,多试几次)
let tries = 0;
const timer = setInterval(() => {
@@ -157,6 +205,24 @@ onBeforeUnmount(() => {
</c-button>
</RouterLink>
</c-tooltip>
<!-- 全站右上角:IPv6 直连切换(仅公网域名且探测到本机有 IPv6 时显示) -->
<c-tooltip
v-if="onV6Host || v6ok"
position="bottom"
:tooltip="onV6Host ? '当前 IPv6 直连入口,点击切回 IPv4 中转' : '检测到你的网络支持 IPv6,点击切换 IPv6 直连加速'"
>
<c-button
round
class="v6-switch"
:bordered="false"
:disabled="v6Switching"
@click="switchV6"
>
<template v-if="onV6Host">⇄ IPv4</template>
<template v-else>⚡ <span class="v6-text">IPv6 直连</span></template>
</c-button>
</c-tooltip>
</div>
<slot />
@@ -282,6 +348,27 @@ onBeforeUnmount(() => {
}
// 顶部导航:滚动时固定在最顶部(sticky),通栏贴顶遮挡滚动内容
.v6-switch {
// 顶栏内正常排版(紧跟「授权应用」之后),不悬浮、不遮挡
font-size: 13px;
white-space: nowrap;
flex-shrink: 0;
}
@media (max-width: 900px) {
// 窄屏顶栏放不下完整文字时收缩为纯图标,并收紧间距,避免溢出右边缘
.top-nav {
gap: 4px;
}
.v6-switch {
.v6-text {
display: none;
}
padding-left: 8px;
padding-right: 8px;
}
}
.top-nav {
position: sticky;
// -26px 抵消滚动容器 padding-top 内缩,使导航真正贴到视口最顶(0)
+1 -1
View File
@@ -35,7 +35,7 @@ const groups: { title: string; items: Item[] }[] = [
{
title: '原创工具',
items: [
{ name: '本机IP查询', icon: '网', desc: '仅显示你设备的公网IPv4/IPv6地址与所属地(多源容错+中文归属地+一键复制),代理/VPN检测(出口IP归属判定+WebRTC泄漏实测+内网IP),IPv6不支持时明示并给出开启教程,本站已支持IPv6直连(速度更快),网速测试为你的设备↔本站服务器真实收发计时并自动记录历史,进入页面自动测9个热门地点延迟', tag: '全新' },
{ name: '本机IP查询', icon: '网', desc: '仅显示你设备的公网IPv4/IPv6地址与所属地(多源容错+中文归属地+一键复制),代理/VPN检测(出口IP归属判定+WebRTC泄漏实测+内网IP),热门地点延迟实测(百度、本省运营商门户按归属自动匹配、全国镜像站+海外节点),测速历史自动记录各地点延迟快照(跨线路/跨时间对照),IPv6不支持时明示并给出开启教程,本站已支持IPv6直连(速度更快),网速测试为你的设备↔本站服务器真实收发计时', tag: '全新' },
{ name: 'Base64图片互转', icon: 'B', desc: 'Base64转图片与图片转Base64合一页双 Tab:三种输入形态(裸串/data:URI/CSS url())自动识别、图片类型魔数嗅探、输出三档格式实时切换、互转按钮带结果闭环跳转,纯浏览器本地不上传', tag: '全新' },
{ name: '批量条码生成', icon: '条', desc: 'EAN/UPC/Code128/Code39/DataMatrix 等 12 种码制,批量生成、打包下载,尺寸颜色字号可调', tag: '全新' },
{ name: '二维码条码识别与生成', icon: '扫', desc: '识别:上传/拖拽/粘贴一键解码(多码混合批量输出,本地 WASM 不上传);生成:自定义前景/背景颜色、中间插入本地 Logo 图片,生成后自动自扫验证可下载 PNG', tag: '全新' },
+54 -5
View File
@@ -99,6 +99,7 @@ async function loadIps() {
v4Geo.value = g4;
v6Geo.value = g6;
ipLoading.value = false;
ensureIspNode(); // 归属运营商已知 → 插入「本省运营商门户」延迟节点并补测
// 拿到地址后并行做代理/VPN 检测(不阻塞主卡片)
runProxyCheck();
rtcProbe();
@@ -237,10 +238,11 @@ async function copyIp(text: string, key: string) {
}
// ---------- 热门地点延迟(你的浏览器到各地点的实测延迟) ----------
type LatNode = { name: string; url: string; ms: number | null; st: 'wait' | 'run' | 'ok' | 'fail' };
type LatNode = { name: string; url: string; ms: number | null; st: 'wait' | 'run' | 'ok' | 'fail'; note?: string };
const latTesting = ref(false);
const nodes = ref<LatNode[]>([
{ name: '本站服务器', url: `${location.origin}/favicon.ico`, ms: null, st: 'wait' },
{ name: '百度', url: 'https://www.baidu.com/favicon.ico', ms: null, st: 'wait' },
{ name: '清华 TUNA(北京)', url: 'https://mirrors.tuna.tsinghua.edu.cn/', ms: null, st: 'wait' },
{ name: '阿里云镜像(杭州)', url: 'https://mirrors.aliyun.com/', ms: null, st: 'wait' },
{ name: '腾讯云镜像(广州)', url: 'https://mirrors.cloud.tencent.com/', ms: null, st: 'wait' },
@@ -251,6 +253,33 @@ const nodes = ref<LatNode[]>([
{ name: 'Cloudflare(海外)', url: 'https://speed.cloudflare.com/__down?bytes=0', ms: null, st: 'wait' },
]);
// 按用户 IPv4 归属运营商动态插入「本省运营商门户」节点(三大运营商+广电,无匹配则不插)
function ensureIspNode() {
if (nodes.value.some((n) => n.name.startsWith('本省'))) return;
const g = v4Geo.value;
const isp = `${g?.isp || ''} ${g?.as || ''}`;
const province = g?.regionName || '';
let portal = '';
let short = '';
if (/联通|Unicom/i.test(isp)) {
portal = 'https://www.10010.com/favicon.ico'; // favicon 直链无 302;首页会被风控挂到超时
short = '联通';
} else if (/电信|Telecom/i.test(isp)) {
portal = 'https://www.189.cn/favicon.ico';
short = '电信';
} else if (/移动|Mobile|铁通|Tietong/i.test(isp)) {
portal = 'https://www.10086.cn/'; // 移动 favicon 不可达,用首页(200 稳定)
short = '移动';
} else if (/广电|Broadnet/i.test(isp)) {
portal = 'https://www.10099.com.cn/favicon.ico';
short = '广电';
}
if (!portal) return; // 未知运营商(教育网/长城等)不插行
const node: LatNode = { name: `本省·${short}`, url: portal, ms: null, st: 'wait', note: province ? `${g?.isp || short} · ${province}` : (g?.isp || '') };
nodes.value.splice(1, 0, node);
ping(node); // 其余节点已在测,单独补测这一项
}
const latSummary = computed(() => {
const ok = nodes.value.filter((n) => n.st === 'ok' && n.ms != null);
if (!ok.length) return '';
@@ -422,6 +451,7 @@ interface SpeedRec {
ms: number; // 到本站延迟
route: 'IPv6 直连' | '公网中转'; // 测试时所走线路
host: string; // 测试时的访问域名
lat?: string; // 测速时点的热门地点延迟快照:"百度5 本省联通6 清华12 …"(空串=当时未测完)
}
const speedHistory = ref<SpeedRec[]>([]);
@@ -444,6 +474,14 @@ function saveSpeedHistory() {
}
}
// 把当前热门地点延迟压成短串快照(写入历史记录):"百度5 本省联通6 清华12 …"
function latSnapshot(): string {
return nodes.value
.filter((n) => n.st === 'ok' && n.ms != null)
.map((n) => `${n.name.replace(/([^)]*)/g, '').replace(/[\s·]/g, '')}${n.ms}`)
.join(' ');
}
function pushSpeedRec() {
speedHistory.value.unshift({
t: Date.now(),
@@ -452,6 +490,7 @@ function pushSpeedRec() {
ms: serverMs.value ?? 0,
route: onV6Host ? 'IPv6 直连' : '公网中转',
host: location.host,
lat: latSnapshot(),
});
speedHistory.value = speedHistory.value.slice(0, 20);
saveSpeedHistory();
@@ -606,6 +645,7 @@ onMounted(() => {
<span>下载 Mbps</span>
<span>上传 Mbps</span>
<span>延迟 ms</span>
<span>热门地点延迟快照</span>
</div>
<div v-for="r in speedHistory" :key="r.t" class="sp-hrow">
<span>{{ fmtTime(r.t) }}</span>
@@ -613,9 +653,10 @@ onMounted(() => {
<span class="c-down">{{ r.down }}</span>
<span class="c-up">{{ r.up }}</span>
<span class="c-ms">{{ r.ms }}</span>
<span class="c-lat">{{ r.lat || '—' }}</span>
</div>
</div>
<div class="sp-hist-tip">对比方法:在当前线路测一次 → 点横幅「切换 IPv6 直连」再测一次,两条线路的下载/上传/延迟直接在表里对照。</div>
<div class="sp-hist-tip">对比方法:在当前线路测一次 → 点横幅「切换 IPv6 直连」再测一次,下载/上传/延迟与各地点(百度/本省运营商/镜像站等)延迟直接在表里对照。</div>
</div>
</div>
@@ -676,7 +717,7 @@ onMounted(() => {
</div>
<div class="lat-grid">
<div v-for="n in nodes" :key="n.name" class="lat-card" :class="latCls(n)">
<span class="lat-name">{{ n.name }}</span>
<span class="lat-name" :title="n.note || ''">{{ n.name }}</span>
<span class="lat-ms">
{{ n.st === 'run' ? '测速中…' : n.st === 'fail' ? '超时' : n.st === 'ok' ? `${n.ms} ms` : '待测' }}
</span>
@@ -1140,7 +1181,7 @@ onMounted(() => {
.sp-hrow {
display: grid;
grid-template-columns: 1.1fr 1.1fr 1fr 1fr 0.9fr;
grid-template-columns: 1.1fr 1.1fr 1fr 1fr 0.9fr 2.4fr;
gap: 6px;
padding: 6px 4px;
align-items: center;
@@ -1208,8 +1249,16 @@ onMounted(() => {
}
}
.sp-hist-table .sp-hrow {
grid-template-columns: 1fr 1fr 1fr 1fr 0.8fr;
grid-template-columns: 0.9fr 1fr 0.8fr 0.8fr 0.7fr 2.6fr;
font-size: 12.5px;
}
.sp-hist-table .c-lat {
font-family: monospace;
font-size: 11.5px;
opacity: 0.85;
line-height: 1.6;
word-break: break-all;
}
}
</style>