diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue index 7a2c67ffd..958879fce 100755 --- a/resources/assets/js/components/UserAvatar.vue +++ b/resources/assets/js/components/UserAvatar.vue @@ -95,12 +95,16 @@ this.setUser(data) } }); + this.$store.state.userAvatar[this._uid] = this.$props; }, beforeDestroy() { if (this.subscribe) { this.subscribe.unsubscribe(); this.subscribe = null; } + if (this.$store.state.userAvatar[this._uid] !== undefined) { + delete this.$store.state.userAvatar[this._uid]; + } }, computed: { ...mapState(["userId", "userInfo", "userOnline", "cacheUserBasic"]), diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index a5bfd8f29..b7be142b8 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -250,12 +250,13 @@ export default { }, /** - * 获取基本数据(项目、对话、仪表盘任务) + * 获取基本数据(项目、对话、仪表盘任务、会员基本信息) + * @param state * @param dispatch * @param timeout * @returns {Promise} */ - getBasicData({dispatch}, timeout) { + getBasicData({state, dispatch}, timeout) { if (typeof timeout === "number") { return new Promise(resolve => { window.__getBasicData && clearTimeout(window.__getBasicData) @@ -270,6 +271,11 @@ export default { dispatch("getProjects").catch(() => {}); dispatch("getDialogs").catch(() => {}); dispatch("getTaskForDashboard"); + // + const allIds = Object.values(state.userAvatar).map(({userid}) => userid); + [...new Set(allIds)].some(userid => { + dispatch("getUserBasic", {userid}); + }) }, /** diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 34b28ed23..55f0d8c6f 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -50,6 +50,7 @@ const stateData = { userToken: '', userIsAdmin: false, userOnline: {}, + userAvatar: {}, // 会话聊天 dialogMsgs: [],