fix: 修复账号信息更新消息订阅从新进入页面状态没有改变问题

This commit is contained in:
“huailei000” 2022-11-10 14:31:57 +08:00 committed by Jiangjie.Bai
parent 242f958428
commit d566adb644

View File

@ -37,8 +37,7 @@ import DetailCard from '@/components/DetailCard'
import QuickActions from '@/components/QuickActions' import QuickActions from '@/components/QuickActions'
import UserConfirmDialog from '@/components/UserConfirmDialog' import UserConfirmDialog from '@/components/UserConfirmDialog'
import { toSafeLocalDateStr } from '@/utils/common' import { toSafeLocalDateStr } from '@/utils/common'
import { getProfile } from '@/api/users' import store from '@/store'
import { mapState } from 'vuex'
export default { export default {
name: 'ProfileInfo', name: 'ProfileInfo',
@ -48,9 +47,14 @@ export default {
QuickActions, QuickActions,
UserConfirmDialog UserConfirmDialog
}, },
props: {
object: {
type: Object,
default: () => store.state.users.profile
}
},
data() { data() {
return { return {
object: this.userProfile || {},
url: `/api/v1/users/profile/`, url: `/api/v1/users/profile/`,
showPasswordDialog: false, showPasswordDialog: false,
currentEdit: '', currentEdit: '',
@ -213,9 +217,6 @@ export default {
} }
}, },
computed: { computed: {
...mapState({
userProfile: state => state.users.profile
}),
detailCardItems() { detailCardItems() {
return [ return [
{ {
@ -298,12 +299,6 @@ export default {
return url return url
} }
}, },
created() {
getProfile().then(res => {
this.object = res
this.$store.commit('users/SET_PROFILE', res)
})
},
methods: { methods: {
updateUserReceiveBackends(val) { updateUserReceiveBackends(val) {
this.$axios.patch( this.$axios.patch(
@ -311,6 +306,7 @@ export default {
{ 'receive_backends': this.getReceiveBackendList() } { 'receive_backends': this.getReceiveBackendList() }
).then(res => { ).then(res => {
this.$message.success(this.$t('common.updateSuccessMsg')) this.$message.success(this.$t('common.updateSuccessMsg'))
this.$store.dispatch('users/getProfile', true)
}).catch(err => { }).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err)) this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
}) })