From 1b287aad3e3e15949b0ca30c6bcf0f7dd99808c1 Mon Sep 17 00:00:00 2001 From: hibert Date: Tue, 25 May 2021 21:25:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20keep=E8=BF=90=E5=8A=A8=E6=97=A5?= =?UTF-8?q?=E8=AE=B0=E8=B7=AF=E7=94=B1=E9=94=99=E8=AF=AF=20(#7257)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hibert Co-authored-by: Ubuntu --- lib/routes/keep/user.js | 46 +++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/routes/keep/user.js b/lib/routes/keep/user.js index b8ef95af2e95df..d2d580a4f9b3eb 100644 --- a/lib/routes/keep/user.js +++ b/lib/routes/keep/user.js @@ -18,28 +18,30 @@ module.exports = async (ctx) => { title: `${data[0].author.username} 的 Keep 动态`, link: `https://show.gotokeep.com/users/${id}`, language: 'zh-cn', - item: data.map((item) => { - let images = []; - if (item.images) { - images = item.meta.picture ? item.images.concat(item.meta.picture) : item.images; - } else if (item.meta.picture) { - images = [item.meta.picture]; - } - let imagesTpl = ''; - images.forEach((item) => { - imagesTpl += ``; - }); + item: data + .filter((item) => 'title' in item.meta) + .map((item) => { + let images = []; + if (item.images) { + images = item.meta.picture ? item.images.concat(item.meta.picture) : item.images; + } else if (item.meta.picture) { + images = [item.meta.picture]; + } + let imagesTpl = ''; + images.forEach((item) => { + imagesTpl += ``; + }); - const minute = Math.floor(item.meta.secondDuration / 60); - const second = item.meta.secondDuration - minute * 60; - return { - title: item.meta.title.trim(), - pubDate: item.created, - link: `https://show.gotokeep.com/entries/${item.id}`, - description: `项目:${item.meta.name === item.meta.workoutName ? item.meta.name : `${item.meta.name} - ${item.meta.workoutName}`}
时长:${minute}分${second}秒${item.content ? `
备注:${item.content}` : ''}${ - imagesTpl ? `
${imagesTpl}` : '' - }`, - }; - }), + const minute = Math.floor(item.meta.secondDuration / 60); + const second = item.meta.secondDuration - minute * 60; + return { + title: item.meta.title.trim(), + pubDate: item.created, + link: `https://show.gotokeep.com/entries/${item.id}`, + description: `项目:${item.meta.name === item.meta.workoutName ? item.meta.name : `${item.meta.name} - ${item.meta.workoutName}`}
时长:${minute}分${second}秒${item.content ? `
备注:${item.content}` : ''}${ + imagesTpl ? `
${imagesTpl}` : '' + }`, + }; + }), }; };