fix:修复文章头像显示的bug

This commit is contained in:
Xwen
2023-12-24 21:26:04 +08:00
parent 15d9c272e0
commit 4d15d81c7e

View File

@@ -43,6 +43,8 @@
<script setup> <script setup>
import useUserStore from "@/stores/user"; import useUserStore from "@/stores/user";
import { reactive, watch, onMounted, computed, ref } from "vue"; import { reactive, watch, onMounted, computed, ref } from "vue";
import { upload } from "@/apis/fileApi";
//userInfo //userInfo
//{icon,name,role,id},根据判断userInfo是否等于未定义来觉得是当前登录用户信息还是其他人信息 //{icon,name,role,id},根据判断userInfo是否等于未定义来觉得是当前登录用户信息还是其他人信息
const props = defineProps([ const props = defineProps([
@@ -62,15 +64,16 @@ const userInfo = reactive({
userLimit: "", userLimit: "",
}); });
const iconUrl = ref("/favicon.ico"); const iconUrl = ref("/favicon.ico");
const iconUrlHandler = () => { const iconUrlHandler = (icon) => {
if ( if (
userInfo.icon == null || userInfo.icon == null ||
userInfo.icon == undefined || userInfo.icon == undefined ||
userInfo.icon == "" userInfo.icon == ""
) { ) {
return "/favicon.ico"; return "/favicon.ico";
} else {
return import.meta.env.VITE_APP_BASEAPI + "/file/" + icon;
} }
return `/favicon.ico`;
}; };
watch(userStore, (n) => { watch(userStore, (n) => {