mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 20:15:40 +00:00
feat(ui): Enhance web overview with new components and data
This commit is contained in:
1 parent
d77f07e093
commit
cc1655624c
8 files changed
+348
-70
No files matched your search
@@ -9,6 +9,8 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { getCcsDir, loadConfig } from '../utils/config-manager';
|
import { getCcsDir, loadConfig } from '../utils/config-manager';
|
||||||
import { runHealthChecks } from './health-service';
|
import { runHealthChecks } from './health-service';
|
||||||
|
import { getAllAuthStatus, initializeAccounts } from '../cliproxy/auth-handler';
|
||||||
|
import { getVersion } from '../utils/version';
|
||||||
|
|
||||||
export const overviewRoutes = Router();
|
export const overviewRoutes = Router();
|
||||||
|
|
||||||
@@ -20,14 +22,25 @@ overviewRoutes.get('/', (_req: Request, res: Response) => {
|
|||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
|
|
||||||
const profileCount = Object.keys(config.profiles).length;
|
const profileCount = Object.keys(config.profiles).length;
|
||||||
const cliproxyCount = Object.keys(config.cliproxy || {}).length;
|
const cliproxyVariantCount = Object.keys(config.cliproxy || {}).length;
|
||||||
|
|
||||||
|
// Count authenticated built-in providers (gemini, codex, agy, qwen, iflow)
|
||||||
|
initializeAccounts();
|
||||||
|
const authStatuses = getAllAuthStatus();
|
||||||
|
const authenticatedProviderCount = authStatuses.filter((s) => s.authenticated).length;
|
||||||
|
|
||||||
|
// Total CLIProxy = custom variants + authenticated providers
|
||||||
|
const totalCliproxyCount = cliproxyVariantCount + authenticatedProviderCount;
|
||||||
|
|
||||||
// Get quick health summary
|
// Get quick health summary
|
||||||
const health = runHealthChecks();
|
const health = runHealthChecks();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
version: getVersion(),
|
||||||
profiles: profileCount,
|
profiles: profileCount,
|
||||||
cliproxy: cliproxyCount,
|
cliproxy: totalCliproxyCount,
|
||||||
|
cliproxyVariants: cliproxyVariantCount,
|
||||||
|
cliproxyProviders: authenticatedProviderCount,
|
||||||
accounts: getAccountCount(),
|
accounts: getAccountCount(),
|
||||||
health: {
|
health: {
|
||||||
status:
|
status:
|
||||||
@@ -38,8 +51,11 @@ overviewRoutes.get('/', (_req: Request, res: Response) => {
|
|||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
res.json({
|
res.json({
|
||||||
|
version: getVersion(),
|
||||||
profiles: 0,
|
profiles: 0,
|
||||||
cliproxy: 0,
|
cliproxy: 0,
|
||||||
|
cliproxyVariants: 0,
|
||||||
|
cliproxyProviders: 0,
|
||||||
accounts: 0,
|
accounts: 0,
|
||||||
health: { status: 'error', passed: 0, total: 0 },
|
health: { status: 'error', passed: 0, total: 0 },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function ConnectionIndicator() {
|
|||||||
const { status } = useWebSocket();
|
const { status } = useWebSocket();
|
||||||
|
|
||||||
const statusConfig = {
|
const statusConfig = {
|
||||||
connected: { icon: Wifi, color: 'text-green-500', label: 'Connected' },
|
connected: { icon: Wifi, color: 'text-green-600', label: 'Connected' },
|
||||||
connecting: { icon: Wifi, color: 'text-yellow-500', label: 'Connecting...' },
|
connecting: { icon: Wifi, color: 'text-yellow-500', label: 'Connecting...' },
|
||||||
disconnected: { icon: WifiOff, color: 'text-red-500', label: 'Disconnected' },
|
disconnected: { icon: WifiOff, color: 'text-red-500', label: 'Disconnected' },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface HealthCheck {
|
|||||||
const statusConfig = {
|
const statusConfig = {
|
||||||
ok: {
|
ok: {
|
||||||
icon: CheckCircle,
|
icon: CheckCircle,
|
||||||
color: 'text-green-500',
|
color: 'text-green-600',
|
||||||
bg: 'bg-green-50 dark:bg-green-900/20',
|
bg: 'bg-green-50 dark:bg-green-900/20',
|
||||||
border: 'border-green-200 dark:border-green-800',
|
border: 'border-green-200 dark:border-green-800',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { CcsLogo } from '@/components/ccs-logo';
|
||||||
|
import { CheckCircle2, AlertCircle, XCircle } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
|
interface HeroSectionProps {
|
||||||
|
version?: string;
|
||||||
|
healthStatus?: 'ok' | 'warning' | 'error';
|
||||||
|
healthPassed?: number;
|
||||||
|
healthTotal?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusConfig = {
|
||||||
|
ok: {
|
||||||
|
icon: CheckCircle2,
|
||||||
|
label: 'All Systems Operational',
|
||||||
|
color: 'text-green-600',
|
||||||
|
badgeBg: 'bg-green-500/10 text-green-600 border-green-500/20',
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
icon: AlertCircle,
|
||||||
|
label: 'Some Issues Detected',
|
||||||
|
color: 'text-yellow-500',
|
||||||
|
badgeBg: 'bg-yellow-500/10 text-yellow-500 border-yellow-500/20',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
icon: XCircle,
|
||||||
|
label: 'Action Required',
|
||||||
|
color: 'text-red-500',
|
||||||
|
badgeBg: 'bg-red-500/10 text-red-500 border-red-500/20',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function HeroSection({
|
||||||
|
version = '5.0.0',
|
||||||
|
healthStatus = 'ok',
|
||||||
|
healthPassed = 0,
|
||||||
|
healthTotal = 0,
|
||||||
|
}: HeroSectionProps) {
|
||||||
|
const status = statusConfig[healthStatus];
|
||||||
|
const StatusIcon = status.icon;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30 p-6">
|
||||||
|
{/* Subtle background pattern */}
|
||||||
|
<div className="absolute inset-0 opacity-[0.03] pointer-events-none">
|
||||||
|
<div
|
||||||
|
className="absolute inset-0"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)`,
|
||||||
|
backgroundSize: '24px 24px',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="relative flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||||
|
{/* Left: Logo and Welcome */}
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<CcsLogo size="lg" showText={false} />
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<h1 className="text-2xl font-bold">CCS Config</h1>
|
||||||
|
<Badge variant="outline" className="font-mono text-xs">
|
||||||
|
v{version}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<p className="text-muted-foreground text-sm mt-1">Claude Code Switch Dashboard</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right: Health Status */}
|
||||||
|
<div className={cn('flex items-center gap-3 px-4 py-2 rounded-lg border', status.badgeBg)}>
|
||||||
|
<StatusIcon className={cn('w-5 h-5', status.color)} />
|
||||||
|
<div>
|
||||||
|
<p className={cn('text-sm font-medium', status.color)}>{status.label}</p>
|
||||||
|
{healthTotal > 0 && (
|
||||||
|
<p className="text-xs opacity-80">
|
||||||
|
{healthPassed}/{healthTotal} checks passed
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Copy, Check, Terminal } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
|
interface CommandSnippet {
|
||||||
|
label: string;
|
||||||
|
command: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultSnippets: CommandSnippet[] = [
|
||||||
|
{
|
||||||
|
label: 'Start Default',
|
||||||
|
command: 'ccs',
|
||||||
|
description: 'Launch Claude with default profile',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'GLM Profile',
|
||||||
|
command: 'ccs glm',
|
||||||
|
description: 'Switch to GLM model',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Health Check',
|
||||||
|
command: 'ccs doctor',
|
||||||
|
description: 'Run system diagnostics',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Delegate Task',
|
||||||
|
command: 'ccs glm -p "your task"',
|
||||||
|
description: 'Delegate to GLM profile',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
interface QuickCommandsProps {
|
||||||
|
snippets?: CommandSnippet[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function QuickCommands({ snippets = defaultSnippets }: QuickCommandsProps) {
|
||||||
|
const [copiedIndex, setCopiedIndex] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const copyToClipboard = async (text: string, index: number) => {
|
||||||
|
await navigator.clipboard.writeText(text);
|
||||||
|
setCopiedIndex(index);
|
||||||
|
setTimeout(() => setCopiedIndex(null), 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="pb-3">
|
||||||
|
<CardTitle className="text-lg flex items-center gap-2">
|
||||||
|
<Terminal className="w-5 h-5 text-muted-foreground" />
|
||||||
|
Quick Commands
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
|
{snippets.map((snippet, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className={cn(
|
||||||
|
'group flex items-center justify-between gap-2 px-3 py-2',
|
||||||
|
'rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<p className="text-xs text-muted-foreground">{snippet.label}</p>
|
||||||
|
<code className="text-sm font-mono font-medium truncate block">
|
||||||
|
{snippet.command}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||||
|
onClick={() => copyToClipboard(snippet.command, index)}
|
||||||
|
title={snippet.description}
|
||||||
|
>
|
||||||
|
{copiedIndex === index ? (
|
||||||
|
<Check className="h-4 w-4 text-green-600" />
|
||||||
|
) : (
|
||||||
|
<Copy className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,33 +1,86 @@
|
|||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import type { LucideIcon } from 'lucide-react';
|
import type { LucideIcon } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
interface StatCardProps {
|
interface StatCardProps {
|
||||||
title: string;
|
title: string;
|
||||||
value: number | string;
|
value: number | string;
|
||||||
icon: LucideIcon;
|
icon: LucideIcon;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
variant?: 'default' | 'success' | 'warning' | 'error' | 'accent';
|
||||||
|
subtitle?: string;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const variantStyles = {
|
||||||
|
default: {
|
||||||
|
iconBg: 'bg-muted',
|
||||||
|
iconColor: 'text-muted-foreground',
|
||||||
|
borderHover: 'hover:border-primary',
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
iconBg: 'bg-green-500/10',
|
||||||
|
iconColor: 'text-green-600',
|
||||||
|
borderHover: 'hover:border-green-500/50',
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
iconBg: 'bg-yellow-500/10',
|
||||||
|
iconColor: 'text-yellow-500',
|
||||||
|
borderHover: 'hover:border-yellow-500/50',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
iconBg: 'bg-red-500/10',
|
||||||
|
iconColor: 'text-red-500',
|
||||||
|
borderHover: 'hover:border-red-500/50',
|
||||||
|
},
|
||||||
|
accent: {
|
||||||
|
iconBg: 'bg-accent/10',
|
||||||
|
iconColor: 'text-accent',
|
||||||
|
borderHover: 'hover:border-accent/50',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export function StatCard({
|
export function StatCard({
|
||||||
title,
|
title,
|
||||||
value,
|
value,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color = 'text-primary',
|
color,
|
||||||
|
variant = 'default',
|
||||||
|
subtitle,
|
||||||
onClick,
|
onClick,
|
||||||
}: StatCardProps) {
|
}: StatCardProps) {
|
||||||
|
const styles = variantStyles[variant];
|
||||||
|
const iconColorClass = color || styles.iconColor;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
className={`cursor-pointer hover:shadow-md transition-shadow ${onClick ? 'hover:border-primary' : ''}`}
|
className={cn(
|
||||||
|
'cursor-pointer transition-all duration-200',
|
||||||
|
'hover:shadow-lg hover:-translate-y-0.5',
|
||||||
|
styles.borderHover,
|
||||||
|
onClick && 'active:scale-[0.98]'
|
||||||
|
)}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<CardContent className="pt-4">
|
<CardContent className="pt-4 pb-4">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center gap-4">
|
||||||
<div>
|
{/* Icon Container with background */}
|
||||||
<p className="text-sm text-muted-foreground">{title}</p>
|
<div
|
||||||
<p className={`text-2xl font-bold ${color}`}>{value}</p>
|
className={cn(
|
||||||
|
'flex items-center justify-center w-12 h-12 rounded-lg transition-transform duration-200',
|
||||||
|
styles.iconBg,
|
||||||
|
'group-hover:scale-105'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon className={cn('w-6 h-6', iconColorClass)} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Content */}
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<p className="text-sm text-muted-foreground truncate">{title}</p>
|
||||||
|
<p className={cn('text-2xl font-bold font-mono', iconColorClass)}>{value}</p>
|
||||||
|
{subtitle && <p className="text-xs text-muted-foreground mt-0.5">{subtitle}</p>}
|
||||||
</div>
|
</div>
|
||||||
<Icon className={`w-8 h-8 ${color} opacity-20`} />
|
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
interface Overview {
|
interface Overview {
|
||||||
|
version: string;
|
||||||
profiles: number;
|
profiles: number;
|
||||||
cliproxy: number;
|
cliproxy: number;
|
||||||
|
cliproxyVariants: number;
|
||||||
|
cliproxyProviders: number;
|
||||||
accounts: number;
|
accounts: number;
|
||||||
health: {
|
health: {
|
||||||
status: 'ok' | 'warning' | 'error';
|
status: 'ok' | 'warning' | 'error';
|
||||||
|
|||||||
+86
-58
@@ -2,6 +2,8 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { StatCard } from '@/components/stat-card';
|
import { StatCard } from '@/components/stat-card';
|
||||||
|
import { HeroSection } from '@/components/hero-section';
|
||||||
|
import { QuickCommands } from '@/components/quick-commands';
|
||||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import {
|
import {
|
||||||
@@ -14,14 +16,15 @@ import {
|
|||||||
BookOpen,
|
BookOpen,
|
||||||
FolderOpen,
|
FolderOpen,
|
||||||
AlertTriangle,
|
AlertTriangle,
|
||||||
|
ArrowRight,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { useOverview } from '@/hooks/use-overview';
|
import { useOverview } from '@/hooks/use-overview';
|
||||||
import { useSharedSummary } from '@/hooks/use-shared';
|
import { useSharedSummary } from '@/hooks/use-shared';
|
||||||
|
|
||||||
const HEALTH_COLORS = {
|
const HEALTH_VARIANTS = {
|
||||||
ok: 'text-green-500',
|
ok: 'success',
|
||||||
warning: 'text-yellow-500',
|
warning: 'warning',
|
||||||
error: 'text-red-500',
|
error: 'error',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export function HomePage() {
|
export function HomePage() {
|
||||||
@@ -32,44 +35,48 @@ export function HomePage() {
|
|||||||
if (isOverviewLoading || isSharedLoading) {
|
if (isOverviewLoading || isSharedLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="p-6 space-y-6">
|
<div className="p-6 space-y-6">
|
||||||
<div>
|
{/* Hero Skeleton */}
|
||||||
<Skeleton className="h-9 w-[200px] mb-2" />
|
<div className="rounded-xl border p-6">
|
||||||
<Skeleton className="h-5 w-[320px]" />
|
<div className="flex items-center gap-4">
|
||||||
|
<Skeleton className="h-12 w-12 rounded-lg" />
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-7 w-[180px] mb-2" />
|
||||||
|
<Skeleton className="h-4 w-[220px]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Stats Skeleton */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
{[1, 2, 3, 4].map((i) => (
|
{[1, 2, 3, 4].map((i) => (
|
||||||
<div key={i} className="space-y-3 p-4 border rounded-lg">
|
<div key={i} className="space-y-3 p-4 border rounded-xl">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center gap-4">
|
||||||
<Skeleton className="h-8 w-8 rounded-full" />
|
<Skeleton className="h-12 w-12 rounded-lg" />
|
||||||
<Skeleton className="h-6 w-12" />
|
<div className="flex-1">
|
||||||
</div>
|
<Skeleton className="h-4 w-20 mb-2" />
|
||||||
<div>
|
<Skeleton className="h-7 w-12" />
|
||||||
<Skeleton className="h-4 w-20 mb-1" />
|
</div>
|
||||||
<Skeleton className="h-7 w-16" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="border rounded-lg p-6 space-y-4">
|
|
||||||
<Skeleton className="h-6 w-[180px]" />
|
{/* Quick Actions Skeleton */}
|
||||||
|
<div className="border rounded-xl p-6 space-y-4">
|
||||||
|
<Skeleton className="h-6 w-[140px]" />
|
||||||
<div className="flex flex-wrap gap-3">
|
<div className="flex flex-wrap gap-3">
|
||||||
<Skeleton className="h-10 w-[140px] rounded-md" />
|
<Skeleton className="h-10 w-[140px] rounded-md" />
|
||||||
<Skeleton className="h-10 w-[120px] rounded-md" />
|
<Skeleton className="h-10 w-[120px] rounded-md" />
|
||||||
<Skeleton className="h-10 w-[150px] rounded-md" />
|
<Skeleton className="h-10 w-[150px] rounded-md" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="border rounded-lg p-6 space-y-4">
|
|
||||||
<div className="flex items-center justify-between">
|
{/* Quick Commands Skeleton */}
|
||||||
<Skeleton className="h-6 w-[140px]" />
|
<div className="border rounded-xl p-6 space-y-4">
|
||||||
<Skeleton className="h-8 w-[80px] rounded-md" />
|
<Skeleton className="h-6 w-[160px]" />
|
||||||
</div>
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<div className="flex gap-6">
|
{[1, 2, 3, 4].map((i) => (
|
||||||
{[1, 2, 3].map((i) => (
|
<Skeleton key={i} className="h-14 rounded-lg" />
|
||||||
<div key={i} className="flex items-center gap-2">
|
|
||||||
<Skeleton className="h-4 w-4" />
|
|
||||||
<Skeleton className="h-4 w-8" />
|
|
||||||
<Skeleton className="h-4 w-16" />
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,13 +84,21 @@ export function HomePage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const healthVariant = overview?.health
|
||||||
|
? HEALTH_VARIANTS[overview.health.status as keyof typeof HEALTH_VARIANTS]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 space-y-6">
|
<div className="p-6 space-y-6">
|
||||||
<div>
|
{/* Hero Section */}
|
||||||
<h1 className="text-2xl font-bold">Welcome to CCS Config</h1>
|
<HeroSection
|
||||||
<p className="text-muted-foreground">Manage your Claude Code Switch configuration</p>
|
version={overview?.version}
|
||||||
</div>
|
healthStatus={overview?.health?.status}
|
||||||
|
healthPassed={overview?.health?.passed}
|
||||||
|
healthTotal={overview?.health?.total}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Configuration Warning */}
|
||||||
{shared?.symlinkStatus && !shared.symlinkStatus.valid && (
|
{shared?.symlinkStatus && !shared.symlinkStatus.valid && (
|
||||||
<Alert variant="warning">
|
<Alert variant="warning">
|
||||||
<AlertTriangle className="h-4 w-4" />
|
<AlertTriangle className="h-4 w-4" />
|
||||||
@@ -98,74 +113,87 @@ export function HomePage() {
|
|||||||
title="API Profiles"
|
title="API Profiles"
|
||||||
value={overview?.profiles ?? 0}
|
value={overview?.profiles ?? 0}
|
||||||
icon={Key}
|
icon={Key}
|
||||||
|
variant="accent"
|
||||||
|
subtitle="Settings-based"
|
||||||
onClick={() => navigate('/api')}
|
onClick={() => navigate('/api')}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="CLIProxy Variants"
|
title="CLIProxy"
|
||||||
value={overview?.cliproxy ?? 0}
|
value={overview?.cliproxy ?? 0}
|
||||||
icon={Zap}
|
icon={Zap}
|
||||||
|
variant="accent"
|
||||||
|
subtitle={`${overview?.cliproxyProviders ?? 0} auth + ${overview?.cliproxyVariants ?? 0} custom`}
|
||||||
onClick={() => navigate('/cliproxy')}
|
onClick={() => navigate('/cliproxy')}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="Accounts"
|
title="Accounts"
|
||||||
value={overview?.accounts ?? 0}
|
value={overview?.accounts ?? 0}
|
||||||
icon={Users}
|
icon={Users}
|
||||||
|
variant="default"
|
||||||
|
subtitle="Isolated instances"
|
||||||
onClick={() => navigate('/accounts')}
|
onClick={() => navigate('/accounts')}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="Health"
|
title="Health"
|
||||||
value={overview?.health ? `${overview.health.passed}/${overview.health.total}` : '-'}
|
value={overview?.health ? `${overview.health.passed}/${overview.health.total}` : '-'}
|
||||||
icon={Activity}
|
icon={Activity}
|
||||||
color={
|
variant={healthVariant}
|
||||||
overview?.health
|
subtitle="System checks"
|
||||||
? HEALTH_COLORS[overview.health.status as keyof typeof HEALTH_COLORS]
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
onClick={() => navigate('/health')}
|
onClick={() => navigate('/health')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Quick Actions */}
|
{/* Quick Actions */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="pb-3">
|
||||||
<CardTitle className="text-lg">Quick Actions</CardTitle>
|
<CardTitle className="text-lg">Quick Actions</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-wrap gap-3">
|
<CardContent className="flex flex-wrap gap-3">
|
||||||
<Button onClick={() => navigate('/api')}>
|
<Button onClick={() => navigate('/api')} className="gap-2">
|
||||||
<Plus className="w-4 h-4 mr-2" /> New Profile
|
<Plus className="w-4 h-4" /> New Profile
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" onClick={() => navigate('/health')}>
|
<Button variant="outline" onClick={() => navigate('/health')} className="gap-2">
|
||||||
<Stethoscope className="w-4 h-4 mr-2" /> Run Doctor
|
<Stethoscope className="w-4 h-4" /> Run Doctor
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" asChild>
|
<Button variant="outline" asChild className="gap-2">
|
||||||
<a href="https://github.com/kaitranntt/ccs" target="_blank" rel="noopener noreferrer">
|
<a href="https://github.com/kaitranntt/ccs" target="_blank" rel="noopener noreferrer">
|
||||||
<BookOpen className="w-4 h-4 mr-2" /> Documentation
|
<BookOpen className="w-4 h-4" /> Documentation
|
||||||
</a>
|
</a>
|
||||||
</Button>
|
</Button>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
{/* Quick Commands */}
|
||||||
|
<QuickCommands />
|
||||||
|
|
||||||
{/* Shared Data Summary */}
|
{/* Shared Data Summary */}
|
||||||
<Card>
|
<Card className="group hover:border-primary/50 transition-colors">
|
||||||
<CardHeader className="flex flex-row items-center justify-between">
|
<CardHeader className="flex flex-row items-center justify-between pb-3">
|
||||||
<CardTitle className="text-lg">Shared Data</CardTitle>
|
<CardTitle className="text-lg flex items-center gap-2">
|
||||||
<Button variant="ghost" size="sm" onClick={() => navigate('/shared')}>
|
<FolderOpen className="w-5 h-5 text-muted-foreground" />
|
||||||
View All
|
Shared Data
|
||||||
|
</CardTitle>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => navigate('/shared')}
|
||||||
|
className="gap-1 opacity-70 group-hover:opacity-100 transition-opacity"
|
||||||
|
>
|
||||||
|
View All <ArrowRight className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex gap-6 text-sm">
|
<div className="flex gap-6 text-sm">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50">
|
||||||
<FolderOpen className="w-4 h-4 text-muted-foreground" />
|
<span className="text-xl font-bold font-mono">{shared?.commands ?? 0}</span>
|
||||||
<span className="font-medium">{shared?.commands ?? 0}</span>
|
|
||||||
<span className="text-muted-foreground">Commands</span>
|
<span className="text-muted-foreground">Commands</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50">
|
||||||
<span className="font-medium">{shared?.skills ?? 0}</span>
|
<span className="text-xl font-bold font-mono">{shared?.skills ?? 0}</span>
|
||||||
<span className="text-muted-foreground">Skills</span>
|
<span className="text-muted-foreground">Skills</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50">
|
||||||
<span className="font-medium">{shared?.agents ?? 0}</span>
|
<span className="text-xl font-bold font-mono">{shared?.agents ?? 0}</span>
|
||||||
<span className="text-muted-foreground">Agents</span>
|
<span className="text-muted-foreground">Agents</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user