From bb80a2ec7c5399a1a4cf9df14e04d3aa2cb0e5d1 Mon Sep 17 00:00:00 2001 From: Rein-Ou <52846432+Rein-Ou@users.noreply.github.com> Date: Wed, 30 Mar 2022 21:44:23 +0800 Subject: [PATCH] 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 --- lib/v2/qweather/now.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/v2/qweather/now.js b/lib/v2/qweather/now.js index b0982d605..626e3af84 100644 --- a/lib/v2/qweather/now.js +++ b/lib/v2/qweather/now.js @@ -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, };