diff --git a/package.json b/package.json index 8d3ee9b..310e146 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "prepare": "husky" }, "dependencies": { + "@microsoft/signalr": "^8.0.0", + "@microsoft/signalr-protocol-msgpack": "^8.0.0", "@types/node": "^20.11.19", "@typescript-eslint/eslint-plugin": "^7.0.1", "@vicons/fluent": "^0.12.0", diff --git a/src/api/account.ts b/src/api/account.ts index 66a5e36..8ab864f 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -7,7 +7,7 @@ import { ref } from 'vue' import { APIRoot, AccountInfo, FunctionTypes } from './api-models' import { useRoute } from 'vue-router' -export const ACCOUNT = ref() +export const ACCOUNT = ref({} as AccountInfo) export const isLoadingAccount = ref(true) const route = useRoute() diff --git a/src/api/api-models.ts b/src/api/api-models.ts index 8a70cf2..fce7147 100644 --- a/src/api/api-models.ts +++ b/src/api/api-models.ts @@ -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 diff --git a/src/api/query.ts b/src/api/query.ts index a4970c5..977cbc0 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -23,7 +23,7 @@ export async function QueryPostAPIWithParams( 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( 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(url: string, body?: unknown): Promise>> { diff --git a/src/components/EventFetcherStatusCard.vue b/src/components/EventFetcherStatusCard.vue index 15aafeb..4214173 100644 --- a/src/components/EventFetcherStatusCard.vue +++ b/src/components/EventFetcherStatusCard.vue @@ -1,17 +1,18 @@