diff --git a/backend/core/context.py b/backend/core/context.py index 7d05d93b..fd755192 100644 --- a/backend/core/context.py +++ b/backend/core/context.py @@ -1060,7 +1060,7 @@ def _weather_code_to_desc(code: int, language: str = "zh") -> str: 61: "Light rain", 63: "Rain", 65: "Heavy rain", 71: "Light snow", 73: "Snow", 75: "Heavy snow", 80: "Showers", 81: "Showers", 82: "Storm rain", - 95: "Thunderstorm", 96: "Hail", 99: "Hail", + 95: "Thunderstorm", 96: "Thunderstorm", 99: "Thunderstorm", } return mapping.get(code, "Unknown") mapping = { @@ -1070,7 +1070,7 @@ def _weather_code_to_desc(code: int, language: str = "zh") -> str: 61: "小雨", 63: "中雨", 65: "大雨", 71: "小雪", 73: "中雪", 75: "大雪", 80: "阵雨", 81: "阵雨", 82: "暴雨", - 95: "雷阵雨", 96: "冰雹", 99: "冰雹", + 95: "雷阵雨", 96: "雷阵雨", 99: "雷阵雨", } return mapping.get(code, "未知") diff --git a/backend/tests/test_unit_context.py b/backend/tests/test_unit_context.py index e6d9a4d9..b9604fb5 100644 --- a/backend/tests/test_unit_context.py +++ b/backend/tests/test_unit_context.py @@ -10,6 +10,7 @@ get_weather, search_locations, _generate_weather_advice, + _weather_code_to_desc, _qweather_current, _qweather_forecast_to_standard, _qweather_icon_to_wmo, @@ -224,6 +225,14 @@ async def test_qweather_forecast_to_standard_builds_result(self): assert result["forecast"][0]["desc"] == "多云" +class TestWeatherCodeDescriptions: + def test_thunderstorm_with_hail_codes_use_general_thunderstorm_label(self): + assert _weather_code_to_desc(96, language="zh") == "雷阵雨" + assert _weather_code_to_desc(99, language="zh") == "雷阵雨" + assert _weather_code_to_desc(96, language="en") == "Thunderstorm" + assert _weather_code_to_desc(99, language="en") == "Thunderstorm" + + class TestSearchLocations: @pytest.mark.asyncio async def test_search_locations_prefers_administrative_match_from_nominatim(self): diff --git a/webapp/app/config/page.tsx b/webapp/app/config/page.tsx index 61490887..1ef1b649 100644 --- a/webapp/app/config/page.tsx +++ b/webapp/app/config/page.tsx @@ -3645,6 +3645,12 @@ function ConfigPageInner() { "Upload up to 6 images. The device cycles to the next image on each refresh.", )} +