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.setUser(data)
} }
}); });
this.$store.state.userAvatar[this._uid] = this.$props;
}, },
beforeDestroy() { beforeDestroy() {
if (this.subscribe) { if (this.subscribe) {
this.subscribe.unsubscribe(); this.subscribe.unsubscribe();
this.subscribe = null; this.subscribe = null;
} }
if (this.$store.state.userAvatar[this._uid] !== undefined) {
delete this.$store.state.userAvatar[this._uid];
}
}, },
computed: { computed: {
...mapState(["userId", "userInfo", "userOnline", "cacheUserBasic"]), ...mapState(["userId", "userInfo", "userOnline", "cacheUserBasic"]),

View File

@ -250,12 +250,13 @@ export default {
}, },
/** /**
* 获取基本数据项目对话仪表盘任务 * 获取基本数据项目对话仪表盘任务会员基本信息
* @param state
* @param dispatch * @param dispatch
* @param timeout * @param timeout
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
getBasicData({dispatch}, timeout) { getBasicData({state, dispatch}, timeout) {
if (typeof timeout === "number") { if (typeof timeout === "number") {
return new Promise(resolve => { return new Promise(resolve => {
window.__getBasicData && clearTimeout(window.__getBasicData) window.__getBasicData && clearTimeout(window.__getBasicData)
@ -270,6 +271,11 @@ export default {
dispatch("getProjects").catch(() => {}); dispatch("getProjects").catch(() => {});
dispatch("getDialogs").catch(() => {}); dispatch("getDialogs").catch(() => {});
dispatch("getTaskForDashboard"); 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: '', userToken: '',
userIsAdmin: false, userIsAdmin: false,
userOnline: {}, userOnline: {},
userAvatar: {},
// 会话聊天 // 会话聊天
dialogMsgs: [], dialogMsgs: [],