mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update url
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { QueryGetAPI } from '@/api/query'
|
||||
import { BASE_API, USER_API_URL } from '@/data/constants'
|
||||
import { BASE_API, USER_API_URL, apiFail } from '@/data/constants'
|
||||
import { APIRoot, UserInfo } from './api-models'
|
||||
import { ref } from 'vue'
|
||||
import { useRouteParams } from '@vueuse/router'
|
||||
@@ -12,7 +12,13 @@ export async function useUser(id: string | undefined = undefined) {
|
||||
id ??= route.params.id.toString()
|
||||
if (id) {
|
||||
if (!USERS.value[id]) {
|
||||
const result = await GetInfo(id)
|
||||
let result: APIRoot<UserInfo>
|
||||
try {
|
||||
result = await GetInfo(id)
|
||||
} catch {
|
||||
apiFail.value = true
|
||||
result = await GetInfo(id)
|
||||
}
|
||||
if (result.code == 200) {
|
||||
USERS.value[id] = result.data
|
||||
}
|
||||
@@ -24,7 +30,7 @@ export async function useUser(id: string | undefined = undefined) {
|
||||
}
|
||||
export async function useUserWithUId(id: number) {
|
||||
if (!USERS.value[id.toString()]) {
|
||||
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL()}info`, {
|
||||
uId: id,
|
||||
})
|
||||
if (result.code == 200) {
|
||||
@@ -35,7 +41,7 @@ export async function useUserWithUId(id: number) {
|
||||
}
|
||||
|
||||
export async function GetInfo(id: string): Promise<APIRoot<UserInfo>> {
|
||||
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
return QueryGetAPI<UserInfo>(`${USER_API_URL()}info`, {
|
||||
id: id,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user