mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
24 lines
625 B
TypeScript
24 lines
625 B
TypeScript
import { QueryGetAPI } from '@/api/query'
|
|
import { BASE_API } from '@/data/constants'
|
|
import { APIRoot, UserInfo } from './api-models'
|
|
import { ref } from 'vue'
|
|
|
|
const ACCOUNT_URL = `${BASE_API}user/`
|
|
export const USERS = ref<{ [uId: number]: UserInfo }>({})
|
|
|
|
export async function useUser(uId: number) {
|
|
if (!USERS.value[uId]) {
|
|
const result = await GetInfo(uId)
|
|
if (result.code == 200) {
|
|
USERS.value[uId] = result.data
|
|
}
|
|
}
|
|
return USERS.value[uId]
|
|
}
|
|
|
|
export async function GetInfo(uId: number): Promise<APIRoot<UserInfo>> {
|
|
return QueryGetAPI<UserInfo>(`${ACCOUNT_URL}info`, {
|
|
uId: uId,
|
|
})
|
|
}
|