diff --git a/templates/index.html b/templates/index.html index 16b6482..e67deb6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -347,7 +347,6 @@ let currentSearchKeyword = ""; let currentServerDirectory = ""; let selectedScriptPath = null; - let scriptStatusMap = {}; // 缓存脚本状态映射 $(function () { loadScripts(); @@ -370,35 +369,28 @@ alert('加载脚本失败:后端返回非数组格式'); return; } - // 只保留有配置的脚本(后端已过滤,前端二次确认) + // 直接保存原始名称,不做额外处理 allScripts = scripts.filter(item => typeof item === 'object' && item !== null && 'name' in item && typeof item.name === 'string' && item.name.trim() !== '' ); - // 批量获取所有脚本的状态和模式 - $.get('/api/scripts/status', function(statusMap) { - scriptStatusMap = statusMap; - currentSearchKeyword = ""; - $('#script-search').val(""); - sortScripts(); - updateConfigScriptSelect(); + currentSearchKeyword = ""; + $('#script-search').val(""); + sortScripts(); + updateConfigScriptSelect(); - if (currentScript) { - const scriptExists = allScripts.some(s => s.name === currentScript); - if (scriptExists) { - $('#config-script').val(currentScript); - loadConfig(currentScript); - updateOutput(); - } else { - currentScript = null; - $('#output-area').empty(); - } + if (currentScript) { + const scriptExists = allScripts.some(s => s.name === currentScript); + if (scriptExists) { + $('#config-script').val(currentScript); + loadConfig(currentScript); + updateOutput(); + } else { + currentScript = null; + $('#output-area').empty(); } - }).fail(function(xhr) { - alert('加载脚本状态失败:' + (xhr.responseJSON?.error || xhr.statusText)); - }); - + } }).fail(function (xhr) { alert('加载脚本列表失败:' + (xhr.responseJSON?.error || xhr.statusText)); allScripts = []; @@ -452,7 +444,7 @@ if (filteredScripts.length === 0) { const tip = currentSearchKeyword ? ` 未找到包含"${currentSearchKeyword}"的脚本` : - ` 暂无配置的脚本`; + ` tasks目录下无脚本文件(支持.bat/.py)`; container.append(`