import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Slider } from "@/components/ui/slider" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Separator } from "@/components/ui/separator" import { Switch } from "@/components/ui/switch" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" import { Checkbox } from "@/components/ui/checkbox" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { ScrollArea } from "@/components/ui/scroll-area" import { useState } from "react" import { Config, defaultConfig } from "@/types/config" import { Settings, Volume2, FlashlightIcon as Brightness4, Wifi, Database, Shield, Monitor, Bell, Server, Lock, Zap, HardDrive, Cpu, } from "lucide-react" export default function Control() { const [config, setConfig] = useState(defaultConfig) const updateConfig = (path: string, value: any) => { setConfig(prev => { const newConfig = { ...prev } const keys = path.split('.') let current: any = newConfig for (let i = 0; i < keys.length - 1; i++) { current = current[keys[i]] } current[keys[keys.length - 1]] = value return newConfig }) } const updateNestedConfig = (path: string, value: any) => { updateConfig(path, value) } return (
{/* App Configuration */} 应用配置 应用基本设置
updateConfig('app.name', e.target.value)} placeholder="输入应用名称" />
updateConfig('app.version', e.target.value)} placeholder="输入版本号" />
updateConfig('app.debug', checked)} />
{/* Database Configuration */} 数据库配置 数据库连接设置
updateConfig('database.max_connections', value[0])} min={5} max={100} step={5} />
updateConfig('database.connection_timeout', value[0])} min={10} max={120} step={5} />
{/* Kafka Configuration */} Kafka配置 消息队列设置
updateConfig('kafka.max_retries', value[0])} min={1} max={10} step={1} />
updateConfig('kafka.retry_delay', value[0])} min={100} max={5000} step={100} />
{/* Security Configuration */} 安全配置 安全相关设置
updateConfig('security.session_timeout', value[0])} min={1800} max={7200} step={300} />
updateConfig('security.max_login_attempts', value[0])} min={3} max={10} step={1} />
{/* Logging Configuration */} 日志配置 日志记录设置
updateConfig('logging.max_files', value[0])} min={5} max={50} step={5} />
{/* Cache Configuration */} 缓存配置 缓存系统设置
updateConfig('cache.ttl', value[0])} min={60} max={3600} step={60} />
updateConfig('cache.max_size', value[0])} min={100} max={10000} step={100} />
{/* Site Configuration */} 站点配置 网站基本设置
updateConfig('site.name', e.target.value)} placeholder="输入站点名称" />
updateConfig('site.brand.logo_url', e.target.value)} placeholder="输入Logo URL" />
updateConfig('site.brand.primary_color', e.target.value)} />
updateConfig('site.brand.dark_mode_default', checked)} />
{/* Notice Configuration */} 通知配置 系统通知设置
{config.notice.banner.enabled && ( <>
updateConfig('notice.banner.text.zh-CN', e.target.value)} placeholder="输入中文横幅文本" />
updateConfig('notice.banner.text.en', e.target.value)} placeholder="Enter English banner text" />
)}
{/* Maintenance Configuration */} 维护配置 系统维护设置
updateConfig('maintenance.window.enabled', checked)} />
{config.maintenance.window.enabled && ( <>
updateConfig('maintenance.window.start_time', e.target.value + 'Z')} />
updateConfig('maintenance.window.end_time', e.target.value + 'Z')} />