fix: 取消收藏后主页不显示当前仪表板

This commit is contained in:
fit2cloud-chenyw 2021-05-21 15:54:20 +08:00
parent 04abe0c182
commit 27109824f2
2 changed files with 18 additions and 5 deletions

View File

@ -36,8 +36,13 @@ export default {
starDatas: []
}
},
computed: {
panelInfo() {
return this.$store.state.panel.panelInfo
}
},
created() {
bus.$on('panle_start_list_refresh', this.initData)
bus.$on('panle_start_list_refresh', this.refreshStarts)
this.initData()
},
methods: {
@ -64,12 +69,20 @@ export default {
remove(row) {
deleteEnshrine(row.storeId).then(res => {
this.initData()
this.panelInfo && this.panelInfo.id && row.panelGroupId === this.panelInfo.id && this.setMainNull()
})
},
initData() {
enshrineList({}).then(res => {
this.starDatas = res.data
})
},
setMainNull() {
this.$store.dispatch('panel/setPanelInfo', { id: null, name: '', preStyle: null })
},
refreshStarts(isStar) {
this.initData()
!isStar && this.setMainNull()
}
}
}

View File

@ -162,13 +162,13 @@ export default {
star() {
this.panelInfo && saveEnshrine(this.panelInfo.id).then(res => {
this.hasStar = true
this.refreshStarList()
this.refreshStarList(true)
})
},
unstar() {
this.panelInfo && deleteEnshrine(this.panelInfo.id).then(res => {
this.hasStar = false
this.refreshStarList()
this.refreshStarList(false)
})
},
initHasStar() {
@ -177,8 +177,8 @@ export default {
this.hasStar = res.data && res.data.some(item => item.panelGroupId === this.panelInfo.id)
})
},
refreshStarList() {
bus.$emit('panle_start_list_refresh')
refreshStarList(isStar) {
bus.$emit('panle_start_list_refresh', isStar)
}
}