mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-14 05:16:47 +08:00
init
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user