diff --git a/static/js/app.js b/static/js/app.js index 546cad9..901ea39 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2314,6 +2314,84 @@ document.addEventListener('DOMContentLoaded', function() { } }); +// ================================ +// 【外发配置菜单】相关功能 +// ================================ + +// 外发配置类型配置 +const outgoingConfigs = { + smtp: { + title: 'SMTP邮件配置', + description: '配置SMTP服务器用于发送注册验证码等邮件通知', + icon: 'bi-envelope-fill', + color: 'primary', + fields: [ + { + id: 'smtp_server', + label: 'SMTP服务器', + type: 'text', + placeholder: 'smtp.qq.com', + required: true, + help: '邮箱服务商的SMTP服务器地址,如:smtp.qq.com、smtp.gmail.com' + }, + { + id: 'smtp_port', + label: 'SMTP端口', + type: 'number', + placeholder: '587', + required: true, + help: '通常为587(TLS)或465(SSL)' + }, + { + id: 'smtp_user', + label: '发件邮箱', + type: 'email', + placeholder: 'your-email@qq.com', + required: true, + help: '用于发送邮件的邮箱地址' + }, + { + id: 'smtp_password', + label: '邮箱密码/授权码', + type: 'password', + placeholder: '输入密码或授权码', + required: true, + help: '邮箱密码或应用专用密码(QQ邮箱需要授权码)' + }, + { + id: 'smtp_from', + label: '发件人显示名(可选)', + type: 'text', + placeholder: '闲鱼自动回复系统', + required: false, + help: '邮件发件人显示的名称,留空则使用邮箱地址' + }, + { + id: 'smtp_use_tls', + label: '启用TLS', + type: 'select', + options: [ + { value: 'true', text: '是' }, + { value: 'false', text: '否' } + ], + required: true, + help: '是否启用TLS加密(推荐开启)' + }, + { + id: 'smtp_use_ssl', + label: '启用SSL', + type: 'select', + options: [ + { value: 'true', text: '是' }, + { value: 'false', text: '否' } + ], + required: true, + help: '是否启用SSL加密(与TLS二选一)' + } + ] + } +}; + // ================================ // 【通知渠道菜单】相关功能 // ================================ @@ -7393,15 +7471,20 @@ async function loadSystemSettings() { console.log('用户信息:', result, '是否管理员:', isAdmin); - // 显示/隐藏注册设置(仅管理员可见) + // 显示/隐藏注册设置和外发配置(仅管理员可见) const registrationSettings = document.getElementById('registration-settings'); + const outgoingConfigs = document.getElementById('outgoing-configs'); if (registrationSettings) { registrationSettings.style.display = isAdmin ? 'block' : 'none'; } + if (outgoingConfigs) { + outgoingConfigs.style.display = isAdmin ? 'block' : 'none'; + } - // 如果是管理员,加载注册设置 + // 如果是管理员,加载注册设置和外发配置 if (isAdmin) { await loadRegistrationSettings(); + await loadOutgoingConfigs(); } } } catch (error) { @@ -7414,6 +7497,152 @@ async function loadSystemSettings() { } } +// 加载外发配置 +async function loadOutgoingConfigs() { + try { + const response = await fetch('/system-settings', { + headers: { + 'Authorization': `Bearer ${authToken}` + } + }); + + if (response.ok) { + const settings = await response.json(); + + // 渲染外发配置界面 + renderOutgoingConfigs(settings); + } + } catch (error) { + console.error('加载外发配置失败:', error); + showToast('加载外发配置失败', 'danger'); + } +} + +// 渲染外发配置界面 +function renderOutgoingConfigs(settings) { + const container = document.getElementById('outgoing-configs'); + if (!container) return; + + let html = '
${smtpConfig.description}
+ +