diff --git a/src/components/tool/network/dns.tsx b/src/components/tool/network/dns.tsx index 6659e40..cae5ca1 100644 --- a/src/components/tool/network/dns.tsx +++ b/src/components/tool/network/dns.tsx @@ -18,16 +18,16 @@ interface DNSResponse { } const DNS_RECORD_TYPES = [ - { value: "1", label: "A", description: "IPv4 地址" }, - { value: "28", label: "AAAA", description: "IPv6 地址" }, - { value: "5", label: "CNAME", description: "规范名称" }, - { value: "15", label: "MX", description: "邮件交换" }, - { value: "2", label: "NS", description: "名称服务器" }, - { value: "16", label: "TXT", description: "文本记录" }, - { value: "6", label: "SOA", description: "授权起始" }, - { value: "257", label: "CAA", description: "证书颁发机构授权" }, - { value: "12", label: "PTR", description: "指针记录" }, - { value: "33", label: "SRV", description: "服务记录" }, + { value: "1", label: "A", description: "IPv4 Address" }, + { value: "28", label: "AAAA", description: "IPv6 Address" }, + { value: "5", label: "CNAME", description: "Canonical Name" }, + { value: "15", label: "MX", description: "Mail Exchange" }, + { value: "2", label: "NS", description: "Name Server" }, + { value: "16", label: "TXT", description: "Text Record" }, + { value: "6", label: "SOA", description: "Start of Authority" }, + { value: "257", label: "CAA", description: "Certification Authority Authorization" }, + { value: "12", label: "PTR", description: "Pointer Record" }, + { value: "33", label: "SRV", description: "Service Record" }, ]; const getRecordTypeName = (type: number): string => { @@ -43,7 +43,7 @@ const Tool: FC = () => { const queryDNS = async () => { if (!domain.trim()) { - toast.error("请输入域名"); + toast.error("Please enter a domain name"); return; } @@ -54,7 +54,7 @@ const Tool: FC = () => { const startTime = performance.now(); try { - // 并发查询所有记录类型 + // Query all record types concurrently const queries = DNS_RECORD_TYPES.map((recordType) => fetch( `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent( @@ -80,11 +80,11 @@ const Tool: FC = () => { const endTime = performance.now(); setQueryTime(endTime - startTime); - // 合并所有结果并去重 + // Merge and deduplicate results const combinedResults = allResults.flat(); if (combinedResults.length > 0) { - // 按记录类型分组并去重 + // Group by record type and deduplicate const uniqueResults = Array.from( new Map( combinedResults.map((record) => [ @@ -95,16 +95,16 @@ const Tool: FC = () => { ); setResults(uniqueResults); - toast.success(`查询成功,找到 ${uniqueResults.length} 条记录`); + toast.success(`Query successful, found ${uniqueResults.length} record(s)`); } else { setResults([]); - toast.info("未找到记录"); + toast.info("No records found"); } } catch (error: unknown) { if (error instanceof Error) { - toast.error(`查询失败: ${error.message}`); + toast.error(`Query failed: ${error.message}`); } else { - toast.error("查询失败"); + toast.error("Query failed"); } setResults([]); } finally { @@ -122,34 +122,34 @@ const Tool: FC = () => {
- + setDomain(e.target.value)} onKeyPress={handleKeyPress} disabled={loading} /> - 将自动查询所有类型的 DNS 记录 + Will automatically query all DNS record types
{queryTime > 0 && (
- 查询耗时: {queryTime.toFixed(2)} ms + Query time: {queryTime.toFixed(2)} ms
)} {results.length > 0 && (
-
查询结果:
+
Query Results:
{results.map((record, index) => (
{ className="border rounded-md p-3 bg-card text-card-foreground" >
-
名称:
+
Name:
{record.name}
-
类型:
+
Type:
{getRecordTypeName(record.type)}
TTL:
-
{record.TTL} 秒
-
数据:
+
{record.TTL} seconds
+
Data:
{record.data}
diff --git a/src/components/tool/network/ping.tsx b/src/components/tool/network/ping.tsx index a5ba320..378226e 100644 --- a/src/components/tool/network/ping.tsx +++ b/src/components/tool/network/ping.tsx @@ -38,14 +38,14 @@ const Tool: FC = () => { const ping = async () => { if (!url.trim()) { - toast.error("请输入 URL"); + toast.error("Please enter a URL"); return; } const seq = ++seqRef.current; let targetUrl = url.trim(); - // 如果没有协议前缀,默认使用 https:// + // If no protocol prefix, default to https:// if (!targetUrl.startsWith("http://") && !targetUrl.startsWith("https://")) { targetUrl = `https://${targetUrl}`; } @@ -75,7 +75,7 @@ const Tool: FC = () => { const time = endTime - startTime; const errorMessage = - error instanceof Error ? error.message : "请求失败"; + error instanceof Error ? error.message : "Request failed"; const newResult: PingResult = { seq, @@ -117,7 +117,7 @@ const Tool: FC = () => { const startPing = () => { if (!url.trim()) { - toast.error("请输入 URL"); + toast.error("Please enter a URL"); return; } @@ -133,10 +133,10 @@ const Tool: FC = () => { }); seqRef.current = 0; - // 立即执行第一次 ping + // Execute first ping immediately ping(); - // 然后每秒执行一次 + // Then execute every second intervalRef.current = window.setInterval(ping, 1000); }; @@ -149,7 +149,7 @@ const Tool: FC = () => { }; useEffect(() => { - // 自动滚动到底部 + // Auto-scroll to bottom if (resultsContainerRef.current) { resultsContainerRef.current.scrollTop = resultsContainerRef.current.scrollHeight; @@ -157,7 +157,7 @@ const Tool: FC = () => { }, [results]); useEffect(() => { - // 清理定时器 + // Cleanup timer return () => { if (intervalRef.current) { clearInterval(intervalRef.current); @@ -172,9 +172,9 @@ const Tool: FC = () => {
- + setUrl(e.target.value)} disabled={running} @@ -184,11 +184,11 @@ const Tool: FC = () => {
{!running ? ( ) : ( )}
@@ -196,23 +196,23 @@ const Tool: FC = () => { {stats.sent > 0 && (
-
统计信息
+
Statistics
-
已发送:
-
{stats.sent} 包
-
已接收:
-
{stats.received} 包
-
丢失:
+
Sent:
+
{stats.sent} packets
+
Received:
+
{stats.received} packets
+
Lost:
- {stats.lost} 包 ({lossRate}%) + {stats.lost} packets ({lossRate}%)
{stats.received > 0 && ( <> -
最小延迟:
+
Min Latency:
{stats.min.toFixed(2)} ms
-
最大延迟:
+
Max Latency:
{stats.max.toFixed(2)} ms
-
平均延迟:
+
Avg Latency:
{stats.avg.toFixed(2)} ms
)} @@ -222,7 +222,7 @@ const Tool: FC = () => { {results.length > 0 && (
-
Ping 结果:
+
Ping Results:
{ ) : ( <> - seq={result.seq} 请求超时 + seq={result.seq} Request timeout {result.error && ` (${result.error})`} )} @@ -247,7 +247,7 @@ const Tool: FC = () => { {running && (
- 运行中... + Running...
)}
diff --git a/src/components/tool/network/speedtest.tsx b/src/components/tool/network/speedtest.tsx index 0626ce7..ea1d453 100644 --- a/src/components/tool/network/speedtest.tsx +++ b/src/components/tool/network/speedtest.tsx @@ -68,7 +68,7 @@ const Tool: FC = () => { return { performance: metrics }; } else { - // 如果没有详细的性能数据,只返回总时间 + // If no detailed performance data, only return total time return { performance: { dns: 0, @@ -144,13 +144,13 @@ const Tool: FC = () => { const startTest = async () => { if (!url.trim()) { - toast.error("请输入 URL"); + toast.error("Please enter a URL"); return; } let targetUrl = url.trim(); - // 如果没有协议前缀,默认使用 https:// + // If no protocol prefix, default to https:// if (!targetUrl.startsWith("http://") && !targetUrl.startsWith("https://")) { targetUrl = `https://${targetUrl}`; } @@ -164,24 +164,24 @@ const Tool: FC = () => { switch (testType) { case "performance": testResult = await testPerformance(targetUrl); - toast.success("性能测试完成"); + toast.success("Performance test completed"); break; case "download": testResult = await testDownloadSpeed(targetUrl); - toast.success("下载速度测试完成"); + toast.success("Download speed test completed"); break; case "upload": testResult = await testUploadSpeed(targetUrl); - toast.success("上传速度测试完成"); + toast.success("Upload speed test completed"); break; } setResult(testResult); } catch (error: unknown) { if (error instanceof Error) { - toast.error(`测试失败: ${error.message}`); + toast.error(`Test failed: ${error.message}`); } else { - toast.error("测试失败"); + toast.error("Test failed"); } } finally { setTesting(false); @@ -198,24 +198,24 @@ const Tool: FC = () => {
- ⚠️ CORS 限制说明 + ⚠️ CORS Restrictions
-

由于浏览器的 CORS 安全策略,部分网站可能无法直接测试。

-

建议测试以下类型的网站:

+

Due to browser CORS security policies, some websites cannot be tested directly.

+

Recommended websites to test:

    -
  • 支持 CORS 的公共 API
  • -
  • 您自己控制的网站(可配置 CORS 头)
  • -
  • 使用 CORS 代理服务
  • +
  • Public APIs with CORS support
  • +
  • Your own websites (with configured CORS headers)
  • +
  • Using CORS proxy services
- + setUrl(e.target.value)} onKeyPress={handleKeyPress} @@ -224,7 +224,7 @@ const Tool: FC = () => {
- +
{result && (
-
测试结果:
+
Test Results:
{result.performance && (
-
页面加载性能
+
Page Load Performance
{result.performance.dns > 0 && (
-
DNS 查询:
+
DNS Lookup:
{result.performance.dns.toFixed(2)} ms
)} {result.performance.tcp > 0 && (
-
TCP 连接:
+
TCP Connection:
{result.performance.tcp.toFixed(2)} ms
)} {result.performance.ssl > 0 && (
-
SSL 握手:
+
SSL Handshake:
{result.performance.ssl.toFixed(2)} ms
)} {result.performance.ttfb > 0 && (
-
首字节时间 (TTFB):
+
Time to First Byte (TTFB):
{result.performance.ttfb.toFixed(2)} ms
)} {result.performance.download > 0 && (
-
内容下载:
+
Content Download:
{result.performance.download.toFixed(2)} ms
)}
-
总时间:
+
Total Time:
{result.performance.total.toFixed(2)} ms
@@ -295,7 +295,7 @@ const Tool: FC = () => { {result.downloadSpeed !== undefined && (
-
下载速度
+
Download Speed
{result.downloadSpeed.toFixed(2)} Mbps
@@ -307,7 +307,7 @@ const Tool: FC = () => { {result.uploadSpeed !== undefined && (
-
上传速度
+
Upload Speed
{result.uploadSpeed.toFixed(2)} Mbps
@@ -321,13 +321,13 @@ const Tool: FC = () => { {testType === "download" && (
- 提示: 下载速度测试会下载目标 URL 的内容并计算速度 + Note: Download speed test will download content from the target URL and calculate speed
)} {testType === "upload" && (
- 提示: 上传速度测试会向目标 URL 发送 1MB 测试数据 + Note: Upload speed test will send 1MB of test data to the target URL
)}
diff --git a/src/components/tool/network/tcping.tsx b/src/components/tool/network/tcping.tsx index bc98050..f94338b 100644 --- a/src/components/tool/network/tcping.tsx +++ b/src/components/tool/network/tcping.tsx @@ -39,7 +39,7 @@ const Tool: FC = () => { const tcping = async () => { if (!host.trim()) { - toast.error("请输入主机名或 IP"); + toast.error("Please enter a hostname or IP"); return; } @@ -80,7 +80,7 @@ const Tool: FC = () => { const time = endTime - startTime; const errorMessage = - error instanceof Error ? error.message : "连接失败"; + error instanceof Error ? error.message : "Connection failed"; const newResult: TCPingResult = { seq, @@ -122,7 +122,7 @@ const Tool: FC = () => { const startTCPing = () => { if (!host.trim()) { - toast.error("请输入主机名或 IP"); + toast.error("Please enter a hostname or IP"); return; } @@ -177,9 +177,9 @@ const Tool: FC = () => {
- + setHost(e.target.value)} disabled={running} @@ -187,10 +187,10 @@ const Tool: FC = () => {
- + setPort(e.target.value)} disabled={running} @@ -202,7 +202,7 @@ const Tool: FC = () => {
{!running ? ( ) : ( )}
@@ -218,26 +218,26 @@ const Tool: FC = () => { {stats.sent > 0 && (
-
统计信息
+
Statistics
-
已发送:
-
{stats.sent} 次
-
成功:
-
{stats.received} 次
-
失败:
+
Sent:
+
{stats.sent} times
+
Success:
+
{stats.received} times
+
Failed:
- {stats.lost} 次 ({lossRate}%) + {stats.lost} times ({lossRate}%)
{stats.received > 0 && ( <> -
最小延迟:
+
Min Latency:
{stats.min.toFixed(2)} ms
-
最大延迟:
+
Max Latency:
{stats.max.toFixed(2)} ms
-
平均延迟:
+
Avg Latency:
{stats.avg.toFixed(2)} ms
-
端口状态:
-
开放
+
Port Status:
+
Open
)}
@@ -246,7 +246,7 @@ const Tool: FC = () => { {results.length > 0 && (
-
TCPing 结果:
+
TCPing Results:
{ ) : ( <> - seq={result.seq} port={port} 连接失败 + seq={result.seq} port={port} Connection failed {result.error && ` (${result.error})`} )} @@ -271,7 +271,7 @@ const Tool: FC = () => { {running && (
- 运行中... + Running...
)}