Authored by shuaiguo

feat(article/detail): 详情点赞同步列表 reviewed by 邱骏

... ... @@ -2,6 +2,8 @@ const FETCH_DETAIL_INFO = 'FETCH_DETAIL_INFO';
const UPDATE_ARTICLE_PRAISE_INFO = 'UPDATE_ARTICLE_PRAISE_INFO';
const FETCH_RECOMMEND_ARTICLES = 'FETCH_RECOMMEND_ARTICLES';
import { UPDATE_ARTICLE_PRAISE } from './list/types';
export default function() {
return {
namespaced: true,
... ... @@ -30,6 +32,7 @@ export default function() {
});
if (res.code === 200) {
commit(`article/articleList/${UPDATE_ARTICLE_PRAISE}`, {articleId, status}, {root: true});
commit(UPDATE_ARTICLE_PRAISE_INFO);
}
},
... ...
... ... @@ -33,9 +33,15 @@ export default {
// 更新点赞
[Types.UPDATE_ARTICLE_PRAISE](state, {articleId, status, index}) {
let article = state.articleList[index];
let article = null;
if (article.articleId === parseInt(articleId, 10)) {
if (index) {
article = state.articleList[index];
} else {
article = state.articleList.find(item => +item.articleId === +articleId);
}
if (article && article.articleId === parseInt(articleId, 10)) {
if (article.praiseCount === 0 && status === 0) {
article.praiseCount += 1;
article.hasPraised = 'Y';
... ...