mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
feat: 更新 ESLint 配置以放宽不安全参数传递的限制;在 API 查询中添加 Bili-Auth 支持;优化路由参数传递逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { APIRoot, PaginationResponse } from './api-models'
|
||||
import { apiFail } from '@/data/constants'
|
||||
import { cookie } from './account'
|
||||
import { useBiliAuth } from '@/store/useBiliAuth';
|
||||
|
||||
export async function QueryPostAPI<T>(
|
||||
urlString: string,
|
||||
@@ -57,6 +58,10 @@ async function QueryPostAPIWithParamsInternal<T>(
|
||||
h[header[0]] = header[1]
|
||||
})
|
||||
if (cookie.value.cookie) h.Authorization = `Bearer ${cookie.value.cookie}`
|
||||
const biliAuth = useBiliAuth();
|
||||
if (biliAuth.currentToken) {
|
||||
h['Bili-Auth'] = biliAuth.currentToken;
|
||||
}
|
||||
|
||||
// 当使用FormData时,不手动设置Content-Type,让浏览器自动添加boundary
|
||||
if (!(body instanceof FormData)) {
|
||||
@@ -117,6 +122,10 @@ async function QueryGetAPIInternal<T>(
|
||||
if (cookie.value.cookie) {
|
||||
h.Authorization = `Bearer ${cookie.value.cookie}`
|
||||
}
|
||||
const biliAuth = useBiliAuth();
|
||||
if (biliAuth.currentToken) {
|
||||
h['Bili-Auth'] = biliAuth.currentToken;
|
||||
}
|
||||
return await QueryAPIInternal<T>(url, { method: 'get', headers: h })
|
||||
} catch (err) {
|
||||
console.log(`url:${urlString}, error:${err}`)
|
||||
|
||||
Reference in New Issue
Block a user