:bugs: 修复专题界面,切换专题不请求数据问题

This commit is contained in:
ronger 2021-02-23 16:34:22 +08:00
parent 0d91b38fca
commit ecba7403b8

View File

@ -19,7 +19,8 @@ export const state = () => {
detail: { detail: {
fetching: false, fetching: false,
data: {} data: {}
} },
topicUri: ''
} }
} }
@ -45,7 +46,6 @@ export const mutations = {
clearDetailData(state, action) { clearDetailData(state, action) {
state.detail.data = {} state.detail.data = {}
}, },
// 更新文章阅读全文状态 // 更新文章阅读全文状态
updateDetailRenderedState(state, action) { updateDetailRenderedState(state, action) {
Vue.set( Vue.set(
@ -59,6 +59,9 @@ export const mutations = {
}, },
updateArticleSponsorCount(state, action) { updateArticleSponsorCount(state, action) {
state.detail.data.articleSponsorCount += action.sponsorNumber state.detail.data.articleSponsorCount += action.sponsorNumber
},
updateTopicUri(state, action) {
state.topicUri = action
} }
} }
@ -68,10 +71,13 @@ export const actions = {
commit('updateListFetching', true) commit('updateListFetching', true)
// 当前页判断 // 当前页判断
let currentData = JSON.parse(JSON.stringify(state)).list.data let currentData = JSON.parse(JSON.stringify(state)).list.data
let topicUri = JSON.parse(JSON.stringify(state)).topicUri
if (Number(params.page) === currentData.pagination.currentPage) { if (Number(params.page) === currentData.pagination.currentPage) {
if (topicUri && topicUri === params.topic_uri) {
commit('updateListFetching', false) commit('updateListFetching', false)
return return
} }
}
// 清空已有数据 // 清空已有数据
commit('updateListData', getDefaultListData()) commit('updateListData', getDefaultListData())
let data = { let data = {
@ -85,6 +91,7 @@ export const actions = {
.then(response => { .then(response => {
commit('updateListFetching', false); commit('updateListFetching', false);
commit('updateListData', response); commit('updateListData', response);
commit('updateTopicUri', params.topic_uri || '');
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);