mirror of
https://github.com/blossom-editor/blossom
synced 2024-11-17 22:48:03 +08:00
天气未配置时的提示(#14)
This commit is contained in:
parent
0323f84b51
commit
1db4efc0fe
@ -47,7 +47,11 @@ public class WeatherManager {
|
||||
Map<String, Object> maps = initParam(location);
|
||||
if (maps == null) {
|
||||
log.info("未配置天气信息, 忽略天气查询");
|
||||
return null;
|
||||
HeWeatherDTO weather = new HeWeatherDTO();
|
||||
HeWeatherDTO.Location l = new HeWeatherDTO.Location();
|
||||
l.setName("未配置天气");
|
||||
weather.setLocation(l);
|
||||
return weather;
|
||||
}
|
||||
HttpResponse city;
|
||||
HttpResponse now;
|
||||
@ -130,7 +134,7 @@ public class WeatherManager {
|
||||
*/
|
||||
public Map<String, Object> initParam(String location) {
|
||||
Map<String, String> paramMap = paramService.selectMap(false, ParamEnum.HEFENG_KEY);
|
||||
if (MapUtil.isNotEmpty(paramMap) && StrUtil.isBlank(paramMap.get(ParamEnum.HEFENG_KEY.name()))) {
|
||||
if (MapUtil.isNotEmpty(paramMap) && StrUtil.isNotBlank(paramMap.get(ParamEnum.HEFENG_KEY.name()))) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("location", location);
|
||||
map.put("key", paramMap.get(ParamEnum.HEFENG_KEY.name()));
|
||||
|
@ -112,7 +112,7 @@ const getImgUrl = (name: string) => {
|
||||
|
||||
const weather = ref({
|
||||
location: {
|
||||
name: ''
|
||||
name: '未配置天气'
|
||||
},
|
||||
now: {
|
||||
iconValue: '#wt-qing',
|
||||
@ -134,12 +134,16 @@ const getWeather = () => {
|
||||
weatherResult.value = 'LOADING';
|
||||
setTimeout(() => {
|
||||
getAll({ location: userStore.userinfo.location }).then(resp => {
|
||||
resp.data.now.img = getImgUrl(resp.data.now.iconValue.replaceAll('#wt-', ''))
|
||||
// resp.data.now.img = '@renderer/assets/imgs/weather/' + resp.data.now.iconValue.replaceAll('#wt-', '') + '.png'
|
||||
resp.data.daily[0].img = getImgUrl(resp.data.daily[0].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
resp.data.daily[1].img = getImgUrl(resp.data.daily[1].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
resp.data.daily[2].img = getImgUrl(resp.data.daily[2].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
weather.value = resp.data
|
||||
console.log(resp.data);
|
||||
if (resp.data.now) {
|
||||
resp.data.now.img = getImgUrl(resp.data.now.iconValue.replaceAll('#wt-', ''))
|
||||
}
|
||||
if (resp.data.daily) {
|
||||
resp.data.daily[0].img = getImgUrl(resp.data.daily[0].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
resp.data.daily[1].img = getImgUrl(resp.data.daily[1].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
resp.data.daily[2].img = getImgUrl(resp.data.daily[2].iconValueDay.replaceAll('#wt-', '') + '-s')
|
||||
}
|
||||
weather.value = { ...weather.value, ...resp.data }
|
||||
})
|
||||
}, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user