feat: add dashboard panel components for hero summary and temperature chart

This commit is contained in:
2569718930@qq.com
2026-03-10 10:37:14 +08:00
parent 1afca8ecbb
commit d1b591106e
3 changed files with 79 additions and 59 deletions
@@ -552,9 +552,35 @@ export function ModelForecast({
}) { }) {
const { locale, t } = useI18n(); const { locale, t } = useI18n();
const view = getModelView(detail, targetDate); const view = getModelView(detail, targetDate);
const modelEntries = Object.entries(view.models).filter( const fallbackMeteoblue = detail.source_forecasts?.meteoblue?.today_high;
([, value]) => value !== null && value !== undefined && Number.isFinite(Number(value)), 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 (
<section className="models-section">
{!hideTitle && <h3>{t("section.models")}</h3>}
<div className="model-bars">
<EmptyState text={t("section.noModels")} />
</div>
</section>
);
}
const numericValues = modelEntries.map(([, value]) => Number(value)); const numericValues = modelEntries.map(([, value]) => Number(value));
const comparisonValues = const comparisonValues =
view.deb != null ? [...numericValues, Number(view.deb)] : numericValues; view.deb != null ? [...numericValues, Number(view.deb)] : numericValues;
@@ -576,10 +602,6 @@ export function ModelForecast({
<section className="models-section"> <section className="models-section">
{!hideTitle && <h3>{t("section.models")}</h3>} {!hideTitle && <h3>{t("section.models")}</h3>}
<div className="model-bars"> <div className="model-bars">
{!modelEntries.length ? (
<EmptyState text={t("section.noModels")} />
) : (
<>
{modelEntries {modelEntries
.sort((a, b) => Number(b[1] || 0) - Number(a[1] || 0)) .sort((a, b) => Number(b[1] || 0) - Number(a[1] || 0))
.map(([name, value]) => { .map(([name, value]) => {
@@ -641,8 +663,6 @@ export function ModelForecast({
</div> </div>
</div> </div>
)} )}
</>
)}
</div> </div>
</section> </section>
); );
View File
View File