import { useState, useEffect } from 'react'; import Head from 'next/head'; import { toast } from 'react-hot-toast'; import { CogIcon, ShieldCheckIcon, CurrencyDollarIcon, GlobeAltIcon, BellIcon, PhoneIcon, CloudIcon, KeyIcon } from '@heroicons/react/24/outline'; import Layout from '@/components/Layout'; interface Settings { // 基础设置 siteName: string; siteDescription: string; adminEmail: string; supportEmail: string; // 通话设置 maxCallDuration: number; // 分钟 callTimeout: number; // 秒 enableRecording: boolean; enableVideoCall: boolean; // 费用设置 - 修改为每个服务单独配置 serviceRates: { ai_voice: number; // AI语音翻译费率(元/分钟) ai_video: number; // AI视频翻译费率(元/分钟) sign_language: number; // 手语翻译费率(元/分钟) human_interpreter: number; // 真人翻译费率(元/分钟) document_translation: number; // 文档翻译费率(元/字) }; currency: string; taxRate: number; // 通知设置 emailNotifications: boolean; smsNotifications: boolean; pushNotifications: boolean; // 安全设置 enableTwoFactor: boolean; sessionTimeout: number; // 分钟 maxLoginAttempts: number; // API设置 twilioAccountSid: string; twilioAuthToken: string; openaiApiKey: string; // 语言设置 defaultLanguage: string; supportedLanguages: string[]; } export default function SettingsPage() { const [settings, setSettings] = useState({ siteName: '口译服务管理系统', siteDescription: '专业的多语言口译服务平台', adminEmail: 'admin@interpreter.com', supportEmail: 'support@interpreter.com', maxCallDuration: 120, callTimeout: 30, enableRecording: true, enableVideoCall: true, serviceRates: { ai_voice: 2.0, ai_video: 3.0, sign_language: 5.0, human_interpreter: 8.0, document_translation: 0.1, }, currency: 'CNY', taxRate: 0.06, emailNotifications: true, smsNotifications: false, pushNotifications: true, enableTwoFactor: false, sessionTimeout: 30, maxLoginAttempts: 5, twilioAccountSid: '', twilioAuthToken: '', openaiApiKey: '', defaultLanguage: 'zh-CN', supportedLanguages: ['zh-CN', 'en-US', 'ja-JP', 'ko-KR', 'fr-FR', 'de-DE', 'es-ES'] }); const [loading, setLoading] = useState(false); const [activeTab, setActiveTab] = useState('basic'); // 保存设置 const saveSettings = async () => { try { setLoading(true); // 这里应该调用API保存设置 // await api.updateSettings(settings); // 模拟API调用 await new Promise(resolve => setTimeout(resolve, 1000)); toast.success('设置保存成功'); } catch (error) { console.error('Error saving settings:', error); toast.error('保存设置失败'); } finally { setLoading(false); } }; // 重置设置 const resetSettings = () => { setSettings({ siteName: '口译服务管理系统', siteDescription: '专业的多语言口译服务平台', adminEmail: 'admin@interpreter.com', supportEmail: 'support@interpreter.com', maxCallDuration: 120, callTimeout: 30, enableRecording: true, enableVideoCall: true, serviceRates: { ai_voice: 2.0, ai_video: 3.0, sign_language: 5.0, human_interpreter: 8.0, document_translation: 0.1, }, currency: 'CNY', taxRate: 0.06, emailNotifications: true, smsNotifications: false, pushNotifications: true, enableTwoFactor: false, sessionTimeout: 30, maxLoginAttempts: 5, twilioAccountSid: '', twilioAuthToken: '', openaiApiKey: '', defaultLanguage: 'zh-CN', supportedLanguages: ['zh-CN', 'en-US', 'ja-JP', 'ko-KR', 'fr-FR', 'de-DE', 'es-ES'] }); toast.success('设置已重置为默认值'); }; const tabs = [ { id: 'basic', name: '基础设置', icon: CogIcon }, { id: 'call', name: '通话设置', icon: PhoneIcon }, { id: 'billing', name: '费用设置', icon: CurrencyDollarIcon }, { id: 'notifications', name: '通知设置', icon: BellIcon }, { id: 'security', name: '安全设置', icon: ShieldCheckIcon }, { id: 'api', name: 'API设置', icon: KeyIcon }, { id: 'language', name: '语言设置', icon: GlobeAltIcon } ]; return ( 系统设置 - 口译服务管理后台
{/* 页面标题 */}

系统设置

{/* 侧边栏标签 */}
{/* 主内容区域 */}
{/* 基础设置 */} {activeTab === 'basic' && (

基础设置

setSettings({...settings, siteName: e.target.value})} className="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500" />
setSettings({...settings, adminEmail: e.target.value})} className="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500" />