diff --git a/src/ui-modules/config-api.js b/src/ui-modules/config-api.js index 178831f..8310a8e 100644 --- a/src/ui-modules/config-api.js +++ b/src/ui-modules/config-api.js @@ -116,7 +116,18 @@ export async function handleUpdateConfig(req, res, currentConfig) { if (newConfig.LOG_MAX_FILES !== undefined) currentConfig.LOG_MAX_FILES = newConfig.LOG_MAX_FILES; // Scheduled Health Check settings - if (newConfig.SCHEDULED_HEALTH_CHECK !== undefined) currentConfig.SCHEDULED_HEALTH_CHECK = newConfig.SCHEDULED_HEALTH_CHECK; + if (newConfig.SCHEDULED_HEALTH_CHECK !== undefined) { + const incoming = newConfig.SCHEDULED_HEALTH_CHECK; + currentConfig.SCHEDULED_HEALTH_CHECK = { + enabled: incoming?.enabled === true, + startupRun: incoming?.startupRun !== false, + interval: (() => { + const val = Number(incoming?.interval); + return isNaN(val) ? 600000 : Math.max(60000, Math.min(3600000, val)); + })(), + providerTypes: Array.isArray(incoming?.providerTypes) ? incoming.providerTypes : [] + }; + } // Handle system prompt update if (newConfig.systemPrompt !== undefined) { diff --git a/static/app/config-manager.js b/static/app/config-manager.js index 9c16a00..e093f3c 100644 --- a/static/app/config-manager.js +++ b/static/app/config-manager.js @@ -398,10 +398,14 @@ async function saveConfiguration() { .map(tag => tag.getAttribute('data-value')) : []; + // 验证并规范化 interval 值 + const rawInterval = parseInt(document.getElementById('scheduledHealthCheckInterval')?.value); + const validatedInterval = isNaN(rawInterval) ? 600000 : Math.max(60000, Math.min(3600000, rawInterval)); + config.SCHEDULED_HEALTH_CHECK = { enabled: document.getElementById('scheduledHealthCheckEnabled')?.checked !== false, startupRun: document.getElementById('scheduledHealthCheckStartupRun')?.checked !== false, - interval: parseInt(document.getElementById('scheduledHealthCheckInterval')?.value || 600000), + interval: validatedInterval, providerTypes: scheduledHealthCheckProviderTypes };