fix:修复头像没有默认值的bug
This commit is contained in:
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -50,14 +50,14 @@ const userInfo = reactive({
|
|||||||
role: [],
|
role: [],
|
||||||
id: "",
|
id: "",
|
||||||
});
|
});
|
||||||
const iconUrl = ref("/src/assets/logo.ico");
|
const iconUrl = ref("../../src/assets/common/icons/logo.ico");
|
||||||
const iconUrlHandler = () => {
|
const iconUrlHandler = () => {
|
||||||
if (
|
if (
|
||||||
userInfo.icon == null ||
|
userInfo.icon == null ||
|
||||||
userInfo.icon == undefined ||
|
userInfo.icon == undefined ||
|
||||||
userInfo.icon == ""
|
userInfo.icon == ""
|
||||||
) {
|
) {
|
||||||
return "/src/assets/logo.ico";
|
return "../../src/assets/common/icons/logo.ico";
|
||||||
}
|
}
|
||||||
return `${import.meta.env.VITE_APP_BASEAPI}/file/${userInfo.icon}`;
|
return `${import.meta.env.VITE_APP_BASEAPI}/file/${userInfo.icon}`;
|
||||||
};
|
};
|
||||||
@@ -88,7 +88,6 @@ const Init = () => {
|
|||||||
userInfo.role = props.userInfo.role;
|
userInfo.role = props.userInfo.role;
|
||||||
userInfo.id = props.userInfo.id;
|
userInfo.id = props.userInfo.id;
|
||||||
iconUrl.value = iconUrlHandler(userInfo.icon);
|
iconUrl.value = iconUrlHandler(userInfo.icon);
|
||||||
console.log("使用传入值:", iconUrl.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用当前登录用户
|
//使用当前登录用户
|
||||||
@@ -97,8 +96,7 @@ const Init = () => {
|
|||||||
userInfo.nick = userStore.name;
|
userInfo.nick = userStore.name;
|
||||||
userInfo.role = userStore.role;
|
userInfo.role = userStore.role;
|
||||||
userInfo.id = userStore.id;
|
userInfo.id = userStore.id;
|
||||||
iconUrl.value = userInfo.icon;
|
iconUrl.value = iconUrlHandler(userInfo.icon);
|
||||||
console.log("当前登陆:", iconUrl.value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ const useUserStore = defineStore("user", {
|
|||||||
const user = res.user;
|
const user = res.user;
|
||||||
const avatar =
|
const avatar =
|
||||||
user.icon == "" || user.icon == null
|
user.icon == "" || user.icon == null
|
||||||
? "/src/assets/logo.ico"
|
? "../../src/assets/common/icons/logo.ico"
|
||||||
: import.meta.env.VITE_APP_BASEAPI + "/file/" + user.icon;
|
: import.meta.env.VITE_APP_BASEAPI + "/file/" + user.icon;
|
||||||
console.log(avatar, "store的avatar");
|
|
||||||
if (res.roleCodes && res.roleCodes.length > 0) {
|
if (res.roleCodes && res.roleCodes.length > 0) {
|
||||||
// 验证返回的roles是否是一个非空数组
|
// 验证返回的roles是否是一个非空数组
|
||||||
this.roles = res.roleCodes;
|
this.roles = res.roleCodes;
|
||||||
|
|||||||
Reference in New Issue
Block a user