...
|
...
|
@@ -23,16 +23,18 @@ function updateAuthorStates(state, item) { |
|
|
}
|
|
|
|
|
|
function updateArticleState(state, item) {
|
|
|
updateAuthorStates(state, item);
|
|
|
let articleState = state.articleStates[item.articleId] || {};
|
|
|
|
|
|
Vue.set(state.articleStates, item.articleId, {
|
|
|
hasAttention: item.hasAttention,
|
|
|
hasFavor: item.hasFavor,
|
|
|
hasPraise: item.hasPraise,
|
|
|
commentCount: item.commentCount,
|
|
|
favoriteCount: item.favoriteCount,
|
|
|
praiseCount: item.praiseCount,
|
|
|
comments: item.comments
|
|
|
hasAttention: item.hasAttention || articleState.hasAttention,
|
|
|
hasFavor: item.hasFavor || articleState.hasFavor,
|
|
|
hasPraise: item.hasPraise || articleState.hasPraise,
|
|
|
commentCount: item.commentCount || articleState.commentCount || 0,
|
|
|
favoriteCount: item.favoriteCount || articleState.favoriteCount || 0,
|
|
|
praiseCount: item.praiseCount || articleState.praiseCount || 0,
|
|
|
comments: item.comments || articleState.comments
|
|
|
});
|
|
|
updateAuthorStates(state, item);
|
|
|
}
|
|
|
|
|
|
function setArticleList(state, data, type, thumb) {
|
...
|
...
|
@@ -173,6 +175,14 @@ export default { |
|
|
[Types.UPDATE_ARTICLE_STATE](state, {data}) {
|
|
|
updateArticleState(state, data);
|
|
|
},
|
|
|
[Types.UPDATE_ARTICLE_COMMENT_COUNT](state, {articleId, commentCount}) {
|
|
|
let article = state.articleStates[articleId];
|
|
|
|
|
|
if (article) {
|
|
|
article.commentCount = commentCount ? commentCount : (article.commentCount + 1);
|
|
|
updateArticleState(state, article);
|
|
|
}
|
|
|
},
|
|
|
[Types.ASYNC_ARTICLE_COMMENT](state, {articleId, type}) {
|
|
|
state[articlefield(type)].forEach(article => {
|
|
|
if (article.articleId === articleId) {
|
...
|
...
|
|