fix(route) qweather/now (#9419)
* qweather_now * now * pubDate fix * timezone * parseDate * item link fix * cache id fix * time fix * format code * Update forecast.md
This commit is contained in:
parent
d50e0948dc
commit
bb80a2ec7c
|
|
@ -15,7 +15,8 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
const requestUrl = rootUrl + 'key=' + config.hefeng.key + '&location=' + id;
|
||||
const responseData = await ctx.cache.tryGet(
|
||||
ctx.params.location,
|
||||
|
||||
ctx.params.location + '_now',
|
||||
async () => {
|
||||
const response = await got(requestUrl);
|
||||
return response.data;
|
||||
|
|
@ -26,15 +27,19 @@ module.exports = async (ctx) => {
|
|||
|
||||
const data = [responseData.now];
|
||||
|
||||
const timeObj = parseDate(responseData.updateTime);
|
||||
|
||||
const time_show = timeObj.getFullYear() + '-' + timeObj.getMonth() + '-' + timeObj.getDay() + ' ' + timeObj.getHours() + ':' + timeObj.getMinutes();
|
||||
|
||||
ctx.state.data = {
|
||||
title: ctx.params.location + '实时天气',
|
||||
description: ctx.params.location + '实时天气状况',
|
||||
item: data.map((item) => ({
|
||||
title: '观测时间:' + parseDate(responseData.updateTime),
|
||||
title: '观测时间:' + time_show,
|
||||
description: art(path.join(__dirname, './util/now.art'), { item }),
|
||||
pubDate: parseDate(responseData.updateTime),
|
||||
guid: '位置:' + ctx.params.location + '--时间:' + parseDate(responseData.updateTime),
|
||||
link: item.fxLink,
|
||||
pubDate: timeObj,
|
||||
guid: '位置:' + ctx.params.location + '--时间:' + time_show,
|
||||
link: responseData.fxLink,
|
||||
})),
|
||||
link: responseData.fxLink,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue