From c9ec427692b6d33270e444541f2a075d9fbcec35 Mon Sep 17 00:00:00 2001 From: Megghy Date: Fri, 10 Oct 2025 13:25:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20ESLint=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BB=A5=E6=94=BE=E5=AE=BD=E4=B8=8D=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92=E7=9A=84=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=9B=E5=9C=A8=20API=20=E6=9F=A5=E8=AF=A2=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20Bili-Auth=20=E6=94=AF=E6=8C=81=EF=BC=9B=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=B7=AF=E7=94=B1=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.mjs | 1 + src/api/query.ts | 9 +++++++++ src/components.d.ts | 10 ---------- src/router/index.ts | 13 +++++++++++++ src/store/useBiliAuth.ts | 2 +- src/views/manage/point/PointManage.vue | 2 +- 6 files changed, 25 insertions(+), 12 deletions(-) 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(() => { }) -