This commit is contained in:
yuping
2022-12-13 18:11:55 +08:00
parent 6573261fd6
commit c75d463c40
4 changed files with 73 additions and 66 deletions

View File

@@ -2,6 +2,8 @@ import {watch, ref} from "vue";
import {boeRequest} from "@/api/request";
import {BASE, GET_USER_LIST} from "@/api/ThirdApi";
const BASE_AVATAR = import.meta.env.DEV ? `${BASE}/upload` : ''
export function useImage(src) {
return new URL(`../assets/image/${src}`, import.meta.url).href
}
@@ -16,12 +18,13 @@ export function getCookie(name) {
return document.cookie?.split(";").find(e => e.includes(name)).replace(`${name}=`, '') || ''
}
export function useUserInfoAvatar(id) {
const avatar = ref(import.meta.env.DEV ? `${BASE}/upload` : '')
export function useUserInfo(id) {
const userInfo = ref({})
watch(id, () => {
id.value && boeRequest(GET_USER_LIST, {id: id.value}).then(res => {
avatar.value = avatar.value + res.result.userInfoList[0].avatar
userInfo.value = res.result.userInfoList[0]
userInfo.value.avatar = BASE_AVATAR + userInfo.value.avatar
})
})
return avatar
return userInfo
}