From d1b591106e44784721f2d42d6c8d13565b88ad9a Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 10 Mar 2026 10:37:14 +0800 Subject: [PATCH] feat: add dashboard panel components for hero summary and temperature chart --- .../components/dashboard/PanelSections.tsx | 138 ++++++++++-------- tmp.json | 0 tmp2.json | 0 3 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 tmp.json create mode 100644 tmp2.json diff --git a/frontend/components/dashboard/PanelSections.tsx b/frontend/components/dashboard/PanelSections.tsx index 8034e398..2d906019 100644 --- a/frontend/components/dashboard/PanelSections.tsx +++ b/frontend/components/dashboard/PanelSections.tsx @@ -552,9 +552,35 @@ export function ModelForecast({ }) { const { locale, t } = useI18n(); const view = getModelView(detail, targetDate); - const modelEntries = Object.entries(view.models).filter( - ([, value]) => value !== null && value !== undefined && Number.isFinite(Number(value)), + const fallbackMeteoblue = detail.source_forecasts?.meteoblue?.today_high; + const modelsMap = { ...view.models }; + + // 强行插入 Meteoblue,防止 helper 函数或日期对齐导致其被剔除 + if ( + modelsMap["Meteoblue"] == null && + fallbackMeteoblue != null && + (!targetDate || targetDate === detail.local_date) + ) { + modelsMap["Meteoblue"] = fallbackMeteoblue; + } + + const modelEntries = Object.entries(modelsMap).filter( + ([, value]) => + value !== null && value !== undefined && Number.isFinite(Number(value)), ); + + // 如果没有任何数值,给出提示 + if (modelEntries.length === 0) { + return ( +
+ {!hideTitle &&

{t("section.models")}

} +
+ +
+
+ ); + } + const numericValues = modelEntries.map(([, value]) => Number(value)); const comparisonValues = view.deb != null ? [...numericValues, Number(view.deb)] : numericValues; @@ -576,72 +602,66 @@ export function ModelForecast({
{!hideTitle &&

{t("section.models")}

}
- {!modelEntries.length ? ( - - ) : ( - <> - {modelEntries - .sort((a, b) => Number(b[1] || 0) - Number(a[1] || 0)) - .map(([name, value]) => { - const numeric = Number(value); - const width = ((numeric - minValue) / range) * 100; - const debLine = - view.deb != null - ? ((Number(view.deb) - minValue) / range) * 100 - : null; + {modelEntries + .sort((a, b) => Number(b[1] || 0) - Number(a[1] || 0)) + .map(([name, value]) => { + const numeric = Number(value); + const width = ((numeric - minValue) / range) * 100; + const debLine = + view.deb != null + ? ((Number(view.deb) - minValue) / range) * 100 + : null; - return ( -
-
- {getModelDisplayName(name)} -
-
-
- {numeric} - {detail.temp_symbol} -
- {debLine != null && ( -
- )} -
-
- ); - })} - {view.deb != null && ( -
-
- DEB + return ( +
+
+ {getModelDisplayName(name)}
- {Number(view.deb)} + {numeric} {detail.temp_symbol}
+ {debLine != null && ( +
+ )}
- )} - + ); + })} + {view.deb != null && ( +
+
+ DEB +
+
+
+ {Number(view.deb)} + {detail.temp_symbol} +
+
+
)}
diff --git a/tmp.json b/tmp.json new file mode 100644 index 00000000..e69de29b diff --git a/tmp2.json b/tmp2.json new file mode 100644 index 00000000..e69de29b