diff --git a/lib/routes/bilibili/fav.js b/lib/routes/bilibili/fav.js index b0ace6fa5..f208751be 100644 --- a/lib/routes/bilibili/fav.js +++ b/lib/routes/bilibili/fav.js @@ -23,7 +23,6 @@ module.exports = async (ctx) => { description: `${userName} 的 bilibili 收藏夹 ${favName}`, item: - data && data.medias && data.medias.map((item) => ({ title: item.title, diff --git a/lib/routes/juejin/posts.js b/lib/routes/juejin/posts.js index 2c1792784..0546ae1da 100644 --- a/lib/routes/juejin/posts.js +++ b/lib/routes/juejin/posts.js @@ -13,7 +13,7 @@ module.exports = async (ctx) => { }, }); const { data } = response.data; - const username = data && data[0] && data[0].author_user_info && data[0].author_user_info.user_name; + const username = data[0] && data[0].author_user_info && data[0].author_user_info.user_name; const resultItems = await util.ProcessFeed(data, ctx.cache); ctx.state.data = { diff --git a/lib/routes/juejin/shares.js b/lib/routes/juejin/shares.js index 2c982c7e2..9b7eaa3a5 100644 --- a/lib/routes/juejin/shares.js +++ b/lib/routes/juejin/shares.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { }, }); const data = response.data.d.entrylist; - const username = data && data[0] && data[0].user && data[0].user.username; + const username = data[0] && data[0].user && data[0].user.username; const resultItems = await util.ProcessFeed(data, ctx.cache); ctx.state.data = { diff --git a/lib/routes/keep/user.js b/lib/routes/keep/user.js index ff37d9a6e..b8ef95af2 100644 --- a/lib/routes/keep/user.js +++ b/lib/routes/keep/user.js @@ -18,30 +18,28 @@ module.exports = async (ctx) => { title: `${data[0].author.username} 的 Keep 动态`, link: `https://show.gotokeep.com/users/${id}`, language: 'zh-cn', - item: - data && - 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.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}` : '' + }`, + }; + }), }; }; diff --git a/lib/routes/mi/board.js b/lib/routes/mi/board.js index a6187812e..67dadce12 100644 --- a/lib/routes/mi/board.js +++ b/lib/routes/mi/board.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { }, }); const data = response.data.entity.records; - const name = data && data[0].boards[0].boardName; + const name = data[0].boards[0].boardName; ctx.state.data = { title: name + '-小米社区', diff --git a/lib/routes/sketch/beta.js b/lib/routes/sketch/beta.js index 954f48e8b..c1f0c12f1 100644 --- a/lib/routes/sketch/beta.js +++ b/lib/routes/sketch/beta.js @@ -39,20 +39,18 @@ module.exports = async (ctx) => { description: 'Sketch is a design toolkit built to help you create your best work — from your earliest ideas, through to final artwork.', image: 'https://cdn.sketchapp.com/assets/components/block-buy/logo.png', - item: - list && - list - .map((index, item) => { - item = $(item); - return { - title: `${item.find('h1').first().text()}`, - description: `${item.html()}`, - link: `https://www.sketch.com/updates/`, - pubDate: new Date(pubdateString).toLocaleDateString(), - guid: version, - }; - }) - .get(), + item: list + .map((index, item) => { + item = $(item); + return { + title: `${item.find('h1').first().text()}`, + description: `${item.html()}`, + link: `https://www.sketch.com/updates/`, + pubDate: new Date(pubdateString).toLocaleDateString(), + guid: version, + }; + }) + .get(), }; } else { const content = $('.update-details').html(); diff --git a/lib/routes/zhihu/activities.js b/lib/routes/zhihu/activities.js index c04d44388..1377094b6 100644 --- a/lib/routes/zhihu/activities.js +++ b/lib/routes/zhihu/activities.js @@ -20,91 +20,89 @@ module.exports = async (ctx) => { title: `${data[0].actor.name}的知乎动态`, link: `https://www.zhihu.com/people/${id}/activities`, description: data[0].actor.headline || data[0].actor.description, - item: - data && - data.map((item) => { - const detail = item.target; - let title; - let description; - let url; - const images = []; - let text = ''; - let link = ''; - let author = ''; + item: data.map((item) => { + const detail = item.target; + let title; + let description; + let url; + const images = []; + let text = ''; + let link = ''; + let author = ''; - switch (item.target.type) { - case 'answer': - title = detail.question.title; - author = detail.author.name; - description = utils.ProcessImage(detail.content); - url = `https://www.zhihu.com/question/${detail.question.id}/answer/${detail.id}`; - break; - case 'article': - title = detail.title; - author = detail.author.name; - description = utils.ProcessImage(detail.content); - url = `https://zhuanlan.zhihu.com/p/${detail.id}`; - break; - case 'pin': - title = detail.excerpt_title; - author = detail.author.name; - detail.content.forEach((contentItem) => { - if (contentItem.type === 'text') { - text = `

${contentItem.own_text}

`; - } else if (contentItem.type === 'image') { - images.push(`

`); - } else if (contentItem.type === 'link') { - link = `

${contentItem.title}

`; - } else if (contentItem.type === 'video') { - link = `

${contentItem.own_text}

`; + } else if (contentItem.type === 'image') { + images.push(`

`); + } else if (contentItem.type === 'link') { + link = `

${contentItem.title}

`; + } else if (contentItem.type === 'video') { + link = `

`; - } - }); - description = `${text}${link}${images.join('')}`; - url = `https://www.zhihu.com/pin/${detail.id}`; - break; - case 'question': - title = detail.title; - author = detail.author.name; - description = utils.ProcessImage(detail.detail); - url = `https://www.zhihu.com/question/${detail.id}`; - break; - case 'collection': - title = detail.title; - url = `https://www.zhihu.com/collection/${detail.id}`; - break; - case 'column': - title = detail.title; - description = `

${detail.intro}

`; - url = `https://zhuanlan.zhihu.com/${detail.id}`; - break; - case 'topic': - title = detail.name; - description = `

${detail.introduction}

话题关注者人数:${detail.followers_count}

`; - url = `https://www.zhihu.com/topic/${detail.id}`; - break; - case 'live': - title = detail.subject; - description = detail.description.replace(/\n|\r/g, '
'); - url = `https://www.zhihu.com/lives/${detail.id}`; - break; - case 'roundtable': - title = detail.name; - description = detail.description; - url = `https://www.zhihu.com/roundtable/${detail.id}`; - break; - } + } + }); + description = `${text}${link}${images.join('')}`; + url = `https://www.zhihu.com/pin/${detail.id}`; + break; + case 'question': + title = detail.title; + author = detail.author.name; + description = utils.ProcessImage(detail.detail); + url = `https://www.zhihu.com/question/${detail.id}`; + break; + case 'collection': + title = detail.title; + url = `https://www.zhihu.com/collection/${detail.id}`; + break; + case 'column': + title = detail.title; + description = `

${detail.intro}

`; + url = `https://zhuanlan.zhihu.com/${detail.id}`; + break; + case 'topic': + title = detail.name; + description = `

${detail.introduction}

话题关注者人数:${detail.followers_count}

`; + url = `https://www.zhihu.com/topic/${detail.id}`; + break; + case 'live': + title = detail.subject; + description = detail.description.replace(/\n|\r/g, '
'); + url = `https://www.zhihu.com/lives/${detail.id}`; + break; + case 'roundtable': + title = detail.name; + description = detail.description; + url = `https://www.zhihu.com/roundtable/${detail.id}`; + break; + } - return { - title: `${data[0].actor.name}${item.action_text}: ${title}`, - author: author, - description: description, - pubDate: new Date(item.created_time * 1000).toUTCString(), - link: url, - }; - }), + return { + title: `${data[0].actor.name}${item.action_text}: ${title}`, + author: author, + description: description, + pubDate: new Date(item.created_time * 1000).toUTCString(), + link: url, + }; + }), }; }; diff --git a/lib/routes/zhihu/answers.js b/lib/routes/zhihu/answers.js index 57ad6dbbb..c0a10ea29 100644 --- a/lib/routes/zhihu/answers.js +++ b/lib/routes/zhihu/answers.js @@ -42,14 +42,12 @@ module.exports = async (ctx) => { title: `${data[0].author.name}的知乎回答`, link: `https://www.zhihu.com/people/${id}/answers`, description: data[0].author.headline || data[0].author.description, - item: - data && - data.map((item) => ({ - title: item.question.title, - description: utils.ProcessImage(item.content), - pubDate: new Date(item.created_time * 1000).toUTCString(), - link: `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`, - })), + item: data.map((item) => ({ + title: item.question.title, + description: utils.ProcessImage(item.content), + pubDate: new Date(item.created_time * 1000).toUTCString(), + link: `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`, + })), }; };