add 'answer' type for jike user (#114)
* fix(jike user): shorten title and add repost content * fix #109 * add 'answer' type for jike user fix title "undefined了: undefined" issue * fix: screen name issue
This commit is contained in:
parent
0822fa0af4
commit
80ff059b63
|
|
@ -29,7 +29,8 @@ module.exports = async (ctx) => {
|
|||
item: data.map((item) => {
|
||||
const typeMap = {
|
||||
'ORIGINAL_POST': '发布',
|
||||
'REPOST': '转发'
|
||||
'REPOST': '转发',
|
||||
'ANSWER': '回答'
|
||||
};
|
||||
|
||||
let linkTemplate = '';
|
||||
|
|
@ -42,7 +43,7 @@ module.exports = async (ctx) => {
|
|||
imgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`;
|
||||
});
|
||||
|
||||
let content = item.content || item.linkInfo && item.linkInfo.title || item.target && item.target.content;
|
||||
let content = item.content || item.linkInfo && item.linkInfo.title || item.target && item.target.content || item.question && item.question.title;
|
||||
const shortenTitle = content.length > 75 ? `${content.substr(0, 75)}...` : content;
|
||||
|
||||
if (item.type === 'REPOST') {
|
||||
|
|
@ -51,12 +52,15 @@ module.exports = async (ctx) => {
|
|||
'ORIGINAL_POST': `https://web.okjike.com/post-detail/${item.target.id}/originalPost`,
|
||||
'REPOST': `https://web.okjike.com/post-detail/${item.target.id}/repost`
|
||||
};
|
||||
|
||||
const screenNameTemplate = item.target.user ? `<p>@${item.target.user.screenName}</p>` : '';
|
||||
|
||||
let repostImgTemplate = '';
|
||||
item.target.pictures && item.target.pictures.forEach((item) => {
|
||||
repostImgTemplate += `<p><img style="box-shadow: 0 0 1px rgba(0,0,0,.2);" referrerpolicy="no-referrer" src="${item.thumbnailUrl}"></p>`;
|
||||
});
|
||||
|
||||
let repostContent = `<a style="padding:15px;margin-top:10px;display:block;border-radius:4px;background-color:#fff;border:1px solid rgba(0,0,0,.08);text-decoration:none;" href="${targetLinkMap[item.target.type]}" target="_blank"><p>@${item.target.user.screenName}</p>${item.target.content}${repostImgTemplate}</a>`;
|
||||
let repostContent = `<a style="padding:15px;margin-top:10px;display:block;border-radius:4px;background-color:#fff;border:1px solid rgba(0,0,0,.08);text-decoration:none;" href="${targetLinkMap[item.target.type]}" target="_blank">${screenNameTemplate}${item.target.content}${repostImgTemplate}</a>`;
|
||||
content = `${content}${repostContent}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue