From df9a36291cc5446a64c53802d58e2a29a7737608 Mon Sep 17 00:00:00 2001 From: Wenaixi Date: Mon, 30 Mar 2026 23:41:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E9=98=B2=E6=AD=A2=E6=A0=BC=E5=BC=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. config-api.js: 添加 SCHEDULED_HEALTH_CHECK 结构验证 2. config-manager.js: 添加 interval 值范围验证 (60000-3600000ms) Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/ui-modules/config-api.js | 13 ++++++++++++- static/app/config-manager.js | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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 };