mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
1011
This commit is contained in:
@@ -17,13 +17,13 @@ export async function GetSelfAccount() {
|
||||
ACCOUNT.value = result.data
|
||||
console.log('[vtsuru] 已获取账户信息')
|
||||
return result.data
|
||||
} else if (result.code == 403) {
|
||||
cookie.value = ''
|
||||
} else if (result.code == 401) {
|
||||
localStorage.removeItem('JWT_Token')
|
||||
console.warn('[vtsuru] Cookie 已失效, 需要重新登陆')
|
||||
message.error('Cookie 已失效, 需要重新登陆')
|
||||
}
|
||||
else {
|
||||
console.warn('[vtsuru] '+ result.message)
|
||||
location.reload()
|
||||
} else {
|
||||
console.warn('[vtsuru] ' + result.message)
|
||||
message.error(result.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,3 +95,19 @@ export interface QAInfo {
|
||||
isFavorite:boolean
|
||||
sendAt: number
|
||||
}
|
||||
export interface LotteryUserInfo {
|
||||
name: string
|
||||
uId: number
|
||||
level?: number
|
||||
avatar: string
|
||||
location?: string
|
||||
isVIP?: boolean
|
||||
card?: LotteryUserCardInfo
|
||||
}
|
||||
export interface LotteryUserCardInfo {
|
||||
name: string
|
||||
level: number
|
||||
guardLevel: number
|
||||
isGuard: boolean
|
||||
isCharge: boolean
|
||||
}
|
||||
|
||||
@@ -16,6 +16,20 @@ export async function QueryPostAPI<T>(url: string, body?: unknown, headers?: [st
|
||||
}) // 不处理异常, 在页面处理
|
||||
return (await data.json()) as APIRoot<T>
|
||||
}
|
||||
export async function QueryPostAPIWithParams<T>(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise<APIRoot<T>> {
|
||||
const url = new URL(urlString)
|
||||
url.search = new URLSearchParams(params).toString()
|
||||
headers ??= []
|
||||
headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
if (contentType) headers?.push(['Content-Type', contentType])
|
||||
|
||||
const data = await fetch(url, {
|
||||
method: 'post',
|
||||
headers: headers,
|
||||
body: body,
|
||||
}) // 不处理异常, 在页面处理
|
||||
return (await data.json()) as APIRoot<T>
|
||||
}
|
||||
export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> {
|
||||
const url = new URL(urlString)
|
||||
url.search = new URLSearchParams(params).toString()
|
||||
|
||||
Reference in New Issue
Block a user