diff --git a/eslint.config.mjs b/eslint.config.mjs index 591e0e7..7447ca9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -85,6 +85,7 @@ export default antfu( 'ts/restrict-template-expressions': 'off', // 允许模板字符串表达式不受限制 'perfectionist/sort-imports': 'off', + 'ts/no-unsafe-argument': 'off', // 允许不安全的参数传递 // JSON 相关规则 'jsonc/sort-keys': 'off', // 关闭 JSON key 排序要求 diff --git a/src/api/query.ts b/src/api/query.ts index e8daed4..7b14166 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -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( urlString: string, @@ -57,6 +58,10 @@ async function QueryPostAPIWithParamsInternal( 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( if (cookie.value.cookie) { h.Authorization = `Bearer ${cookie.value.cookie}` } + const biliAuth = useBiliAuth(); + if (biliAuth.currentToken) { + h['Bili-Auth'] = biliAuth.currentToken; + } return await QueryAPIInternal(url, { method: 'get', headers: h }) } catch (err) { console.log(`url:${urlString}, error:${err}`) diff --git a/src/components.d.ts b/src/components.d.ts index c97f3f1..258d478 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -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'] diff --git a/src/router/index.ts b/src/router/index.ts index cb555a1..2d6cbe8 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -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(() => { diff --git a/src/store/useBiliAuth.ts b/src/store/useBiliAuth.ts index 87468b1..dafc6f5 100644 --- a/src/store/useBiliAuth.ts +++ b/src/store/useBiliAuth.ts @@ -110,7 +110,7 @@ export const useBiliAuth = defineStore('BiliAuth', () => { return [] } try { - const resp = await QueryGetAPI(`${POINT_API_URL}get-goods`, { + const resp = await QueryBiliAuthGetAPI(`${POINT_API_URL}get-goods`, { id, }) if (resp.code == 200) { diff --git a/src/views/manage/point/PointManage.vue b/src/views/manage/point/PointManage.vue index 7bab1d9..ba750b8 100644 --- a/src/views/manage/point/PointManage.vue +++ b/src/views/manage/point/PointManage.vue @@ -1027,7 +1027,7 @@ onMounted(() => { }) -