perf: 优化UserAvatar组件

This commit is contained in:
kuaifan 2022-05-20 10:23:24 +08:00
parent 2e03cee726
commit 7a168977da

View File

@ -103,7 +103,7 @@
}
},
computed: {
...mapState(["userId", "userInfo", "userOnline"]),
...mapState(["userId", "userInfo", "userOnline", "cacheUserBasic"]),
boxStyle() {
const style = {};
@ -198,6 +198,10 @@
this.setUser(this.userInfo);
return;
}
const tempUser = this.cacheUserBasic.find(({userid}) => userid == this.userid);
if (tempUser) {
this.setUser(tempUser);
}
this.$store.dispatch("getUserBasic", {userid: this.userid});
},