This commit is contained in:
wyf
2025-05-23 14:51:09 +08:00
parent 8a418c9c98
commit c650bad8b1
36 changed files with 1297 additions and 892 deletions

View File

@@ -307,6 +307,7 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
// 获取天气信息
Future<void> _getCurrentWeather() async {
if (model.latitude == null || model.longitude == null) {
EasyDartModule.logger.error("获取天气失败:位置数据获取失败");
return; // 如果位置数据没有获取到,则不更新天气
}
String? language = "zh_CN";
@@ -341,14 +342,13 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
model.current_temperature = weather.temperature?.celsius?.toInt();
model.wind_speed = weather.windSpeed?.toInt();
model.weatherIcon = weather.weatherIcon;
if (model.weatherIcon != null) {
model.weatherIconurl =
"https://openweathermap.org/img/w/${model.weatherIcon}.png";
}
updateAll(); // 更新 UI
} catch (e) {
EasyDartModule.logger.error("获取天气失败: $e");
print('获取天气失败: $e');
}
}