mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
nothing
This commit is contained in:
23
src/api/user.ts
Normal file
23
src/api/user.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user