refactor: update network tool components for improved user experience

- Translated UI text in DNS, Ping, TCPing, and Speed Test components from Chinese to English for better accessibility.
- Enhanced user prompts and labels for clarity, including error messages and button texts.
- Updated comments in the code to reflect the changes in language and improve code readability.
This commit is contained in:
typist
2025-10-29 05:51:10 +08:00
parent 3f7c81e892
commit 82c68471df
4 changed files with 110 additions and 110 deletions

View File

@@ -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 = () => {
<div className="flex flex-col gap-4 h-full">
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-2">
<label className="text-sm font-medium"> IP</label>
<label className="text-sm font-medium">Hostname or IP</label>
<Input
placeholder="例如: example.com 192.168.1.1"
placeholder="e.g. example.com or 192.168.1.1"
value={host}
onChange={(e) => setHost(e.target.value)}
disabled={running}
@@ -187,10 +187,10 @@ const Tool: FC = () => {
</div>
<div className="flex flex-col gap-2">
<label className="text-sm font-medium"></label>
<label className="text-sm font-medium">Port</label>
<Input
type="number"
placeholder="例如: 443"
placeholder="e.g. 443"
value={port}
onChange={(e) => setPort(e.target.value)}
disabled={running}
@@ -202,7 +202,7 @@ const Tool: FC = () => {
<div className="flex gap-2">
{!running ? (
<Button onClick={startTCPing} className="flex-1">
Start Test
</Button>
) : (
<Button
@@ -210,7 +210,7 @@ const Tool: FC = () => {
variant="destructive"
className="flex-1"
>
Stop
</Button>
)}
</div>
@@ -218,26 +218,26 @@ const Tool: FC = () => {
{stats.sent > 0 && (
<div className="border rounded-md p-3 bg-card text-card-foreground">
<div className="text-sm font-medium mb-2"></div>
<div className="text-sm font-medium mb-2">Statistics</div>
<div className="grid grid-cols-2 gap-2 text-sm">
<div className="text-muted-foreground">:</div>
<div>{stats.sent} </div>
<div className="text-muted-foreground">:</div>
<div>{stats.received} </div>
<div className="text-muted-foreground">:</div>
<div className="text-muted-foreground">Sent:</div>
<div>{stats.sent} times</div>
<div className="text-muted-foreground">Success:</div>
<div>{stats.received} times</div>
<div className="text-muted-foreground">Failed:</div>
<div>
{stats.lost} ({lossRate}%)
{stats.lost} times ({lossRate}%)
</div>
{stats.received > 0 && (
<>
<div className="text-muted-foreground">:</div>
<div className="text-muted-foreground">Min Latency:</div>
<div>{stats.min.toFixed(2)} ms</div>
<div className="text-muted-foreground">:</div>
<div className="text-muted-foreground">Max Latency:</div>
<div>{stats.max.toFixed(2)} ms</div>
<div className="text-muted-foreground">:</div>
<div className="text-muted-foreground">Avg Latency:</div>
<div>{stats.avg.toFixed(2)} ms</div>
<div className="text-muted-foreground">:</div>
<div className="text-green-500 font-medium"></div>
<div className="text-muted-foreground">Port Status:</div>
<div className="text-green-500 font-medium">Open</div>
</>
)}
</div>
@@ -246,7 +246,7 @@ const Tool: FC = () => {
{results.length > 0 && (
<div className="flex flex-col gap-2 flex-1 overflow-hidden">
<div className="text-sm font-medium">TCPing :</div>
<div className="text-sm font-medium">TCPing Results:</div>
<div
ref={resultsContainerRef}
className="flex-1 overflow-auto space-y-1 font-mono text-sm border rounded-md p-3 bg-card"
@@ -262,7 +262,7 @@ const Tool: FC = () => {
</>
) : (
<>
seq={result.seq} port={port}
seq={result.seq} port={port} Connection failed
{result.error && ` (${result.error})`}
</>
)}
@@ -271,7 +271,7 @@ const Tool: FC = () => {
{running && (
<div className="flex items-center gap-2 text-muted-foreground">
<Loader2 className="size-3 animate-spin" />
...
Running...
</div>
)}
</div>