修复 DEB 预报曲线因 API 结构不匹配而永不渲染
P0: detail?depth=panel 返回 timeseries.hourly 嵌套结构,图表原来直接读 json.hourly 始终 undefined。改为 json.hourly ?? json.timeseries?.hourly fallback。models_hourly 同理。
This commit is contained in:
@@ -344,13 +344,14 @@ export function LiveTemperatureThresholdChart({
|
||||
return res.json() as Promise<CityDetail>;
|
||||
})
|
||||
.then((json) => {
|
||||
if (cancelled || !json?.hourly) return;
|
||||
const hourlySource = (json as any)?.hourly ?? (json as any)?.timeseries?.hourly;
|
||||
if (cancelled || !json || !hourlySource) return;
|
||||
const data: HourlyForecast = {
|
||||
forecastTodayHigh: json.forecast?.today_high ?? null,
|
||||
localTime: json.local_time || null,
|
||||
times: json.hourly.times || [],
|
||||
temps: json.hourly.temps || [],
|
||||
modelCurves: json.models_hourly?.curves || undefined,
|
||||
times: hourlySource.times || [],
|
||||
temps: hourlySource.temps || [],
|
||||
modelCurves: (json.models_hourly ?? (json as any)?.timeseries?.models_hourly)?.curves || undefined,
|
||||
};
|
||||
_hourlyCache.set(city, { ts: Date.now(), data });
|
||||
setHourly(data);
|
||||
|
||||
Reference in New Issue
Block a user