Clarify sidebar current and peak temperature labels

This commit is contained in:
2569718930@qq.com
2026-03-21 18:17:03 +08:00
parent bddcd434da
commit 7fe89e097b
2 changed files with 23 additions and 8 deletions
+19 -8
View File
@@ -165,6 +165,23 @@ export function CitySidebar() {
const summary = store.citySummariesByName[city.name]; const summary = store.citySummariesByName[city.name];
const snapshot = detail || summary; const snapshot = detail || summary;
const isActive = store.selectedCity === city.name; const isActive = store.selectedCity === city.name;
const tempSymbol = snapshot?.temp_symbol || "°C";
const currentTempText =
snapshot?.current?.temp != null
? t("sidebar.currentTemp", {
temp: `${snapshot.current.temp}${tempSymbol}`,
})
: t("common.na");
const peakTempText =
detail?.current?.max_so_far != null &&
detail.current.max_temp_time
? t("sidebar.peakTempAt", {
temp: `${detail.current.max_so_far}${tempSymbol}`,
time: detail.current.max_temp_time,
})
: detail?.current?.max_temp_time
? t("sidebar.peakAt", { time: detail.current.max_temp_time })
: "";
return ( return (
<button <button
@@ -186,9 +203,7 @@ export function CitySidebar() {
snapshot?.current?.temp != null && "loaded", snapshot?.current?.temp != null && "loaded",
)} )}
> >
{snapshot?.current?.temp != null {currentTempText}
? `${snapshot.current.temp}${snapshot.temp_symbol || "°C"}`
: t("common.na")}
</span> </span>
</div> </div>
@@ -196,11 +211,7 @@ export function CitySidebar() {
<span className="city-local-time"> <span className="city-local-time">
{snapshot?.local_time ? `🕒 ${snapshot.local_time}` : ""} {snapshot?.local_time ? `🕒 ${snapshot.local_time}` : ""}
</span> </span>
<span className="city-max-info"> <span className="city-max-info">{peakTempText}</span>
{detail?.current?.max_temp_time
? t("sidebar.peakAt", { time: detail.current.max_temp_time })
: ""}
</span>
</div> </div>
</button> </button>
); );
+4
View File
@@ -21,6 +21,8 @@ const MESSAGES: Record<Locale, Record<string, string>> = {
"header.langEn": "EN", "header.langEn": "EN",
"sidebar.title": "监控城市", "sidebar.title": "监控城市",
"sidebar.currentTemp": "当前 {temp}",
"sidebar.peakTempAt": "峰值 {temp} @ {time}",
"sidebar.peakAt": "峰值 @ {time}", "sidebar.peakAt": "峰值 @ {time}",
"sidebar.group.high": "高风险", "sidebar.group.high": "高风险",
"sidebar.group.medium": "中风险", "sidebar.group.medium": "中风险",
@@ -180,6 +182,8 @@ const MESSAGES: Record<Locale, Record<string, string>> = {
"header.langEn": "EN", "header.langEn": "EN",
"sidebar.title": "Monitored Cities", "sidebar.title": "Monitored Cities",
"sidebar.currentTemp": "Current {temp}",
"sidebar.peakTempAt": "Peak {temp} @ {time}",
"sidebar.peakAt": "Peak @ {time}", "sidebar.peakAt": "Peak @ {time}",
"sidebar.group.high": "High Risk", "sidebar.group.high": "High Risk",
"sidebar.group.medium": "Medium Risk", "sidebar.group.medium": "Medium Risk",