Skip to content

A modern and elegant dashboard for network traffic visualization and analysis.

feat: Add API endpoint to test existing backend connections by ID and refactor About and Backend Config dialogs.

luolei82662b0b2760
diff --git a/Dockerfile b/Dockerfile
index 356e2ec..2f77d7f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -33,6 +33,11 @@ RUN pnpm --filter @clashmaster/collector build
ENV NODE_ENV=production
RUN pnpm --filter @clashmaster/web build
+# Create a minimal, deployable bundle for collector (production deps only)
+RUN pnpm --filter @clashmaster/collector deploy --prod /app/apps/collector-deploy && \
+ mkdir -p /app/apps/collector-deploy/dist && \
+ cp -r /app/apps/collector/dist/* /app/apps/collector-deploy/dist/
+
# Production stage
FROM node:22-alpine AS production
@@ -51,21 +56,15 @@ ENV NODE_ENV=production \
# Ensure data directory exists
RUN mkdir -p /app/data
-# Copy collector (with its node_modules for runtime dependencies)
-COPY --from=base /app/apps/collector/dist ./apps/collector/dist
-COPY --from=base /app/apps/collector/package.json ./apps/collector/
-COPY --from=base /app/apps/collector/node_modules ./apps/collector/node_modules
+# Copy collector (deploy bundle with production deps)
+COPY --from=base /app/apps/collector-deploy ./apps/collector
# Copy web (Next.js standalone output)
COPY --from=base /app/apps/web/.next/standalone ./apps/web/.next/standalone
COPY --from=base /app/apps/web/.next/static ./apps/web/.next/standalone/apps/web/.next/static
COPY --from=base /app/apps/web/public ./apps/web/.next/standalone/apps/web/public
-# Copy packages/shared (for collector dependencies)
-COPY --from=base /app/packages/shared ./packages/shared
-
-# Copy root node_modules for workspace dependencies
-COPY --from=base /app/node_modules ./node_modules
+# Copy root package.json (optional, for reference)
COPY --from=base /app/package.json ./
# Expose ports
diff --git a/apps/collector/src/api.ts b/apps/collector/src/api.ts
index 8967158..a87e0a9 100644
--- a/apps/collector/src/api.ts
+++ b/apps/collector/src/api.ts
@@ -497,6 +497,53 @@ export class APIServer {
return { message: `Backend ${listening ? 'started' : 'stopped'} listening` };
});
+ // Test existing backend connection (uses stored token)
+ app.post('/api/backends/:id/test', async (request, reply) => {
+ const { id } = request.params as { id: string };
+ const backend = this.db.getBackend(parseInt(id));
+ if (!backend) {
+ return reply.status(404).send({ error: 'Backend not found' });
+ }
+
+ try {
+ const wsUrl = backend.url.replace('http://', 'ws://').replace('https://', 'wss://');
+ const fullUrl = wsUrl.includes('/connections') ? wsUrl : `${wsUrl}/connections`;
+
+ const headers: Record<string, string> = {};
+ if (backend.token) {
+ headers['Authorization'] = `Bearer ${backend.token}`;
+ }
+
+ const WebSocket = (await import('ws')).default;
+
+ return new Promise((resolve) => {
+ const ws = new WebSocket(fullUrl, { headers, timeout: 5000 });
+
+ ws.on('open', () => {
+ ws.close();
+ resolve({ success: true, message: 'Connection successful' });
+ });
+
+ ws.on('error', (error: any) => {
+ resolve({ success: false, message: error.message || 'Connection failed' });
+ });
+
+ ws.on('close', (code: number) => {
+ if (code !== 1000 && code !== 1005) {
+ resolve({ success: false, message: `Connection closed with code ${code}` });
+ }
+ });
+
+ setTimeout(() => {
+ ws.terminate();
+ resolve({ success: false, message: 'Connection timeout' });
+ }, 5000);
+ });
+ } catch (error: any) {
+ return { success: false, message: error.message || 'Connection failed' };
+ }
+ });
+
// Test backend connection
app.post('/api/backends/test', async (request) => {
const { url, token } = request.body as { url: string; token?: string };
diff --git a/apps/web/components/about-dialog.tsx b/apps/web/components/about-dialog.tsx
index 9dec54e..940e354 100644
--- a/apps/web/components/about-dialog.tsx
+++ b/apps/web/components/about-dialog.tsx
@@ -1,14 +1,9 @@
"use client";
import Image from "next/image";
-import { ExternalLink, ArrowUpCircle, RefreshCw } from "lucide-react";
+import { ExternalLink, ArrowUpCircle, RefreshCw, X } from "lucide-react";
import { Button } from "@/components/ui/button";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { useTranslations } from "next-intl";
import { useVersionCheck } from "@/hooks/use-version-check";
@@ -25,15 +20,31 @@ export function AboutDialog({ open, onOpenChange }: AboutDialogProps) {
const { latestVersion, hasUpdate, isChecking, stars, checkNow } =
useVersionCheck(APP_VERSION);
+ if (!open) return null;
+
return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[420px]">
- <DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- About
- </DialogTitle>
- </DialogHeader>
- <div className="py-4">
+ <div
+ className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm flex items-center justify-center p-4"
+ onClick={(e) => {
+ if (e.target === e.currentTarget) onOpenChange(false);
+ }}>
+ <Card className="w-full max-w-[420px] relative">
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <CardTitle className="flex items-center gap-2">
+ About
+ </CardTitle>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8 rounded-full"
+ onClick={() => onOpenChange(false)}>
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </Button>
+ </div>
+ </CardHeader>
+ <CardContent>
{/* App Info */}
<div className="flex items-center gap-4 mb-4">
<div className="w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center overflow-hidden shrink-0">
@@ -162,8 +173,8 @@ export function AboutDialog({ open, onOpenChange }: AboutDialogProps) {
</div>
</a>
</div>
- </div>
- </DialogContent>
- </Dialog>
+ </CardContent>
+ </Card>
+ </div>
);
}
diff --git a/apps/web/components/backend-config-dialog.tsx b/apps/web/components/backend-config-dialog.tsx
index 7f23b64..abda8c3 100644
--- a/apps/web/components/backend-config-dialog.tsx
+++ b/apps/web/components/backend-config-dialog.tsx
@@ -355,6 +355,16 @@ export function BackendConfigDialog({
token: "",
});
+ const [editFormData, setEditFormData] = useState({
+ name: "",
+ host: "",
+ port: "9090",
+ ssl: false,
+ token: "",
+ });
+
+ const [showAddForm, setShowAddForm] = useState(false);
+
useEffect(() => {
if (open) {
loadBackends();
@@ -510,6 +520,7 @@ export function BackendConfigDialog({
ssl: false,
token: "",
});
+ setShowAddForm(false);
setShowVerifyAnimation(false);
setPendingBackend(null);
await loadBackends();
@@ -544,14 +555,14 @@ export function BackendConfigDialog({
const handleUpdate = async (id: number) => {
setLoading(true);
try {
- const url = buildUrl(formData.host, formData.port, formData.ssl);
+ const url = buildUrl(editFormData.host, editFormData.port, editFormData.ssl);
await api.updateBackend(id, {
- name: formData.name,
+ name: editFormData.name,
url,
- token: formData.token || undefined,
+ token: editFormData.token || undefined,
});
setEditingId(null);
- setFormData({ name: "", host: "", port: "9090", ssl: false, token: "" });
+ setEditFormData({ name: "", host: "", port: "9090", ssl: false, token: "" });
await loadBackends();
await onBackendChange?.();
} catch (error: any) {
@@ -647,7 +658,7 @@ export function BackendConfigDialog({
setTestingId(backend.id);
setTestResult(null);
try {
- const result = await api.testBackend(backend.url, backend.token);
+ const result = await api.testBackendById(backend.id);
setTestResult(result);
} catch (error: any) {
setTestResult({
@@ -684,18 +695,19 @@ export function BackendConfigDialog({
const startEdit = (backend: Backend) => {
setEditingId(backend.id);
- setFormData({
+ setEditFormData({
name: backend.name,
host: backend.host,
port: String(backend.port || 9090),
ssl: backend.url.startsWith("https"),
token: "",
});
+ setShowAddForm(false);
};
const cancelEdit = () => {
setEditingId(null);
- setFormData({ name: "", host: "", port: "9090", ssl: false, token: "" });
+ setEditFormData({ name: "", host: "", port: "9090", ssl: false, token: "" });
};
if (!open) return null;
@@ -762,10 +774,10 @@ export function BackendConfigDialog({
{t("name")}
</label>
<Input
- value={formData.name}
+ value={editFormData.name}
onChange={(e) =>
- setFormData({
- ...formData,
+ setEditFormData({
+ ...editFormData,
name: e.target.value,
})
}
@@ -778,10 +790,10 @@ export function BackendConfigDialog({
{t("host")}
</label>
<Input
- value={formData.host}
+ value={editFormData.host}
onChange={(e) =>
- setFormData({
- ...formData,
+ setEditFormData({
+ ...editFormData,
host: e.target.value,
})
}
@@ -796,10 +808,10 @@ export function BackendConfigDialog({
{t("port")}
</label>
<Input
- value={formData.port}
+ value={editFormData.port}
onChange={(e) =>
- setFormData({
- ...formData,
+ setEditFormData({
+ ...editFormData,
port: e.target.value,
})
}
@@ -809,9 +821,9 @@ export function BackendConfigDialog({
</div>
<div className="col-span-2 flex items-center gap-2 pt-5">
<Switch
- checked={formData.ssl}
+ checked={editFormData.ssl}
onCheckedChange={(checked) =>
- setFormData({ ...formData, ssl: checked })
+ setEditFormData({ ...editFormData, ssl: checked })
}
/>
<label className="text-sm">{t("useSsl")}</label>
@@ -823,14 +835,18 @@ export function BackendConfigDialog({
</label>
<Input
type="password"
- value={formData.token}
+ value={editFormData.token}
onChange={(e) =>
- setFormData({
- ...formData,
+ setEditFormData({
+ ...editFormData,
token: e.target.value,
})
}
- placeholder={t("tokenPlaceholder")}
+ placeholder={
+ backend.hasToken
+ ? t("tokenKeepPlaceholder")
+ : t("tokenPlaceholder")
+ }
className="h-9 mt-1"
/>
</div>
@@ -973,92 +989,119 @@ export function BackendConfigDialog({
</div>
)}
- {/* Add New Backend Form */}
- <div className="p-4 rounded-lg border border-dashed border-border bg-muted/50">
- <h4 className="text-sm font-medium mb-3 flex items-center gap-2">
- <Plus className="w-4 h-4" />
- {backends.length === 0 && isFirstTime
- ? t("firstTimeTitle")
- : t("addNew")}
- </h4>
- <div className="space-y-3">
- <div className="grid grid-cols-2 gap-3">
- <div>
- <label className="text-xs font-medium">
- {t("name")} *
- </label>
- <Input
- value={formData.name}
- onChange={(e) =>
- setFormData({ ...formData, name: e.target.value })
- }
- placeholder={t("namePlaceholder")}
- className="h-9 mt-1"
- />
+ {/* Add New Backend */}
+ {showAddForm || (isFirstTime && backends.length === 0) ? (
+ <div className="p-4 rounded-lg border border-dashed border-border bg-muted/50">
+ <h4 className="text-sm font-medium mb-3 flex items-center gap-2">
+ <Plus className="w-4 h-4" />
+ {backends.length === 0 && isFirstTime
+ ? t("firstTimeTitle")
+ : t("addNew")}
+ </h4>
+ <div className="space-y-3">
+ <div className="grid grid-cols-2 gap-3">
+ <div>
+ <label className="text-xs font-medium">
+ {t("name")} *
+ </label>
+ <Input
+ value={formData.name}
+ onChange={(e) =>
+ setFormData({ ...formData, name: e.target.value })
+ }
+ placeholder={t("namePlaceholder")}
+ className="h-9 mt-1"
+ />
+ </div>
+ <div>
+ <label className="text-xs font-medium">
+ {t("host")} *
+ </label>
+ <Input
+ value={formData.host}
+ onChange={(e) =>
+ setFormData({ ...formData, host: e.target.value })
+ }
+ placeholder="192.168.1.1"
+ className="h-9 mt-1"
+ />
+ </div>
</div>
- <div>
- <label className="text-xs font-medium">
- {t("host")} *
- </label>
- <Input
- value={formData.host}
- onChange={(e) =>
- setFormData({ ...formData, host: e.target.value })
- }
- placeholder="192.168.1.1"
- className="h-9 mt-1"
- />
+ <div className="grid grid-cols-3 gap-3">
+ <div>
+ <label className="text-xs font-medium">
+ {t("port")}
+ </label>
+ <Input
+ value={formData.port}
+ onChange={(e) =>
+ setFormData({ ...formData, port: e.target.value })
+ }
+ placeholder="9090"
+ className="h-9 mt-1"
+ />
+ </div>
+ <div className="col-span-2 flex items-center gap-2 pt-5">
+ <Switch
+ checked={formData.ssl}
+ onCheckedChange={(checked) =>
+ setFormData({ ...formData, ssl: checked })
+ }
+ />
+ <label className="text-sm">{t("useSsl")}</label>
+ </div>
</div>
- </div>
- <div className="grid grid-cols-3 gap-3">
<div>
<label className="text-xs font-medium">
- {t("port")}
+ {t("token")}
</label>
<Input
- value={formData.port}
+ type="password"
+ value={formData.token}
onChange={(e) =>
- setFormData({ ...formData, port: e.target.value })
+ setFormData({ ...formData, token: e.target.value })
}
- placeholder="9090"
+ placeholder={t("tokenPlaceholder")}
className="h-9 mt-1"
/>
</div>
- <div className="col-span-2 flex items-center gap-2 pt-5">
- <Switch
- checked={formData.ssl}
- onCheckedChange={(checked) =>
- setFormData({ ...formData, ssl: checked })
- }
- />
- <label className="text-sm">{t("useSsl")}</label>
+ <div className="flex gap-2">
+ {backends.length > 0 && (
+ <Button
+ variant="ghost"
+ onClick={() => {
+ setShowAddForm(false);
+ setFormData({ name: "", host: "", port: "9090", ssl: false, token: "" });
+ }}
+ className="flex-shrink-0">
+ <X className="w-4 h-4 mr-2" />
+ {commonT("cancel")}
+ </Button>
+ )}
+ <Button
+ onClick={handleAdd}
+ disabled={loading || !formData.name || !formData.host}
+ className="flex-1">
+ <Plus className="w-4 h-4 mr-2" />
+ {isFirstTime && backends.length === 0
+ ? t("saveAndContinue")
+ : t("addBackend")}
+ </Button>
</div>
</div>
- <div>
- <label className="text-xs font-medium">
- {t("token")}
- </label>
- <Input
- type="password"
- value={formData.token}
- onChange={(e) =>
- setFormData({ ...formData, token: e.target.value })
- }
- placeholder={t("tokenPlaceholder")}
- className="h-9 mt-1"
- />
- </div>
- <Button
- onClick={handleAdd}
- disabled={loading || !formData.name || !formData.host}
- className="w-full">
- <Plus className="w-4 h-4 mr-2" />
- {isFirstTime && backends.length === 0
- ? t("saveAndContinue")
- : t("addBackend")}
- </Button>
</div>
- </div>
+ ) : backends.length > 0 ? (
+ <Button
+ variant="outline"
+ className="w-full border-dashed"
+ onClick={() => {
+ cancelEdit();
+ setShowAddForm(true);
+ }}>
+ <Plus className="w-4 h-4 mr-2" />
+ {t("addNew")}
+ </Button>
+ ) : null}
</div>
) : activeTab === "database" ? (
// Database Tab
diff --git a/apps/web/components/interactive-proxy-stats.tsx b/apps/web/components/interactive-proxy-stats.tsx
index d27b1c5..3b970bd 100644
--- a/apps/web/components/interactive-proxy-stats.tsx
+++ b/apps/web/components/interactive-proxy-stats.tsx
@@ -198,6 +198,11 @@ export function InteractiveProxyStats({ data, activeBackendId }: InteractiveProx
return chartData.reduce((sum, item) => sum + item.value, 0);
}, [chartData]);
+ const topProxies = useMemo(
+ () => [...chartData].sort((a, b) => b.value - a.value).slice(0, 4),
+ [chartData]
+ );
+
const maxTotal = useMemo(() => {
if (!chartData.length) return 1;
return Math.max(...chartData.map(p => p.value));
@@ -405,7 +410,7 @@ export function InteractiveProxyStats({ data, activeBackendId }: InteractiveProx
}
return (
- <div className="space-y-6 overflow-x-hidden">
+ <div className="space-y-6">
{/* Top Section: Three Column Layout */}
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
{/* Left: Pie Chart (3 columns) */}
@@ -415,8 +420,8 @@ export function InteractiveProxyStats({ data, activeBackendId }: InteractiveProx
{t("distribution")}
</CardTitle>
</CardHeader>
- <CardContent>
- <div className="h-[200px] w-full">
+ <CardContent className="pt-2 pb-4">
+ <div className="h-[165px] w-full">
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Pie
@@ -448,6 +453,47 @@ export function InteractiveProxyStats({ data, activeBackendId }: InteractiveProx
</PieChart>
</ResponsiveContainer>
</div>
+ {topProxies.length > 0 && (
+ <div className="mt-2">
+ <p className="text-[10px] text-muted-foreground uppercase tracking-wider text-center">
+ Top 4
+ </p>
+ <div className="mt-1 space-y-1.5">
+ {topProxies.map((item, idx) => {
+ const rankBadgeClass = idx === 0
+ ? "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300"
+ : idx === 1
+ ? "bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"
+ : idx === 2
+ ? "bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300"
+ : "bg-muted text-muted-foreground";
+
+ return (
+ <div
+ key={item.rawName}
+ title={item.name}
+ className="flex items-center gap-1.5 min-w-0"
+ >
+ <span
+ className={cn(
+ "w-5 h-5 rounded-md text-[10px] font-bold flex items-center justify-center shrink-0",
+ rankBadgeClass
+ )}
+ >
+ {idx + 1}
+ </span>
+ <span
+ className="px-1.5 py-0.5 rounded-md text-[10px] font-medium text-white/90 truncate min-w-0"
+ style={{ backgroundColor: item.color }}
+ >
+ {item.name}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ )}
</CardContent>
</Card>
diff --git a/apps/web/components/interactive-rule-stats.tsx b/apps/web/components/interactive-rule-stats.tsx
index 1300660..5fa185e 100644
--- a/apps/web/components/interactive-rule-stats.tsx
+++ b/apps/web/components/interactive-rule-stats.tsx
@@ -183,6 +183,11 @@ export function InteractiveRuleStats({ data, activeBackendId }: InteractiveRuleS
return chartData.reduce((sum, item) => sum + item.value, 0);
}, [chartData]);
+ const topRules = useMemo(
+ () => [...chartData].sort((a, b) => b.value - a.value).slice(0, 4),
+ [chartData]
+ );
+
const maxTotal = useMemo(() => {
if (!chartData.length) return 1;
return Math.max(...chartData.map(r => r.value));
@@ -390,7 +395,7 @@ export function InteractiveRuleStats({ data, activeBackendId }: InteractiveRuleS
}
return (
- <div className="space-y-6 overflow-x-hidden">
+ <div className="space-y-6">
{/* Top Section: Three Column Layout */}
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
{/* Left: Pie Chart (3 columns) */}
@@ -400,8 +405,8 @@ export function InteractiveRuleStats({ data, activeBackendId }: InteractiveRuleS
{t("distribution")}
</CardTitle>
</CardHeader>
- <CardContent>
- <div className="h-[200px] w-full">
+ <CardContent className="pt-2 pb-4">
+ <div className="h-[165px] w-full">
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Pie
@@ -433,6 +438,47 @@ export function InteractiveRuleStats({ data, activeBackendId }: InteractiveRuleS
</PieChart>
</ResponsiveContainer>
</div>
+ {topRules.length > 0 && (
+ <div className="mt-2">
+ <p className="text-[10px] text-muted-foreground uppercase tracking-wider text-center">
+ Top 4
+ </p>
+ <div className="mt-1 space-y-1.5">
+ {topRules.map((item, idx) => {
+ const rankBadgeClass = idx === 0
+ ? "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300"
+ : idx === 1
+ ? "bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"
+ : idx === 2
+ ? "bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300"
+ : "bg-muted text-muted-foreground";
+
+ return (
+ <div
+ key={item.rawName}
+ title={item.name}
+ className="flex items-center gap-1.5 min-w-0"
+ >
+ <span
+ className={cn(
+ "w-5 h-5 rounded-md text-[10px] font-bold flex items-center justify-center shrink-0",
+ rankBadgeClass
+ )}
+ >
+ {idx + 1}
+ </span>
+ <span
+ className="px-1.5 py-0.5 rounded-md text-[10px] font-medium text-white/90 truncate min-w-0"
+ style={{ backgroundColor: item.color }}
+ >
+ {item.name}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ )}
</CardContent>
</Card>
diff --git a/apps/web/components/navigation.tsx b/apps/web/components/navigation.tsx
index bd7a491..c2fe57f 100644
--- a/apps/web/components/navigation.tsx
+++ b/apps/web/components/navigation.tsx
@@ -17,13 +17,8 @@ import {
} from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { BackendConfigDialog } from "./backend-config-dialog";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
import {
Tooltip,
TooltipContent,
@@ -200,153 +195,159 @@ export function Navigation({
/>
{/* About Dialog */}
- <Dialog open={aboutOpen} onOpenChange={setAboutOpen}>
- <DialogContent className="sm:max-w-[420px]">
- <DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <Info className="w-5 h-5 text-primary" />
- {aboutT("title")}
- </DialogTitle>
- </DialogHeader>
- <div className="py-4">
- {/* App Info */}
- <div className="flex items-center gap-4 mb-4">
- <div className="w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center overflow-hidden shrink-0">
- <Image
- src="/clash-master.png"
- alt="Clash Master"
- width={64}
- height={64}
- className="w-full h-full object-cover"
- />
- </div>
- <div>
- <h3 className="text-xl font-bold">{aboutT("projectName")}</h3>
- <p className="text-sm text-muted-foreground mt-1">
- {aboutT("description")}
- </p>
+ {aboutOpen && (
+ <div
+ className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm flex items-center justify-center p-4"
+ onClick={(e) => {
+ if (e.target === e.currentTarget) setAboutOpen(false);
+ }}>
+ <Card className="w-full max-w-[420px]">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Info className="w-5 h-5 text-primary" />
+ {aboutT("title")}
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
+ {/* App Info */}
+ <div className="flex items-center gap-4 mb-4">
+ <div className="w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center overflow-hidden shrink-0">
+ <Image
+ src="/clash-master.png"
+ alt="Clash Master"
+ width={64}
+ height={64}
+ className="w-full h-full object-cover"
+ />
+ </div>
+ <div>
+ <h3 className="text-xl font-bold">{aboutT("projectName")}</h3>
+ <p className="text-sm text-muted-foreground mt-1">
+ {aboutT("description")}
+ </p>
+ </div>
</div>
- </div>
- {/* All card rows with consistent spacing */}
- <div className="space-y-2">
- {/* Current Version */}
- <div className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50">
- <span className="text-sm font-medium">
- {aboutT("currentVersion")}
- </span>
- <span className="text-sm font-mono tabular-nums text-primary font-semibold">
- v{APP_VERSION}
- </span>
- </div>
+ {/* All card rows with consistent spacing */}
+ <div className="space-y-2">
+ {/* Current Version */}
+ <div className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50">
+ <span className="text-sm font-medium">
+ {aboutT("currentVersion")}
+ </span>
+ <span className="text-sm font-mono tabular-nums text-primary font-semibold">
+ v{APP_VERSION}
+ </span>
+ </div>
+
+ {/* Latest Version / Update Status */}
+ {hasUpdate && latestVersion ? (
+ <a
+ href={GITHUB_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center justify-between p-3 rounded-xl border min-h-[3rem] bg-emerald-500/5 border-emerald-500/20 hover:bg-emerald-500/10 transition-colors group">
+ <div>
+ <span className="text-sm font-medium">
+ {aboutT("latestVersion")}
+ </span>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ {aboutT("updateAvailable")} · v{APP_VERSION} → v
+ {latestVersion}
+ </p>
+ </div>
+ <div className="flex items-center gap-2 h-7 shrink-0">
+ <span className="text-sm font-mono tabular-nums text-emerald-500 font-semibold flex items-center gap-1.5">
+ <ArrowUpCircle className="w-4 h-4" />v{latestVersion}
+ </span>
+ <ExternalLink className="w-3.5 h-3.5 text-emerald-500 group-hover:translate-x-0.5 transition-transform" />
+ </div>
+ </a>
+ ) : (
+ <div className="flex items-center justify-between p-3 rounded-xl border min-h-[3rem] bg-secondary/50 border-border/50">
+ <span className="text-sm font-medium">
+ {aboutT("latestVersion")}
+ </span>
+ <div className="flex items-center gap-2 h-7 min-w-[5.5rem] justify-end">
+ {isChecking ? (
+ <span className="text-xs text-muted-foreground flex items-center gap-1.5">
+ <RefreshCw className="w-3 h-3 animate-spin" />
+ {aboutT("checkingUpdate")}
+ </span>
+ ) : latestVersion ? (
+ <span className="text-sm text-muted-foreground">
+ ✓ {aboutT("upToDate")}
+ </span>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 px-2 text-xs"
+ onClick={checkNow}>
+ <RefreshCw className="w-3 h-3 mr-1" />
+ {aboutT("checkNow")}
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
- {/* Latest Version / Update Status */}
- {hasUpdate && latestVersion ? (
+ {/* License */}
+ <div className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50">
+ <span className="text-sm font-medium">{aboutT("license")}</span>
+ <span className="text-sm text-muted-foreground">MIT</span>
+ </div>
+
+ {/* GitHub Link */}
<a
href={GITHUB_URL}
target="_blank"
rel="noopener noreferrer"
- className="flex items-center justify-between p-3 rounded-xl border min-h-[3rem] bg-emerald-500/5 border-emerald-500/20 hover:bg-emerald-500/10 transition-colors group">
- <div>
- <span className="text-sm font-medium">
- {aboutT("latestVersion")}
- </span>
- <p className="text-xs text-muted-foreground mt-0.5">
- {aboutT("updateAvailable")} · v{APP_VERSION} → v
- {latestVersion}
- </p>
+ className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50 hover:bg-secondary/80 hover:border-primary/30 transition-all group">
+ <div className="flex items-center gap-3">
+ <svg
+ viewBox="0 0 24 24"
+ className="w-5 h-5 fill-foreground shrink-0"
+ aria-hidden="true">
+ <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
+ </svg>
+ <div className="min-w-0">
+ <p className="text-sm font-medium">
+ {aboutT("openSource")}
+ </p>
+ <p className="text-xs text-muted-foreground truncate">
+ {GITHUB_URL}
+ </p>
+ </div>
</div>
- <div className="flex items-center gap-2 h-7 shrink-0">
- <span className="text-sm font-mono tabular-nums text-emerald-500 font-semibold flex items-center gap-1.5">
- <ArrowUpCircle className="w-4 h-4" />v{latestVersion}
+ <div className="flex items-center gap-2 shrink-0">
+ <span className="flex items-center gap-1 text-xs font-medium px-2 py-1 rounded-full min-w-[3rem] justify-center h-6">
+ {stars !== null ? (
+ <>
+ <svg
+ viewBox="0 0 16 16"
+ className="w-3.5 h-3.5 fill-amber-500 shrink-0"
+ aria-hidden="true">
+ <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25z" />
+ </svg>
+ <span className="text-amber-500 bg-amber-500/10 px-1.5 py-0.5 rounded-full">
+ {stars >= 1000
+ ? `${(stars / 1000).toFixed(1)}k`
+ : stars}
+ </span>
+ </>
+ ) : (
+ <span className="w-8 h-4 bg-secondary/80 rounded animate-pulse" />
+ )}
</span>
- <ExternalLink className="w-3.5 h-3.5 text-emerald-500 group-hover:translate-x-0.5 transition-transform" />
+ <ExternalLink className="w-4 h-4 text-muted-foreground group-hover:text-primary transition-colors" />
</div>
</a>
- ) : (
- <div className="flex items-center justify-between p-3 rounded-xl border min-h-[3rem] bg-secondary/50 border-border/50">
- <span className="text-sm font-medium">
- {aboutT("latestVersion")}
- </span>
- <div className="flex items-center gap-2 h-7 min-w-[5.5rem] justify-end">
- {isChecking ? (
- <span className="text-xs text-muted-foreground flex items-center gap-1.5">
- <RefreshCw className="w-3 h-3 animate-spin" />
- {aboutT("checkingUpdate")}
- </span>
- ) : latestVersion ? (
- <span className="text-sm text-muted-foreground">
- ✓ {aboutT("upToDate")}
- </span>
- ) : (
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2 text-xs"
- onClick={checkNow}>
- <RefreshCw className="w-3 h-3 mr-1" />
- {aboutT("checkNow")}
- </Button>
- )}
- </div>
- </div>
- )}
-
- {/* License */}
- <div className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50">
- <span className="text-sm font-medium">{aboutT("license")}</span>
- <span className="text-sm text-muted-foreground">MIT</span>
</div>
-
- {/* GitHub Link */}
- <a
- href={GITHUB_URL}
- target="_blank"
- rel="noopener noreferrer"
- className="flex items-center justify-between p-3 rounded-xl bg-secondary/50 border border-border/50 hover:bg-secondary/80 hover:border-primary/30 transition-all group">
- <div className="flex items-center gap-3">
- <svg
- viewBox="0 0 24 24"
- className="w-5 h-5 fill-foreground shrink-0"
- aria-hidden="true">
- <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
- </svg>
- <div className="min-w-0">
- <p className="text-sm font-medium">
- {aboutT("openSource")}
- </p>
- <p className="text-xs text-muted-foreground truncate">
- {GITHUB_URL}
- </p>
- </div>
- </div>
- <div className="flex items-center gap-2 shrink-0">
- <span className="flex items-center gap-1 text-xs font-medium px-2 py-1 rounded-full min-w-[3rem] justify-center h-6">
- {stars !== null ? (
- <>
- <svg
- viewBox="0 0 16 16"
- className="w-3.5 h-3.5 fill-amber-500 shrink-0"
- aria-hidden="true">
- <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25z" />
- </svg>
- <span className="text-amber-500 bg-amber-500/10 px-1.5 py-0.5 rounded-full">
- {stars >= 1000
- ? `${(stars / 1000).toFixed(1)}k`
- : stars}
- </span>
- </>
- ) : (
- <span className="w-8 h-4 bg-secondary/80 rounded animate-pulse" />
- )}
- </span>
- <ExternalLink className="w-4 h-4 text-muted-foreground group-hover:text-primary transition-colors" />
- </div>
- </a>
- </div>
- </div>
- </DialogContent>
- </Dialog>
+ </CardContent>
+ </Card>
+ </div>
+ )}
</>
);
}
diff --git a/apps/web/components/providers/theme-provider.tsx b/apps/web/components/providers/theme-provider.tsx
index 189a2b1..636858e 100644
--- a/apps/web/components/providers/theme-provider.tsx
+++ b/apps/web/components/providers/theme-provider.tsx
@@ -1,11 +1,44 @@
"use client";
import * as React from "react";
-import { ThemeProvider as NextThemesProvider } from "next-themes";
+import { ThemeProvider as NextThemesProvider, useTheme } from "next-themes";
+
+const THEME_COLORS = {
+ light: "#F5F7FA",
+ dark: "#0B0F19",
+} as const;
+
+function ThemeColorSync() {
+ const { resolvedTheme } = useTheme();
+
+ React.useEffect(() => {
+ const color = resolvedTheme === "dark" ? THEME_COLORS.dark : THEME_COLORS.light;
+ // Update all theme-color meta tags
+ const metas = document.querySelectorAll<HTMLMetaElement>('meta[name="theme-color"]');
+ if (metas.length > 0) {
+ metas.forEach((meta) => {
+ meta.removeAttribute("media");
+ meta.setAttribute("content", color);
+ });
+ } else {
+ const meta = document.createElement("meta");
+ meta.name = "theme-color";
+ meta.content = color;
+ document.head.appendChild(meta);
+ }
+ }, [resolvedTheme]);
+
+ return null;
+}
export function ThemeProvider({
children,
...props
}: React.ComponentProps<typeof NextThemesProvider>) {
- return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
+ return (
+ <NextThemesProvider {...props}>
+ <ThemeColorSync />
+ {children}
+ </NextThemesProvider>
+ );
}
diff --git a/apps/web/lib/api.ts b/apps/web/lib/api.ts
index 8cf6e9a..d5f7d8c 100644
--- a/apps/web/lib/api.ts
+++ b/apps/web/lib/api.ts
@@ -275,6 +275,9 @@ export const api = {
testBackend: (url: string, token?: string) =>
fetchJson<{ success: boolean; message: string }>(`${API_BASE}/backends/test`, 'POST', { url, token }),
+
+ testBackendById: (id: number) =>
+ fetchJson<{ success: boolean; message: string }>(`${API_BASE}/backends/${id}/test`, 'POST'),
// Database management
getDbStats: () =>
diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json
index 8a7eb83..d70bdc6 100644
--- a/apps/web/messages/en.json
+++ b/apps/web/messages/en.json
@@ -269,6 +269,7 @@
"useSsl": "Use HTTPS",
"namePlaceholder": "e.g., Router",
"tokenPlaceholder": "Optional, if set please fill in",
+ "tokenKeepPlaceholder": "Token already set, leave blank to keep",
"active": "Active",
"disabled": "Disabled",
"setActive": "Set Active",
diff --git a/apps/web/messages/zh.json b/apps/web/messages/zh.json
index 76e0cfd..731963a 100644
--- a/apps/web/messages/zh.json
+++ b/apps/web/messages/zh.json
@@ -268,6 +268,7 @@
"useSsl": "使用 HTTPS",
"namePlaceholder": "例如:路由器",
"tokenPlaceholder": "可选,如有设置请填写",
+ "tokenKeepPlaceholder": "已设置令牌,留空保持不变",
"active": "当前活跃",
"disabled": "已禁用",
"setActive": "设为活跃",
diff --git a/package.json b/package.json
index ee9a03d..eea0ab5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "clash-master",
- "version": "1.0.7",
+ "version": "1.0.8",
"private": true,
"workspaces": [
"apps/*",