import React, { useState } from 'react'; import { Card, Row, Col, Form, Input, Button, Select, Switch, InputNumber, Alert, Divider, Tabs } from 'antd'; import { DatabaseOutlined, KeyOutlined, SettingOutlined, SaveOutlined, ToolOutlined } from '@ant-design/icons'; import './AdminConfig.css'; const { Option } = Select; const { Item } = Form; const { TabPane } = Tabs; const AdminConfig = () => { const [form] = Form.useForm(); // 数据库配置 const databaseConfig = { // MongoDB配置 mongoDB: { host: 'localhost', port: 27017, database: 'alpha-futures', username: '', password: '', authSource: 'admin', ssl: false, enabled: true }, // PostgreSQL配置 postgreSQL: { host: 'localhost', port: 5432, database: 'alpha-futures', username: 'postgres', password: 'password', ssl: false, enabled: true }, // Redis配置 redis: { host: 'localhost', port: 6379, password: '', db: 0, enabled: true }, // InfluxDB配置 influxDB: { host: 'localhost', port: 8086, database: 'alpha-futures', username: '', password: '', ssl: false, enabled: true } }; // 服务器配置 const serverConfig = { port: 3005, host: '0.0.0.0', environment: 'development', debug: true, timeout: 30000, maxBodySize: '10mb' }; // 安全配置 const securityConfig = { jwtSecret: 'your-secret-key', jwtExpiresIn: '7d', rateLimit: { windowMs: 60000, max: 120 }, cors: { origin: '*', methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization'] } }; const [config, setConfig] = useState({ database: databaseConfig, server: serverConfig, security: securityConfig }); // 处理配置变更 const handleConfigChange = (section, key, value) => { setConfig(prev => ({ ...prev, [section]: { ...prev[section], [key]: value } })); }; // 处理数据库配置变更 const handleDatabaseConfigChange = (dbType, key, value) => { setConfig(prev => ({ ...prev, database: { ...prev.database, [dbType]: { ...prev.database[dbType], [key]: value } } })); }; // 处理表单提交 const handleSubmit = (values) => { console.log('配置保存:', values); // 模拟保存操作 Alert.success('配置已保存'); }; // 测试数据库连接 const testDatabaseConnection = (dbType) => { console.log(`测试${dbType}连接`); // 模拟测试操作 setTimeout(() => { Alert.success(`${dbType}连接测试成功`); }, 1000); }; return (