This commit is contained in:
2023-10-11 23:23:07 +08:00
parent e93cccd054
commit 02c2309255
16 changed files with 522 additions and 205 deletions

View File

@@ -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)
}
}

View File

@@ -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
}

View File

@@ -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()