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:
@@ -85,6 +85,7 @@ export default antfu(
|
|||||||
'ts/restrict-template-expressions': 'off', // 允许模板字符串表达式不受限制
|
'ts/restrict-template-expressions': 'off', // 允许模板字符串表达式不受限制
|
||||||
|
|
||||||
'perfectionist/sort-imports': 'off',
|
'perfectionist/sort-imports': 'off',
|
||||||
|
'ts/no-unsafe-argument': 'off', // 允许不安全的参数传递
|
||||||
|
|
||||||
// JSON 相关规则
|
// JSON 相关规则
|
||||||
'jsonc/sort-keys': 'off', // 关闭 JSON key 排序要求
|
'jsonc/sort-keys': 'off', // 关闭 JSON key 排序要求
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { APIRoot, PaginationResponse } from './api-models'
|
import type { APIRoot, PaginationResponse } from './api-models'
|
||||||
import { apiFail } from '@/data/constants'
|
import { apiFail } from '@/data/constants'
|
||||||
import { cookie } from './account'
|
import { cookie } from './account'
|
||||||
|
import { useBiliAuth } from '@/store/useBiliAuth';
|
||||||
|
|
||||||
export async function QueryPostAPI<T>(
|
export async function QueryPostAPI<T>(
|
||||||
urlString: string,
|
urlString: string,
|
||||||
@@ -57,6 +58,10 @@ async function QueryPostAPIWithParamsInternal<T>(
|
|||||||
h[header[0]] = header[1]
|
h[header[0]] = header[1]
|
||||||
})
|
})
|
||||||
if (cookie.value.cookie) h.Authorization = `Bearer ${cookie.value.cookie}`
|
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
|
// 当使用FormData时,不手动设置Content-Type,让浏览器自动添加boundary
|
||||||
if (!(body instanceof FormData)) {
|
if (!(body instanceof FormData)) {
|
||||||
@@ -117,6 +122,10 @@ async function QueryGetAPIInternal<T>(
|
|||||||
if (cookie.value.cookie) {
|
if (cookie.value.cookie) {
|
||||||
h.Authorization = `Bearer ${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 })
|
return await QueryAPIInternal<T>(url, { method: 'get', headers: h })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`url:${urlString}, error:${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']
|
LiveInfoContainer: typeof import('./components/LiveInfoContainer.vue')['default']
|
||||||
MonacoEditorComponent: typeof import('./components/MonacoEditorComponent.vue')['default']
|
MonacoEditorComponent: typeof import('./components/MonacoEditorComponent.vue')['default']
|
||||||
NAlert: typeof import('naive-ui')['NAlert']
|
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']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||||
NFlex: typeof import('naive-ui')['NFlex']
|
NFlex: typeof import('naive-ui')['NFlex']
|
||||||
NFormItemGi: typeof import('naive-ui')['NFormItemGi']
|
NFormItemGi: typeof import('naive-ui')['NFormItemGi']
|
||||||
NGridItem: typeof import('naive-ui')['NGridItem']
|
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']
|
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||||
NSpace: typeof import('naive-ui')['NSpace']
|
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
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']
|
PointGoodsItem: typeof import('./components/manage/PointGoodsItem.vue')['default']
|
||||||
PointHistoryCard: typeof import('./components/manage/PointHistoryCard.vue')['default']
|
PointHistoryCard: typeof import('./components/manage/PointHistoryCard.vue')['default']
|
||||||
PointOrderCard: typeof import('./components/manage/PointOrderCard.vue')['default']
|
PointOrderCard: typeof import('./components/manage/PointOrderCard.vue')['default']
|
||||||
|
|||||||
@@ -116,6 +116,19 @@ const router = createRouter({
|
|||||||
})
|
})
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
useLoadingBarStore().loadingBar?.start()
|
useLoadingBarStore().loadingBar?.start()
|
||||||
|
|
||||||
|
// 保留 as 参数(如果存在)
|
||||||
|
if (from.query.as && !to.query.as) {
|
||||||
|
next({
|
||||||
|
...to,
|
||||||
|
query: {
|
||||||
|
...to.query,
|
||||||
|
as: from.query.as,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export const useBiliAuth = defineStore('BiliAuth', () => {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const resp = await QueryGetAPI<ResponsePointGoodModel[]>(`${POINT_API_URL}get-goods`, {
|
const resp = await QueryBiliAuthGetAPI<ResponsePointGoodModel[]>(`${POINT_API_URL}get-goods`, {
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
if (resp.code == 200) {
|
if (resp.code == 200) {
|
||||||
|
|||||||
@@ -1027,7 +1027,7 @@ onMounted(() => { })
|
|||||||
</NTooltip>
|
</NTooltip>
|
||||||
</NText>
|
</NText>
|
||||||
|
|
||||||
<NRadioGroup
|
<NRadioGroup
|
||||||
:value="currentGoodsModel.goods.setting?.allowGuardLevel ?? 0"
|
:value="currentGoodsModel.goods.setting?.allowGuardLevel ?? 0"
|
||||||
@update:value="(v) => {
|
@update:value="(v) => {
|
||||||
if (!currentGoodsModel.goods.setting) {
|
if (!currentGoodsModel.goods.setting) {
|
||||||
|
|||||||
Reference in New Issue
Block a user