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