From edf3e93eef622394548ad0203a18cd70372c3da7 Mon Sep 17 00:00:00 2001 From: yarnom Date: Mon, 3 Nov 2025 16:29:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=A7=E5=B1=8F=E5=B9=95=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/app.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index 92a3e32..28cdde1 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -300,13 +300,25 @@ WeatherApp.updateSummaryPanel = function(historyData, forecastData){ const futureSum = [r1,r2,r3].reduce((s,v)=> s + (v!=null?Number(v):0), 0); if (elFuture) elFuture.textContent = `未来1~3小时降雨 ${fmt(futureSum)} 毫米`; - // 超过阈值(>0.4mm)触发 Summary 面板橙色预警样式 + // 预警等级:>0.4 红色;>0.0 橙色;否则无 try { const panel = document.getElementById('summaryPanel'); - if (panel) { - if (futureSum > 0.4) panel.classList.add('alert-on'); - else panel.classList.remove('alert-on'); - } + const screen = document.querySelector('.screen'); + const setLevel = (sum) => { + const isRed = sum > 1; + const isOrange = !isRed && sum > 0 && sum < 1; + if (panel) { + panel.classList.toggle('alert-red', isRed); + panel.classList.toggle('alert-on', isOrange); + if (!isRed && !isOrange) { panel.classList.remove('alert-red','alert-on'); } + } + if (screen) { + screen.classList.toggle('alert-red', isRed); + screen.classList.toggle('alert-on', isOrange); + if (!isRed && !isOrange) { screen.classList.remove('alert-red','alert-on'); } + } + }; + setLevel(futureSum); } catch {} // --- 过去预报准确率(按小时分档 [0,5), [5,10), [10,∞))---