perf: ws重连后重新获取会员基本信息

This commit is contained in:
kuaifan 2022-05-23 11:27:31 +08:00
parent 464d7bc635
commit c53d7a5dd2
3 changed files with 13 additions and 2 deletions

View File

@ -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"]),

View File

@ -250,12 +250,13 @@ export default {
},
/**
* 获取基本数据项目对话仪表盘任务
* 获取基本数据项目对话仪表盘任务会员基本信息
* @param state
* @param dispatch
* @param timeout
* @returns {Promise<unknown>}
*/
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});
})
},
/**

View File

@ -50,6 +50,7 @@ const stateData = {
userToken: '',
userIsAdmin: false,
userOnline: {},
userAvatar: {},
// 会话聊天
dialogMsgs: [],