import React from 'react'; import { Tabs, Form, Input, Button, Space, Divider, Slider, InputNumber } from 'antd'; // InputNumber added import { ApiOutlined, RocketOutlined, PictureOutlined, SaveOutlined, SafetyCertificateOutlined, LockOutlined, GlobalOutlined, SettingOutlined, DatabaseOutlined, UploadOutlined } from '@ant-design/icons'; import ConfigFormItem from './ConfigFormItem'; import ConfigSection from './ConfigSection'; import VectorDbConfig from './VectorDbConfig'; const { TabPane } = Tabs; // const { Option } = Select; // Removed interface ConfigStructure { [key: string]: { [key: string]: string; }; } interface ConfigTabsProps { configs: ConfigStructure; secretFields: Record; isMobile: boolean; activeKey: string; onTabChange: (key: string) => void; formsMap: Record; allDescriptions: Record>; onSaveSingleConfig: (formInstance: any, groupName: string, key: string) => Promise; onSaveAllForGroup: (formInstance: any, groupName: string, itemKeys: string[]) => Promise; onBaseSaveConfig: (group: string, key: string, value: string) => Promise; setConfigs: React.Dispatch>; // imageQualityOptions: Array<{ value: string; label: string; description: string; }>; // Removed } const ConfigTabs: React.FC = ({ configs, secretFields, isMobile, activeKey, onTabChange, formsMap, allDescriptions, onSaveSingleConfig, onSaveAllForGroup, onBaseSaveConfig, setConfigs, // imageQualityOptions, // Removed }) => { const renderConfigFormItems = (formInstance: any, groupName: string, itemKeys: string[]) => { return itemKeys.map(key => { const isSecret = secretFields[groupName]?.includes(key); const description = allDescriptions[groupName]?.[key] || ''; const currentValue = configs[groupName]?.[key]; return ( ); }); }; const tabItems = [ { key: 'AI', label: 'AI 设置', icon: , children: ( } description="配置AI服务的基本参数,包括API端点、密钥和模型选择" isMobile={isMobile} >
{renderConfigFormItems(formsMap.AI, "AI", ['ApiEndpoint', 'ApiKey', 'Model', 'EmbeddingModel'])}
} description={allDescriptions.AI?.ImageAnalysisPrompt} isMobile={isMobile} > { const newConfigs = { ...configs }; if (!newConfigs.AI) newConfigs.AI = {}; newConfigs.AI.ImageAnalysisPrompt = e.target.value; setConfigs(newConfigs); }} style={{ marginBottom: 16 }} />
} description={allDescriptions.AI?.TagGenerationPrompt} isMobile={isMobile} > { const newConfigs = { ...configs }; if (!newConfigs.AI) newConfigs.AI = {}; newConfigs.AI.TagGenerationPrompt = e.target.value; setConfigs(newConfigs); }} style={{ marginBottom: 16 }} />
} description={allDescriptions.AI?.TagMatchingPrompt} isMobile={isMobile} > { const newConfigs = { ...configs }; if (!newConfigs.AI) newConfigs.AI = {}; newConfigs.AI.TagMatchingPrompt = e.target.value; setConfigs(newConfigs); }} style={{ marginBottom: 16 }} />
) }, { key: 'Authorization', label: '授权配置', icon: , children: ( } description="JSON Web Token (JWT) 的安全设置,用于管理用户身份验证和授权" isMobile={isMobile} >
{renderConfigFormItems(formsMap.Jwt, "Jwt", ['SecretKey', 'Issuer', 'Audience'])}
} description="GitHub OAuth 应用配置,用于实现第三方登录功能" isMobile={isMobile} >
{renderConfigFormItems(formsMap.Authentication, "Authentication", ["GitHubClientId", "GitHubClientSecret", "GitHubCallbackUrl"])}
} description="LinuxDo OAuth 应用配置,用于实现第三方登录功能" isMobile={isMobile} >
{renderConfigFormItems(formsMap.Authentication, "Authentication", ["LinuxDoClientId", "LinuxDoClientSecret", "LinuxDoCallbackUrl"])}
) }, { key: 'AppSettings', label: '应用设置', icon: , children: ( } description="应用程序的基本配置参数" isMobile={isMobile} >
{renderConfigFormItems(formsMap.AppSettings, "AppSettings", ['ServerUrl', 'MaxConcurrentTasks', 'EnableRegistration', 'EnableAnonymousImageHosting'])}
) }, { key: 'Upload', label: '上传设置', icon: , children: ( <> } description="配置文件上传处理方式和图片转换参数" isMobile={isMobile} >
缩略图最大宽度 (px)
} help={
{allDescriptions.Upload?.ThumbnailMaxWidth}
} initialValue={parseInt(configs.Upload?.ThumbnailMaxWidth || '400', 10)} style={{ marginBottom: 0 }} > 缩略图压缩质量 } help={
{allDescriptions.Upload?.ThumbnailCompressionQuality}
} initialValue={parseInt(configs.Upload?.ThumbnailCompressionQuality || '75', 10)} style={{ marginBottom: 0 }} > `${value}%` }} marks={{ 30: '30%', 60: '60%', 90: '90%' }} />
高清图片压缩质量 } help={
{allDescriptions.Upload?.HighQualityImageCompressionQuality}
} initialValue={parseInt(configs.Upload?.HighQualityImageCompressionQuality || '95', 10)} style={{ marginBottom: 0 }} > `${value}%` }} marks={{ 50: '50%', 75: '75%', 100: '100%' }} />
) }, { key: 'VectorDb', label: '向量数据', icon: , children: ( ) } ]; return ( ({ key: item.key, label: ( {item.icon} {item.label} ), children: item.children }))} /> ); }; export default ConfigTabs;