first commit
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Sync to CNB / sync (push) Has been cancelled
Delete old workflow runs / del_runs (push) Has been cancelled
Upstream Sync / Sync latest commits from upstream repo (push) Has been cancelled

This commit is contained in:
2026-01-30 16:57:44 +08:00
commit 3d175d75af
119 changed files with 35834 additions and 0 deletions

135
app/user-agent/page.tsx Normal file
View File

@@ -0,0 +1,135 @@
"use client";
import { useState, useEffect } from "react";
import { Monitor, Globe, Cpu, Info } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { toast } from "sonner";
export default function UAPage() {
const [ua, setUa] = useState("");
const [info, setInfo] = useState<any>(null);
useEffect(() => {
const currentUA = navigator.userAgent;
setUa(currentUA);
parseUA(currentUA);
}, []);
const parseUA = (userAgent: string) => {
if (!userAgent) return;
const browser = {
name: "未知浏览器",
version: ""
};
const os = {
name: "未知操作系统",
version: ""
};
// Simple Browser Detection
if (userAgent.indexOf("Edg") > -1) { browser.name = "Edge"; }
else if (userAgent.indexOf("Chrome") > -1) { browser.name = "Chrome"; }
else if (userAgent.indexOf("Firefox") > -1) { browser.name = "Firefox"; }
else if (userAgent.indexOf("Safari") > -1) { browser.name = "Safari"; }
// Simple OS Detection
if (userAgent.indexOf("Windows") > -1) { os.name = "Windows"; }
else if (userAgent.indexOf("Mac OS") > -1) { os.name = "macOS"; }
else if (userAgent.indexOf("Android") > -1) { os.name = "Android"; }
else if (userAgent.indexOf("iPhone") > -1 || userAgent.indexOf("iPad") > -1) { os.name = "iOS"; }
else if (userAgent.indexOf("Linux") > -1) { os.name = "Linux"; }
setInfo({ browser, os });
};
const resetToMine = () => {
const currentUA = navigator.userAgent;
setUa(currentUA);
parseUA(currentUA);
toast.success("已重置为当前浏览器 UA");
};
return (
<div className="space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500">
<div className="flex items-center space-x-4 border-b pb-4">
<div className="flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-slate-600 to-slate-800 shadow-lg">
<Monitor className="h-6 w-6 text-white" />
</div>
<div>
<h1 className="text-2xl font-bold tracking-tight">User-Agent </h1>
<p className="text-muted-foreground"> User-Agent </p>
</div>
</div>
<div className="grid gap-6">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-base">UA </CardTitle>
<Button variant="outline" size="sm" onClick={resetToMine}>使 UA</Button>
</CardHeader>
<CardContent>
<Textarea
value={ua}
onChange={(e) => {
setUa(e.target.value);
parseUA(e.target.value);
}}
className="font-mono min-h-25"
placeholder="请在此粘贴 User-Agent 字符串..."
/>
</CardContent>
</Card>
{info && (
<div className="grid md:grid-cols-2 gap-6">
<Card>
<CardHeader>
<CardTitle className="text-base flex items-center gap-2">
<Globe className="h-4 w-4 text-blue-500" />
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between border-b pb-2">
<span className="text-muted-foreground">/</span>
<span className="font-bold">{info.browser.name}</span>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="text-base flex items-center gap-2">
<Cpu className="h-4 w-4 text-orange-500" />
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between border-b pb-2">
<span className="text-muted-foreground"></span>
<span className="font-bold">{info.os.name}</span>
</div>
</CardContent>
</Card>
</div>
)}
<Card>
<CardHeader>
<CardTitle className="text-base flex items-center gap-2">
<Info className="h-4 w-4" />
User-Agent
</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground leading-relaxed">
User-Agent (UA) HTTP 使 UA
</CardContent>
</Card>
</div>
</div>
);
}