✨新增本机IP查询(/my-ip,Network,免费):IPv4/IPv6+中文归属地+9地点延迟+网速测试;🔧文档翻译切换本地LibreTranslate引擎,修复NewAPI限流429;relay新增/my-ip与/ip-geo免费端点;nginx /relay/补X-Real-IP头
This commit is contained in:
1 parent
f4f1b373de
commit
fdcd1f8de8
12 files changed
+736
-3
No files matched your search
@@ -40,7 +40,7 @@ useHead(head);
|
||||
const { t } = useI18n();
|
||||
|
||||
// 宽屏工具:不受 600px 限宽,占满可用宽度(画布/多栏类工具)
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker', '/signature-pad', '/ai-image-lab', '/ai-chat', '/copywriting', '/ai-gen', '/code-reader']);
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker', '/signature-pad', '/ai-image-lab', '/ai-chat', '/copywriting', '/ai-gen', '/code-reader', '/my-ip']);
|
||||
const isWide = computed(() => WIDE_TOOLS.has(route.path));
|
||||
|
||||
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
|
||||
|
||||
@@ -35,6 +35,7 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
{
|
||||
title: '原创工具',
|
||||
items: [
|
||||
{ name: '本机IP查询', icon: '网', desc: '公网IPv4/IPv6地址与所属地一键查询(多源容错+中文归属地+一键复制),进入页面自动测9个热门地点延迟,一键测试本机下载/上传网速', 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: '全新' },
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useRecentTools } from '@/composable/recent-tools';
|
||||
|
||||
// 近期新功能亮点(手动维护,新工具上线时加一条)
|
||||
const NEW_FEATURES = [
|
||||
{ path: '/my-ip', icon: '🌍', name: '本机IP查询', desc: '公网IPv4/IPv6地址与所属地一键查询,自动测9个热门地点延迟,一键测试当前下载上传网速' },
|
||||
{ path: '/code-reader', icon: '🧩', name: '二维码生成', desc: '识别工具内新能力:自定义颜色、中间插入本地 Logo 图,生成后自动自扫验证' },
|
||||
{ path: '/base64-image-converter', icon: '🔁', name: 'Base64图片互转', desc: 'Base64转图片与图片转Base64合一页,三格式自动识别,纯浏览器本地不上传' },
|
||||
{ path: '/image-tools', icon: '🖌️', name: '图片编辑·无痕改字', desc: 'PS式图层画笔选区,OCR点字框自动匹配字号颜色角度无缝改字' },
|
||||
|
||||
+2
-1
@@ -108,6 +108,7 @@ import { tool as urlEncoder } from './url-encoder';
|
||||
import { tool as urlParser } from './url-parser';
|
||||
import { tool as uuidGenerator } from './uuid-generator';
|
||||
import { tool as macAddressLookup } from './mac-address-lookup';
|
||||
import { tool as myIp } from './my-ip';
|
||||
import { tool as xmlFormatter } from './xml-formatter';
|
||||
import { tool as yamlViewer } from './yaml-viewer';
|
||||
|
||||
@@ -187,7 +188,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Network',
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator, myIp],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { World } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.my-ip.title'),
|
||||
path: '/my-ip',
|
||||
description: translate('tools.my-ip.description'),
|
||||
keywords: ['ip', 'ipv4', 'ipv6', '本机', '公网', '内网', '归属地', '网速', '测速', '延迟', 'ping', 'speed', 'address', 'location'],
|
||||
component: () => import('./my-ip.vue'),
|
||||
icon: World,
|
||||
});
|
||||
@@ -0,0 +1,697 @@
|
||||
<script setup lang="ts">
|
||||
// 本机IP查询:公网 IPv4/IPv6 + 归属地 + 热门地点延迟 + 网速测试(免费:纯前端 + 轻 relay 端点)
|
||||
type Geo = { country?: string; region?: string; city?: string; isp?: string; as?: string; lan?: boolean } | null;
|
||||
|
||||
// ---------- IP 查询 ----------
|
||||
const ipLoading = ref(true);
|
||||
const v4 = ref('');
|
||||
const v4Geo = ref<Geo>(null);
|
||||
const v6 = ref('');
|
||||
const v6Geo = ref<Geo>(null);
|
||||
const seenIp = ref('');
|
||||
const seenLan = ref(false);
|
||||
const seenGeo = ref<Geo>(null);
|
||||
const copied = ref('');
|
||||
|
||||
async function jfetch(url: string, ms = 8000): Promise<any> {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return await r.json();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
async function tfetch(url: string, ms = 6000): Promise<string> {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
const txt = (await r.text()).trim();
|
||||
if (txt.startsWith('{')) {
|
||||
try {
|
||||
const j = JSON.parse(txt);
|
||||
return String(j.ip || '');
|
||||
} catch {
|
||||
/* 非 JSON 就当纯文本 */
|
||||
}
|
||||
}
|
||||
return txt;
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
async function firstOf(urls: string[]): Promise<string> {
|
||||
for (const u of urls) {
|
||||
try {
|
||||
const ip = await tfetch(u);
|
||||
if (ip) return ip;
|
||||
} catch {
|
||||
/* 换下一个源 */
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
const V4_SRC = ['https://v4.ident.me/', 'https://api.ipify.org?format=json', 'https://ip.3322.org/'];
|
||||
const V6_SRC = ['https://api6.ipify.org?format=json', 'https://v6.ident.me/'];
|
||||
|
||||
function isV6(s: string): boolean {
|
||||
return s.includes(':');
|
||||
}
|
||||
|
||||
async function geoFor(ip: string): Promise<Geo> {
|
||||
if (!ip) return null;
|
||||
try {
|
||||
const j = await jfetch(`/relay/ip-geo?ip=${encodeURIComponent(ip)}`, 9000);
|
||||
return (j && j.data) || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadIps() {
|
||||
ipLoading.value = true;
|
||||
const [t4, t6, seen] = await Promise.all([
|
||||
firstOf(V4_SRC),
|
||||
firstOf(V6_SRC),
|
||||
jfetch('/relay/my-ip').catch(() => null),
|
||||
]);
|
||||
const sd: any = seen && seen.data ? seen.data : null;
|
||||
if (sd) {
|
||||
seenIp.value = sd.ip || '';
|
||||
seenLan.value = !!sd.lan;
|
||||
seenGeo.value = sd.geo || null;
|
||||
}
|
||||
// 公网 IPv4:外部服务优先;失败且服务器视角非内网时回退
|
||||
v4.value = t4 || (sd && !sd.lan && sd.ip && !String(sd.ip).includes(':') ? String(sd.ip) : '');
|
||||
// IPv6 必须含冒号才认(双栈源在无 v6 网络下会返回 v4)
|
||||
v6.value = isV6(t6) ? t6 : '';
|
||||
const [g4, g6] = await Promise.all([geoFor(v4.value), geoFor(v6.value)]);
|
||||
v4Geo.value = g4;
|
||||
v6Geo.value = g6;
|
||||
if (!seenGeo.value && seenIp.value) seenGeo.value = await geoFor(seenIp.value);
|
||||
ipLoading.value = false;
|
||||
}
|
||||
|
||||
function geoLine(g: Geo): string {
|
||||
if (!g) return '';
|
||||
if (g.lan) return '内网地址(局域网),无公网归属地';
|
||||
const place = [g.country, g.region, g.city].filter(Boolean).join(' · ');
|
||||
const isp = g.isp ? ` · ${g.isp}` : '';
|
||||
const asn = g.as ? `(${g.as})` : '';
|
||||
return (place || '未知归属地') + isp + asn;
|
||||
}
|
||||
|
||||
async function copyIp(text: string, key: string) {
|
||||
if (!text) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
copied.value = key;
|
||||
setTimeout(() => {
|
||||
if (copied.value === key) copied.value = '';
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
// ---------- 热门地点延迟 ----------
|
||||
type LatNode = { name: string; url: string; ms: number | null; st: 'wait' | 'run' | 'ok' | 'fail' };
|
||||
const latTesting = ref(false);
|
||||
const nodes = ref<LatNode[]>([
|
||||
{ name: '本站服务器', url: `${location.origin}/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' },
|
||||
{ name: '华为云镜像', url: 'https://mirrors.huaweicloud.com/', ms: null, st: 'wait' },
|
||||
{ name: '中科大 USTC(合肥)', url: 'https://mirrors.ustc.edu.cn/', ms: null, st: 'wait' },
|
||||
{ name: '香港 Fedora', url: 'https://mirror.hk.fedoraproject.org/', ms: null, st: 'wait' },
|
||||
{ name: '日本 JAIST', url: 'https://mirror.jaist.ac.jp/', ms: null, st: 'wait' },
|
||||
{ name: 'Cloudflare(海外)', url: 'https://speed.cloudflare.com/__down?bytes=0', ms: null, st: 'wait' },
|
||||
]);
|
||||
|
||||
const latSummary = computed(() => {
|
||||
const ok = nodes.value.filter((n) => n.st === 'ok' && n.ms != null);
|
||||
if (!ok.length) return '';
|
||||
const avg = Math.round(ok.reduce((s, n) => s + (n.ms || 0), 0) / ok.length);
|
||||
const best = Math.min(...ok.map((n) => n.ms || 0));
|
||||
return `平均 ${avg} ms · 最快 ${best} ms · ${ok.length}/${nodes.value.length} 个节点可达`;
|
||||
});
|
||||
|
||||
async function ping(n: LatNode) {
|
||||
n.st = 'run';
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 8000);
|
||||
const t0 = performance.now();
|
||||
try {
|
||||
const same = n.url.startsWith(location.origin);
|
||||
await fetch(n.url + (n.url.includes('?') ? '&' : '?') + '_t=' + Date.now(), {
|
||||
mode: same ? 'cors' : 'no-cors',
|
||||
cache: 'no-store',
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
n.ms = Math.round(performance.now() - t0);
|
||||
n.st = 'ok';
|
||||
} catch {
|
||||
n.ms = null;
|
||||
n.st = 'fail';
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
|
||||
async function runAllLatency() {
|
||||
if (latTesting.value) return;
|
||||
latTesting.value = true;
|
||||
await Promise.all(nodes.value.map(ping));
|
||||
latTesting.value = false;
|
||||
}
|
||||
|
||||
function latCls(n: LatNode): string {
|
||||
if (n.st === 'fail') return 'is-fail';
|
||||
if (n.st !== 'ok' || n.ms == null) return 'is-wait';
|
||||
if (n.ms < 60) return 'is-good';
|
||||
if (n.ms < 150) return 'is-ok';
|
||||
if (n.ms < 300) return 'is-mid';
|
||||
return 'is-slow';
|
||||
}
|
||||
|
||||
// ---------- 网速测试(Cloudflare 全球节点) ----------
|
||||
const sp = ref<'idle' | 'down' | 'up' | 'done' | 'error'>('idle');
|
||||
const spPct = ref(0);
|
||||
const spBytes = ref(0);
|
||||
const downMbps = ref(0);
|
||||
const upMbps = ref(0);
|
||||
const spMsg = ref('');
|
||||
|
||||
const transferredMb = computed(() => (spBytes.value / 1048576).toFixed(1));
|
||||
|
||||
async function fetchBytes(url: string, ms = 30000) {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
await r.arrayBuffer();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
function randBuf(len: number): ArrayBuffer {
|
||||
const buf = new Uint8Array(len);
|
||||
const W = 65536;
|
||||
for (let o = 0; o < len; o += W) crypto.getRandomValues(buf.subarray(o, Math.min(o + W, len)));
|
||||
return buf.buffer as ArrayBuffer;
|
||||
}
|
||||
|
||||
async function runSpeedTest() {
|
||||
if (sp.value === 'down' || sp.value === 'up') return;
|
||||
sp.value = 'down';
|
||||
spPct.value = 0;
|
||||
spBytes.value = 0;
|
||||
downMbps.value = 0;
|
||||
upMbps.value = 0;
|
||||
spMsg.value = '';
|
||||
try {
|
||||
// 预热连接(握手不计速)
|
||||
await fetchBytes('https://speed.cloudflare.com/__down?bytes=1048576', 20000);
|
||||
// 下载:5MB/块,至少 5s 且 15MB,上限 30s 或 120MB
|
||||
const DCH = 5 * 1024 * 1024;
|
||||
let got = 0;
|
||||
const t0 = performance.now();
|
||||
for (;;) {
|
||||
await fetchBytes('https://speed.cloudflare.com/__down?bytes=' + DCH);
|
||||
got += DCH;
|
||||
spBytes.value = got;
|
||||
const el = (performance.now() - t0) / 1000;
|
||||
spPct.value = Math.min(58, Math.round((el / 6) * 58));
|
||||
if ((el >= 5 && got >= 15 * 1024 * 1024) || el >= 30 || got >= 120 * 1024 * 1024) break;
|
||||
}
|
||||
const del = (performance.now() - t0) / 1000;
|
||||
downMbps.value = Math.round((got * 8) / del / 1e4) / 100;
|
||||
|
||||
// 上传:2MB/块,至少 4s 且 8MB,上限 20s 或 40MB
|
||||
sp.value = 'up';
|
||||
const payload = randBuf(2 * 1024 * 1024);
|
||||
let sent = 0;
|
||||
const u0 = performance.now();
|
||||
for (;;) {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 30000);
|
||||
try {
|
||||
const r = await fetch('https://speed.cloudflare.com/__up', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-store',
|
||||
headers: { 'Content-Type': 'application/octet-stream' },
|
||||
body: payload,
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
sent += payload.byteLength;
|
||||
spBytes.value = got + sent;
|
||||
const el = (performance.now() - u0) / 1000;
|
||||
spPct.value = 58 + Math.min(42, Math.round((el / 5) * 42));
|
||||
if ((el >= 4 && sent >= 8 * 1024 * 1024) || el >= 20 || sent >= 40 * 1024 * 1024) break;
|
||||
}
|
||||
const uel = (performance.now() - u0) / 1000;
|
||||
upMbps.value = Math.round((sent * 8) / uel / 1e4) / 100;
|
||||
spPct.value = 100;
|
||||
sp.value = 'done';
|
||||
} catch (e: any) {
|
||||
sp.value = 'error';
|
||||
spMsg.value =
|
||||
e && e.name === 'AbortError'
|
||||
? '测速超时:到测速节点不通,请稍后重试'
|
||||
: '测速失败:无法访问 Cloudflare 测速节点(可能被网络拦截),请稍后重试';
|
||||
}
|
||||
}
|
||||
|
||||
function grade(mbps: number): string {
|
||||
if (mbps >= 200) return '🚀 极速:多路 4K / 秒下大文件';
|
||||
if (mbps >= 100) return '⚡ 很快:4K 视频与大文件下载流畅';
|
||||
if (mbps >= 50) return '✅ 良好:1080p~4K 视频流畅';
|
||||
if (mbps >= 20) return '👍 中等:1080p 视频流畅';
|
||||
if (mbps >= 10) return '📶 偏慢:720p 视频可用';
|
||||
return '🐢 较慢:建议检查网络或更换线路';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadIps();
|
||||
runAllLatency();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="myip-root">
|
||||
<!-- IP 地址卡片 -->
|
||||
<div class="ip-row">
|
||||
<div class="ip-card">
|
||||
<div class="ip-card-head">
|
||||
<span class="ip-tag v4">IPv4</span>
|
||||
<span class="ip-label">公网地址</span>
|
||||
<button class="copy-btn" :disabled="!v4" @click="copyIp(v4, 'v4')">
|
||||
{{ copied === 'v4' ? '✓ 已复制' : '复制' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="ip-value" :class="{ loading: ipLoading && !v4 }">
|
||||
{{ v4 || (ipLoading ? '查询中…' : '未获取到(网络可能屏蔽了 IP 查询服务)') }}
|
||||
</div>
|
||||
<div class="ip-geo">{{ geoLine(v4Geo) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="ip-card">
|
||||
<div class="ip-card-head">
|
||||
<span class="ip-tag v6">IPv6</span>
|
||||
<span class="ip-label">公网地址</span>
|
||||
<button class="copy-btn" :disabled="!v6" @click="copyIp(v6, 'v6')">
|
||||
{{ copied === 'v6' ? '✓ 已复制' : '复制' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="ip-value" :class="{ loading: ipLoading && !v6 }">
|
||||
{{ v6 || (ipLoading ? '检测中…' : '未检测到 IPv6(运营商或路由器未开启)') }}
|
||||
</div>
|
||||
<div class="ip-geo">{{ v6 ? geoLine(v6Geo) : '' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="ip-card">
|
||||
<div class="ip-card-head">
|
||||
<span class="ip-tag" :class="seenLan ? 'lan' : 'view'">{{ seenLan ? '内网' : '视角' }}</span>
|
||||
<span class="ip-label">{{ seenLan ? '你的电脑在局域网中的地址' : '服务器视角的接入 IP' }}</span>
|
||||
<button class="copy-btn" :disabled="!seenIp" @click="copyIp(seenIp, 'seen')">
|
||||
{{ copied === 'seen' ? '✓ 已复制' : '复制' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="ip-value" :class="{ loading: ipLoading && !seenIp }">
|
||||
{{ seenIp || (ipLoading ? '查询中…' : '未获取到') }}
|
||||
</div>
|
||||
<div class="ip-geo">{{ seenLan ? '局域网地址(访问本工具的设备当前接入地址)' : geoLine(seenGeo) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ip-hint">
|
||||
进入页面自动查询:公网地址来自外部 IP 服务(多源容错),归属地由本站服务端查询(中文数据,带缓存);点击卡片右上角「复制」可复制地址。
|
||||
<button class="refresh-btn" :disabled="ipLoading" @click="loadIps()">{{ ipLoading ? '刷新中…' : '刷新 IP' }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 热门地点延迟 -->
|
||||
<div class="sec">
|
||||
<div class="sec-head">
|
||||
<h3>连接热门地点的速度</h3>
|
||||
<span class="sec-sub">进入页面自动测量你的浏览器到各地点的网络延迟(越低越快,点「重新测速」再测一轮)</span>
|
||||
<n-button size="large" :loading="latTesting" @click="runAllLatency()">重新测速</n-button>
|
||||
</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-ms">
|
||||
{{ n.st === 'run' ? '测速中…' : n.st === 'fail' ? '超时' : n.st === 'ok' ? `${n.ms} ms` : '待测' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lat-summary">{{ latSummary }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 网速测试 -->
|
||||
<div class="sec">
|
||||
<div class="sec-head">
|
||||
<h3>本机网速测试</h3>
|
||||
<span class="sec-sub">点击按钮测试你当前的下载 / 上传速度(Cloudflare 全球节点,最多消耗约 160MB 流量)</span>
|
||||
<n-button
|
||||
size="large"
|
||||
type="primary"
|
||||
:loading="sp === 'down' || sp === 'up'"
|
||||
@click="runSpeedTest()"
|
||||
>
|
||||
{{ sp === 'idle' ? '开始测速' : sp === 'down' ? '测速中(下载)…' : sp === 'up' ? '测速中(上传)…' : '重新测速' }}
|
||||
</n-button>
|
||||
</div>
|
||||
<div class="sp-bar">
|
||||
<div class="sp-fill" :style="{ width: spPct + '%' }"></div>
|
||||
</div>
|
||||
<div class="sp-meta">
|
||||
<span v-if="sp === 'down' || sp === 'up'">测速中,已传输 {{ transferredMb }} MB…</span>
|
||||
<span v-else-if="sp === 'done'">测速完成 · 共传输 {{ transferredMb }} MB</span>
|
||||
<span v-else-if="sp === 'error'">—</span>
|
||||
<span v-else>点击「开始测速」后自动进行下载与上传测试</span>
|
||||
</div>
|
||||
<div class="sp-results">
|
||||
<div class="sp-item">
|
||||
<div class="sp-num">{{ downMbps || '—' }}</div>
|
||||
<div class="sp-unit">Mbps 下载速度</div>
|
||||
<div class="sp-grade">{{ downMbps ? grade(downMbps) : '' }}</div>
|
||||
</div>
|
||||
<div class="sp-item">
|
||||
<div class="sp-num up">{{ upMbps || '—' }}</div>
|
||||
<div class="sp-unit">Mbps 上传速度</div>
|
||||
<div class="sp-grade">{{ upMbps ? grade(upMbps) : '' }}</div>
|
||||
</div>
|
||||
<div class="sp-item tip">
|
||||
<div class="sp-tip-t">测速原理</div>
|
||||
<div class="sp-tip">下载从 Cloudflare 节点拉取固定大小数据块计时,上传向节点推送随机数据块计时,结果为你到最近 Cloudflare 节点的实际吞吐。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="sp === 'error'" class="sp-error">{{ spMsg }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.myip-root {
|
||||
min-height: calc(100vh - 170px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
font-size: 15px;
|
||||
color: #1f2a44;
|
||||
}
|
||||
|
||||
/* ---- IP 卡片 ---- */
|
||||
.ip-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.ip-card {
|
||||
border: 1px solid #e5e9f2;
|
||||
border-radius: 12px;
|
||||
padding: 16px 18px;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 4px rgba(30, 60, 110, 0.05);
|
||||
}
|
||||
.ip-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ip-tag {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
padding: 2px 9px;
|
||||
border-radius: 6px;
|
||||
&.v4 {
|
||||
background: #e8f3ff;
|
||||
color: #1d6fe0;
|
||||
}
|
||||
&.v6 {
|
||||
background: #e9fbf1;
|
||||
color: #0d9f57;
|
||||
}
|
||||
&.lan {
|
||||
background: #fff4e5;
|
||||
color: #d97706;
|
||||
}
|
||||
&.view {
|
||||
background: #f1ecff;
|
||||
color: #6d4aff;
|
||||
}
|
||||
}
|
||||
.ip-label {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
}
|
||||
.copy-btn {
|
||||
margin-left: auto;
|
||||
font-size: 14px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #cfd8ea;
|
||||
background: #fff;
|
||||
color: #1d6fe0;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
&:hover:not(:disabled) {
|
||||
background: #e8f3ff;
|
||||
border-color: #1d6fe0;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
.ip-value {
|
||||
font-family: ui-monospace, 'SF Mono', Consolas, monospace;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
line-height: 1.35;
|
||||
min-height: 30px;
|
||||
&.loading {
|
||||
color: #94a3b8;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
.ip-geo {
|
||||
margin-top: 8px;
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
min-height: 21px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.ip-hint {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.refresh-btn {
|
||||
margin-left: 8px;
|
||||
font-size: 14px;
|
||||
padding: 3px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #cfd8ea;
|
||||
background: #fff;
|
||||
color: #1d6fe0;
|
||||
cursor: pointer;
|
||||
&:hover:not(:disabled) {
|
||||
background: #e8f3ff;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- 通用区块 ---- */
|
||||
.sec {
|
||||
border: 1px solid #e5e9f2;
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
background: #fff;
|
||||
flex: 1;
|
||||
}
|
||||
.sec-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 19px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.sec-sub {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ---- 延迟网格 ---- */
|
||||
.lat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.lat-card {
|
||||
border: 1px solid #e8edf6;
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
background: #fafcff;
|
||||
}
|
||||
.lat-name {
|
||||
font-size: 14.5px;
|
||||
color: #33415c;
|
||||
}
|
||||
.lat-ms {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.is-good .lat-ms {
|
||||
color: #0d9f57;
|
||||
}
|
||||
.is-ok .lat-ms {
|
||||
color: #1d6fe0;
|
||||
}
|
||||
.is-mid .lat-ms {
|
||||
color: #d97706;
|
||||
}
|
||||
.is-slow .lat-ms {
|
||||
color: #dc2626;
|
||||
}
|
||||
.is-fail .lat-ms,
|
||||
.is-wait .lat-ms {
|
||||
color: #94a3b8;
|
||||
font-size: 14.5px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.is-fail {
|
||||
background: #fff5f5;
|
||||
}
|
||||
.lat-summary {
|
||||
margin-top: 12px;
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
min-height: 21px;
|
||||
}
|
||||
|
||||
/* ---- 网速 ---- */
|
||||
.sp-bar {
|
||||
height: 14px;
|
||||
background: #eef2f8;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
margin: 6px 0 10px;
|
||||
}
|
||||
.sp-fill {
|
||||
height: 100%;
|
||||
width: 0;
|
||||
background: linear-gradient(90deg, #1d6fe0, #0d9f57);
|
||||
transition: width 0.3s;
|
||||
}
|
||||
.sp-meta {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
margin-bottom: 14px;
|
||||
min-height: 21px;
|
||||
}
|
||||
.sp-results {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.sp-item {
|
||||
background: #f7f9fd;
|
||||
border: 1px solid #e8edf6;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.sp-num {
|
||||
font-size: 34px;
|
||||
font-weight: 800;
|
||||
color: #1d6fe0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.2;
|
||||
&.up {
|
||||
color: #0d9f57;
|
||||
}
|
||||
}
|
||||
.sp-unit {
|
||||
font-size: 14.5px;
|
||||
color: #5b6b85;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.sp-grade {
|
||||
margin-top: 8px;
|
||||
font-size: 15px;
|
||||
color: #33415c;
|
||||
min-height: 22px;
|
||||
}
|
||||
.sp-item.tip {
|
||||
text-align: left;
|
||||
}
|
||||
.sp-tip-t {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #33415c;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.sp-tip {
|
||||
font-size: 14.5px;
|
||||
color: #5b6b85;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.sp-error {
|
||||
color: #dc2626;
|
||||
font-size: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.sec-head {
|
||||
h3 {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -183,7 +183,7 @@ async function translateOne(job: any) {
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', job.file);
|
||||
fd.append('to', langName(docTo.value));
|
||||
fd.append('to', docTo.value); // 传语言码,服务端本地引擎按码翻译(旧标签格式也兼容)
|
||||
// 单文件超时保护:超过 8 分钟视为失败
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 8 * 60 * 1000);
|
||||
|
||||
Reference in new issue
Block a user