mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update
This commit is contained in:
@@ -5,11 +5,11 @@ import { ref } from 'vue'
|
||||
import { useRouteParams } from '@vueuse/router'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
export const USERS = ref<{ [uId: number]: UserInfo }>({})
|
||||
export const USERS = ref<{ [id: string]: UserInfo }>({})
|
||||
|
||||
export async function useUser(id: number | undefined = undefined) {
|
||||
export async function useUser(id: string | undefined = undefined) {
|
||||
const route = useRoute()
|
||||
id ??= Number(route.params.id)
|
||||
id ??= route.params.id.toString()
|
||||
if (id) {
|
||||
if (!USERS.value[id]) {
|
||||
const result = await GetInfo(id)
|
||||
@@ -23,16 +23,18 @@ export async function useUser(id: number | undefined = undefined) {
|
||||
}
|
||||
}
|
||||
export async function useUserWithUId(id: number) {
|
||||
if (!USERS.value[id]) {
|
||||
const result = await GetInfo(id)
|
||||
if (!USERS.value[id.toString()]) {
|
||||
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
uId: id,
|
||||
})
|
||||
if (result.code == 200) {
|
||||
USERS.value[id] = result.data
|
||||
USERS.value[id.toString()] = result.data
|
||||
}
|
||||
}
|
||||
return USERS.value[id]
|
||||
return USERS.value[id.toString()]
|
||||
}
|
||||
|
||||
export async function GetInfo(id: number): Promise<APIRoot<UserInfo>> {
|
||||
export async function GetInfo(id: string): Promise<APIRoot<UserInfo>> {
|
||||
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
id: id,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user