mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
add web-fetcher
This commit is contained in:
@@ -7,7 +7,7 @@ import { ref } from 'vue'
|
||||
import { APIRoot, AccountInfo, FunctionTypes } from './api-models'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
export const ACCOUNT = ref<AccountInfo>()
|
||||
export const ACCOUNT = ref<AccountInfo>({} as AccountInfo)
|
||||
export const isLoadingAccount = ref(true)
|
||||
const route = useRoute()
|
||||
|
||||
|
||||
@@ -30,6 +30,20 @@ export interface UserInfo {
|
||||
streamerInfo?: StreamerModel
|
||||
}
|
||||
}
|
||||
export interface EventFetcherStateModel {
|
||||
online: boolean
|
||||
status: { [errorCode: string]: string }
|
||||
version?: string
|
||||
todayReceive: number
|
||||
useCookie: boolean
|
||||
type: EventFetcherType
|
||||
}
|
||||
|
||||
export enum EventFetcherType {
|
||||
Application,
|
||||
OBS,
|
||||
Server,
|
||||
}
|
||||
export interface AccountInfo extends UserInfo {
|
||||
isEmailVerified: boolean
|
||||
isBiliVerified: boolean
|
||||
@@ -41,11 +55,7 @@ export interface AccountInfo extends UserInfo {
|
||||
biliAuthCode?: string
|
||||
biliAuthCodeStatus: BiliAuthCodeStatusType
|
||||
|
||||
eventFetcherOnline: boolean
|
||||
eventFetcherStatus: string
|
||||
eventFetcherStatusV3: { [errorCode: string]: string }
|
||||
eventFetcherTodayReceive: number
|
||||
eventFetcherVersion?: string
|
||||
eventFetcherState: EventFetcherStateModel
|
||||
|
||||
nextSendEmailTime?: number
|
||||
isServerFetcherOnline: boolean
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function QueryPostAPIWithParams<T>(
|
||||
const url = new URL(urlString)
|
||||
url.search = getParams(params)
|
||||
headers ??= []
|
||||
headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
|
||||
if (contentType) headers?.push(['Content-Type', contentType])
|
||||
|
||||
@@ -55,7 +55,7 @@ export async function QueryGetAPI<T>(
|
||||
url.search = getParams(params)
|
||||
if (cookie.value) {
|
||||
headers ??= []
|
||||
headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
}
|
||||
try {
|
||||
const data = await fetch(url.toString(), {
|
||||
@@ -81,6 +81,9 @@ function getParams(params?: [string, string][]) {
|
||||
if (urlParams.has('as')) {
|
||||
resultParams.set('as', urlParams.get('as') || '')
|
||||
}
|
||||
if (urlParams.has('token')) {
|
||||
resultParams.set('token', urlParams.get('token') || '')
|
||||
}
|
||||
return resultParams.toString()
|
||||
}
|
||||
export async function QueryPostPaginationAPI<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> {
|
||||
|
||||
Reference in New Issue
Block a user