diff --git a/.github/workflows/bun.yml b/.github/workflows/bun.yml index 95f4b3f..0e967a3 100644 --- a/.github/workflows/bun.yml +++ b/.github/workflows/bun.yml @@ -22,3 +22,5 @@ jobs: run: bun install - name: 📦 Build run: bun run build + - name: 📦 Upload SourceMap + run: bunx @hyperdx/cli upload-sourcemaps --path dist\assets diff --git a/bun.lockb b/bun.lockb index 01deef1..8dab163 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 5f04f7b..a88a298 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@hyperdx/browser": "^0.21.2", + "@hyperdx/cli": "^0.1.0", "@microsoft/signalr": "^8.0.7", "@microsoft/signalr-protocol-msgpack": "^8.0.7", "@mixer/postmessage-rpc": "^1.1.4", diff --git a/src/api/query.ts b/src/api/query.ts index 00112a7..5a4ee3d 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -25,6 +25,7 @@ export async function QueryPostAPIWithParams( contentType?: string, headers?: [string, string][] ): Promise> { + // @ts-expect-error 忽略 return await QueryPostAPIWithParamsInternal>( urlString, params, @@ -40,15 +41,23 @@ async function QueryPostAPIWithParamsInternal( contentType: string = 'application/json', headers: [string, string][] = [] ) { - const url = new URL(urlString) + let url: URL + try { + url = new URL(urlString) + } catch (e) { + console.error('尝试解析API地址失败: ' + urlString, e) + return { + code: 400, + message: '无效的API地址: ' + urlString, + data: {} as T + } + } url.search = getParams(params) headers ??= [] - let h = {} as { - [key: string]: string - } - headers.forEach(header => { + let h = {} as { [key: string]: string } + headers.forEach((header) => { h[header[0]] = header[1] - }); + }) if (cookie.value) h['Authorization'] = `Bearer ${cookie.value}` h['Content-Type'] = contentType @@ -77,6 +86,7 @@ export async function QueryGetAPI( params?: any, headers?: [string, string][] ): Promise> { + // @ts-expect-error 忽略 return await QueryGetAPIInternal>(urlString, params, headers) } async function QueryGetAPIInternal( @@ -85,22 +95,27 @@ async function QueryGetAPIInternal( headers?: [string, string][] ) { try { - const url = new URL(urlString) + let url: URL + try { + url = new URL(urlString) + } catch (e) { + console.error('尝试解析API地址失败: ' + urlString, e) + return { + code: 400, + message: '无效的API地址: ' + urlString, + data: {} as T + } + } url.search = getParams(params) headers ??= [] - let h = {} as { - [key: string]: string - } + let h = {} as { [key: string]: string } headers.forEach((header) => { h[header[0]] = header[1] }) if (cookie.value) { h['Authorization'] = `Bearer ${cookie.value}` } - return await QueryAPIInternal(url, { - method: 'get', - headers: h - }) + return await QueryAPIInternal(url, { method: 'get', headers: h }) } catch (err) { console.log(`url:${urlString}, error:${err}`) throw err @@ -133,6 +148,7 @@ export async function QueryPostPaginationAPI( url: string, body?: unknown ): Promise> { + // @ts-expect-error 忽略 return await QueryPostAPIWithParamsInternal>( url, undefined, @@ -143,6 +159,7 @@ export async function QueryGetPaginationAPI( urlString: string, params?: unknown ): Promise> { + // @ts-expect-error 忽略 return await QueryGetAPIInternal>(urlString, params) } export function GetHeaders(): [string, string][] { diff --git a/src/views/obs/DanmujiOBS.vue b/src/views/obs/DanmujiOBS.vue index 32f6f2f..bf720d7 100644 --- a/src/views/obs/DanmujiOBS.vue +++ b/src/views/obs/DanmujiOBS.vue @@ -47,8 +47,8 @@ defineExpose({ setCss }) const { customCss, isOBS = true } = defineProps<{ customCss?: string isOBS?: boolean, - active: boolean, - visible: boolean, + active?: boolean, + visible?: boolean, }>() const messageRender = ref() diff --git a/src/views/obs/LiveRequestOBS.vue b/src/views/obs/LiveRequestOBS.vue index 9b4a899..e4131f5 100644 --- a/src/views/obs/LiveRequestOBS.vue +++ b/src/views/obs/LiveRequestOBS.vue @@ -88,8 +88,13 @@ async function get() { if (data.code == 200) { return data.data } - } catch (err) {} - return {} as { songs: SongRequestInfo[]; setting: Setting_LiveRequest } + } catch (err) { + console.log(err) + } + return { + songs: [], + setting: {} as Setting_LiveRequest, + } as { songs: SongRequestInfo[]; setting: Setting_LiveRequest } } const allowGuardTypes = computed(() => { const types = [] @@ -148,19 +153,12 @@ onUnmounted(() => {

已有 {{ activeSongs.length ?? 0 }} 条

-
+
@@ -169,22 +167,10 @@ onUnmounted(() => {