diff --git a/weapp/utils/journal.js b/weapp/utils/journal.js index 8dc55e3..3938e4f 100644 --- a/weapp/utils/journal.js +++ b/weapp/utils/journal.js @@ -4,7 +4,9 @@ function diaryEntry(item) { if (typeof images === 'string') { try { images = JSON.parse(images); } catch (e) { images = []; } } if (!Array.isArray(images)) images = []; var date = String(item.created_at || '').slice(0, 10); - return Object.assign({}, item, { title: item.title || '日常的一页', summary: String(item.content || '').replace(/\s+/g, ' ').slice(0, 100), date: date, dateLabel: date.replace(/-/g, '.'), cover: getImageUrl(images[0]), imageCount: images.length, author: item.creator_name || item.created_by_name || '' }); + var characters = Array.from(String(item.content || '').replace(/\s+/g, ' ')); + var summary = characters.slice(0, 100).join('') + (characters.length > 100 ? '…' : ''); + return Object.assign({}, item, { title: item.title || '日常的一页', summary: summary, date: date, dateLabel: date.replace(/-/g, '.'), cover: getImageUrl(images[0]), imageCount: images.length, author: item.creator_name || item.created_by_name || '' }); } function albumEntry(item) { return Object.assign({}, item, { cover: getImageUrl(item.cover), title: item.title || '我们的相册' }); } function memoryEntry(item) {