mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36: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}`)
|
||||
|
||||
10
src/components.d.ts
vendored
10
src/components.d.ts
vendored
@@ -19,23 +19,13 @@ declare module 'vue' {
|
||||
LiveInfoContainer: typeof import('./components/LiveInfoContainer.vue')['default']
|
||||
MonacoEditorComponent: typeof import('./components/MonacoEditorComponent.vue')['default']
|
||||
NAlert: typeof import('naive-ui')['NAlert']
|
||||
NAvatar: typeof import('naive-ui')['NAvatar']
|
||||
NButton: typeof import('naive-ui')['NButton']
|
||||
NCard: typeof import('naive-ui')['NCard']
|
||||
NDataTable: typeof import('naive-ui')['NDataTable']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
NFlex: typeof import('naive-ui')['NFlex']
|
||||
NFormItemGi: typeof import('naive-ui')['NFormItemGi']
|
||||
NGridItem: typeof import('naive-ui')['NGridItem']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NImage: typeof import('naive-ui')['NImage']
|
||||
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTag: typeof import('naive-ui')['NTag']
|
||||
NText: typeof import('naive-ui')['NText']
|
||||
NTime: typeof import('naive-ui')['NTime']
|
||||
PointGoodsItem: typeof import('./components/manage/PointGoodsItem.vue')['default']
|
||||
PointHistoryCard: typeof import('./components/manage/PointHistoryCard.vue')['default']
|
||||
PointOrderCard: typeof import('./components/manage/PointOrderCard.vue')['default']
|
||||
|
||||
@@ -116,6 +116,19 @@ const router = createRouter({
|
||||
})
|
||||
router.beforeEach((to, from, next) => {
|
||||
useLoadingBarStore().loadingBar?.start()
|
||||
|
||||
// 保留 as 参数(如果存在)
|
||||
if (from.query.as && !to.query.as) {
|
||||
next({
|
||||
...to,
|
||||
query: {
|
||||
...to.query,
|
||||
as: from.query.as,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
router.afterEach(() => {
|
||||
|
||||
@@ -110,7 +110,7 @@ export const useBiliAuth = defineStore('BiliAuth', () => {
|
||||
return []
|
||||
}
|
||||
try {
|
||||
const resp = await QueryGetAPI<ResponsePointGoodModel[]>(`${POINT_API_URL}get-goods`, {
|
||||
const resp = await QueryBiliAuthGetAPI<ResponsePointGoodModel[]>(`${POINT_API_URL}get-goods`, {
|
||||
id,
|
||||
})
|
||||
if (resp.code == 200) {
|
||||
|
||||
@@ -1027,7 +1027,7 @@ onMounted(() => { })
|
||||
</NTooltip>
|
||||
</NText>
|
||||
|
||||
<NRadioGroup
|
||||
<NRadioGroup
|
||||
:value="currentGoodsModel.goods.setting?.allowGuardLevel ?? 0"
|
||||
@update:value="(v) => {
|
||||
if (!currentGoodsModel.goods.setting) {
|
||||
|
||||
Reference in New Issue
Block a user