更新
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user