From 86150cc571d36fd1d3398bcb3ca7e2fe709620f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Mon, 19 Sep 2022 16:13:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=86=85=E5=AE=B9=E6=9B=B4=E6=96=B0=E4=B8=8D?= =?UTF-8?q?=E5=8F=8A=E6=97=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/profile/ProfileInfo.vue | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/views/profile/ProfileInfo.vue b/src/views/profile/ProfileInfo.vue index e1c3e8491..46c81cad4 100644 --- a/src/views/profile/ProfileInfo.vue +++ b/src/views/profile/ProfileInfo.vue @@ -37,7 +37,8 @@ import DetailCard from '@/components/DetailCard' import QuickActions from '@/components/QuickActions' import UserConfirmDialog from '@/components/UserConfirmDialog' import { toSafeLocalDateStr } from '@/utils/common' -import store from '@/store' +import { getProfile } from '@/api/users' +import { mapState } from 'vuex' export default { name: 'ProfileInfo', @@ -47,14 +48,9 @@ export default { QuickActions, UserConfirmDialog }, - props: { - object: { - type: Object, - default: () => store.state.users.profile - } - }, data() { return { + object: this.userProfile || {}, url: `/api/v1/users/profile/`, showPasswordDialog: false, currentEdit: '', @@ -160,7 +156,7 @@ export default { attrs: { disabled: true, name: 'site_msg', - model: this.object.receive_backends.indexOf('site_msg') !== -1 + model: this.object?.receive_backends.indexOf('site_msg') !== -1 }, callbacks: { change: this.updateUserReceiveBackends @@ -171,7 +167,7 @@ export default { type: 'switcher', attrs: { name: 'email', - model: this.object.receive_backends.indexOf('email') !== -1 + model: this.object?.receive_backends.indexOf('email') !== -1 }, callbacks: { change: this.updateUserReceiveBackends @@ -182,7 +178,7 @@ export default { type: 'switcher', attrs: { name: 'wecom', - model: this.object.receive_backends.indexOf('wecom') !== -1 + model: this.object?.receive_backends.indexOf('wecom') !== -1 }, has: this.$store.getters.publicSettings.AUTH_WECOM, callbacks: { @@ -194,7 +190,7 @@ export default { type: 'switcher', attrs: { name: 'dingtalk', - model: this.object.receive_backends.indexOf('dingtalk') !== -1 + model: this.object?.receive_backends.indexOf('dingtalk') !== -1 }, has: this.$store.getters.publicSettings.AUTH_DINGTALK, callbacks: { @@ -206,7 +202,7 @@ export default { type: 'switcher', attrs: { name: 'feishu', - model: this.object.receive_backends.indexOf('feishu') !== -1 + model: this.object?.receive_backends.indexOf('feishu') !== -1 }, has: this.$store.getters.publicSettings.AUTH_FEISHU, callbacks: { @@ -217,6 +213,9 @@ export default { } }, computed: { + ...mapState({ + userProfile: state => state.users.profile + }), detailCardItems() { return [ { @@ -299,6 +298,12 @@ export default { return url } }, + created() { + getProfile().then(res => { + this.object = res + this.$store.commit('users/SET_PROFILE', res) + }) + }, methods: { updateUserReceiveBackends(val) { this.$axios.patch(