diff --git a/.gitignore b/.gitignore
index e58d61a..267cd1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,3 +54,4 @@ Thumbs.db
# Project specific
backups/
+/out/
diff --git a/src/web/routes/registration.py b/src/web/routes/registration.py
index 41c006e..5ba459e 100644
--- a/src/web/routes/registration.py
+++ b/src/web/routes/registration.py
@@ -225,6 +225,11 @@ def _run_sync_registration_task(task_uuid: str, email_service_type: str, proxy:
if db_service:
config = db_service.config.copy() if db_service.config else {}
+ # 兼容旧版字段名 api_url -> base_url
+ if 'api_url' in config and 'base_url' not in config:
+ config['base_url'] = config.pop('api_url')
+ if 'domain' in config and 'default_domain' not in config:
+ config['default_domain'] = config.pop('domain')
# 更新任务关联的邮箱服务
crud.update_registration_task(db, task_uuid, email_service_id=db_service.id)
logger.info(f"使用数据库邮箱服务: {db_service.name} (ID: {db_service.id})")
@@ -249,6 +254,11 @@ def _run_sync_registration_task(task_uuid: str, email_service_type: str, proxy:
if db_service and db_service.config:
config = db_service.config.copy()
+ # 兼容旧版字段名 api_url -> base_url
+ if 'api_url' in config and 'base_url' not in config:
+ config['base_url'] = config.pop('api_url')
+ if 'domain' in config and 'default_domain' not in config:
+ config['default_domain'] = config.pop('domain')
crud.update_registration_task(db, task_uuid, email_service_id=db_service.id)
logger.info(f"使用数据库自定义域名服务: {db_service.name}")
elif settings.custom_domain_base_url and settings.custom_domain_api_key:
diff --git a/static/js/email_services.js b/static/js/email_services.js
index b48e6eb..4ffd2dc 100644
--- a/static/js/email_services.js
+++ b/static/js/email_services.js
@@ -288,7 +288,7 @@ async function loadCustomServices() {
${selectedCustom.has(service.id) ? 'checked' : ''}>
${escapeHtml(service.name)} |
- ${escapeHtml(service.config?.api_url || '-')} |
+ ${escapeHtml(service.config?.base_url || '-')} |
${service.enabled ? '启用' : '禁用'}
@@ -403,9 +403,9 @@ async function handleAddCustom(e) {
service_type: 'custom_domain',
name: formData.get('name'),
config: {
- api_url: formData.get('api_url'),
+ base_url: formData.get('api_url'),
api_key: formData.get('api_key'),
- domain: formData.get('domain')
+ default_domain: formData.get('domain')
},
enabled: formData.get('enabled') === 'on',
priority: parseInt(formData.get('priority')) || 0
@@ -553,14 +553,14 @@ async function editCustomService(id) {
// 填充表单
document.getElementById('edit-custom-id').value = service.id;
document.getElementById('edit-custom-name').value = service.name || '';
- document.getElementById('edit-custom-api-url').value = service.config?.api_url || '';
+ document.getElementById('edit-custom-api-url').value = service.config?.base_url || '';
document.getElementById('edit-custom-api-key').value = service.config?.api_key || '';
document.getElementById('edit-custom-domain').value = service.config?.domain || '';
document.getElementById('edit-custom-priority').value = service.priority || 0;
document.getElementById('edit-custom-enabled').checked = service.enabled;
// 清空密码提示
- document.getElementById('edit-custom-api-key').placeholder = service.config?.api_key ? '已设置,留空保持不变' : 'API Key';
+ document.getElementById('edit-custom-api-key').placeholder = service.config?.has_api_key ? '已设置,留空保持不变' : 'API Key';
// 显示模态框
elements.editCustomModal.classList.add('active');
@@ -586,8 +586,8 @@ async function handleEditCustom(e) {
// 构建配置
const config = {
- api_url: formData.get('api_url'),
- domain: formData.get('domain')
+ base_url: formData.get('api_url'),
+ default_domain: formData.get('domain')
};
// 只有在填写了 API Key 时才更新
diff --git a/static/js/utils.js b/static/js/utils.js
index 4a1e14b..43c39ea 100644
--- a/static/js/utils.js
+++ b/static/js/utils.js
@@ -225,6 +225,10 @@ class ApiClient {
return this.request(path, { ...options, method: 'PUT', body });
}
+ patch(path, body, options = {}) {
+ return this.request(path, { ...options, method: 'PATCH', body });
+ }
+
delete(path, options = {}) {
return this.request(path, { ...options, method: 'DELETE' });
}
|