This commit is contained in:
yuping
2022-12-13 17:02:07 +08:00
parent de9b83c9e7
commit 19bfce36fe
5 changed files with 151 additions and 91 deletions

View File

@@ -1,3 +1,7 @@
import {watch, ref} from "vue";
import {boeRequest} from "@/api/request";
import {BASE, GET_USER_LIST} from "@/api/ThirdApi";
export function useImage(src) {
return new URL(`../assets/image/${src}`, import.meta.url).href
}
@@ -10,4 +14,14 @@ export function setCookie(name, value, perpetual) {
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` : '')
watch(id, () => {
id.value && boeRequest(GET_USER_LIST, {id: id.value}).then(res => {
avatar.value = avatar.value + res.result.userInfoList[0].avatar
})
})
return avatar
}