From 8e2fdb10f5e82487f24aa1c9b19b4c52ce98ea9d Mon Sep 17 00:00:00 2001 From: Megghy Date: Sat, 29 Nov 2025 19:05:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20Cookie=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=AD=96=E7=95=A5=E5=B9=B6=E5=A2=9E=E5=BC=BA=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E7=A0=81=E7=8A=B6=E6=80=81=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 CookieCloud 同步间隔从 30 分钟缩短至 10 分钟,提高同步频率 - 在 BiliCookie store 初始化时立即执行一次检查,强制尝试从 CookieCloud 同步 - 新增弹幕客户端启动失败时的错误通知提示 - 在管理页面加载时检测身份码失效状态并显示错误提示 - 优化邮箱验证状态检查时机,延迟 500ms 执行避免初始化冲突 - 自动注册 NTable 组件到全 --- src/client/store/useBiliCookie.ts | 5 +- src/components.d.ts | 2 + src/store/useWebFetcher.ts | 8 + src/views/ManageLayout.vue | 543 ++++---- src/views/manage/AnalyzeView.vue | 1204 ++++++----------- .../views/manage/AnalyzeView_new.vue | 0 src/views/manage/DashboardView.vue | 13 + src/views/manage/EventView.vue | 868 ++++++++---- src/views/manage/HistoryView.vue | 162 +-- src/views/manage/point/PointManage.vue | 2 +- target/rust-analyzer/flycheck0/stderr | 1 - target/rust-analyzer/flycheck0/stdout | 600 -------- 12 files changed, 1282 insertions(+), 2126 deletions(-) rename tmp/danmaku_test.ts => src/views/manage/AnalyzeView_new.vue (100%) delete mode 100644 target/rust-analyzer/flycheck0/stderr delete mode 100644 target/rust-analyzer/flycheck0/stdout diff --git a/src/client/store/useBiliCookie.ts b/src/client/store/useBiliCookie.ts index 280fee7..08c0c27 100644 --- a/src/client/store/useBiliCookie.ts +++ b/src/client/store/useBiliCookie.ts @@ -15,7 +15,7 @@ export const USER_INFO_CACHE_KEY = 'cache.bilibili.userInfo' // 检查周期 (毫秒) const REGULAR_CHECK_INTERVAL = 60 * 1000 // 每分钟检查一次 Cookie 有效性 -const CLOUD_SYNC_INTERVAL_CHECKS = 30 // 每 30 次常规检查后 (约 30 分钟) 同步一次 CookieCloud +const CLOUD_SYNC_INTERVAL_CHECKS = 10 // 每 10 次常规检查后 (约 10 分钟) 同步一次 CookieCloud // 用户信息缓存有效期 (毫秒) const USER_INFO_CACHE_DURATION = 5 * 60 * 1000 // 缓存 5 分钟 @@ -381,6 +381,9 @@ export const useBiliCookie = defineStore('biliCookie', () => { _checkIntervalId = setInterval(check, REGULAR_CHECK_INTERVAL) info(`[BiliCookie] 定时检查已启动,周期: ${REGULAR_CHECK_INTERVAL / 1000} 秒`) + // 立即执行一次检查,强制尝试从 CookieCloud 同步 + await check(true) + info('[BiliCookie] Store 初始化完成') } diff --git a/src/components.d.ts b/src/components.d.ts index 65231c9..6157140 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -49,6 +49,7 @@ declare module 'vue' { NSpin: typeof import('naive-ui')['NSpin'] NStatistic: typeof import('naive-ui')['NStatistic'] NSwitch: typeof import('naive-ui')['NSwitch'] + NTable: typeof import('naive-ui')['NTable'] NTag: typeof import('naive-ui')['NTag'] NText: typeof import('naive-ui')['NText'] NTime: typeof import('naive-ui')['NTime'] @@ -117,6 +118,7 @@ declare global { const NSpin: typeof import('naive-ui')['NSpin'] const NStatistic: typeof import('naive-ui')['NStatistic'] const NSwitch: typeof import('naive-ui')['NSwitch'] + const NTable: typeof import('naive-ui')['NTable'] const NTag: typeof import('naive-ui')['NTag'] const NText: typeof import('naive-ui')['NText'] const NTime: typeof import('naive-ui')['NTime'] diff --git a/src/store/useWebFetcher.ts b/src/store/useWebFetcher.ts index b3fd6ba..784cc79 100644 --- a/src/store/useWebFetcher.ts +++ b/src/store/useWebFetcher.ts @@ -95,6 +95,14 @@ export const useWebFetcher = defineStore('WebFetcher', () => { } let danmakuResult = await connectDanmakuClient(type, directAuthInfo) + if (!danmakuResult?.success) { + window.$notification?.create({ + title: '弹幕客户端启动失败', + content: danmakuResult?.message || '无法连接到弹幕服务器', + type: 'error', + duration: 5000, + }) + } while (!danmakuResult?.success) { console.log(`${prefix.value}弹幕客户端启动失败, 5秒后重试`) await new Promise(resolve => setTimeout(resolve, 5000)) diff --git a/src/views/ManageLayout.vue b/src/views/ManageLayout.vue index df72a08..c997ab2 100644 --- a/src/views/ManageLayout.vue +++ b/src/views/ManageLayout.vue @@ -50,7 +50,7 @@ import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue' import APlayer from 'vue3-aplayer' import { RouterLink, useRoute } from 'vue-router' import { cookie, isLoadingAccount, useAccount } from '@/api/account' -import { ThemeType } from '@/api/api-models' +import { BiliAuthCodeStatusType, ThemeType } from '@/api/api-models' import { QueryGetAPI } from '@/api/query' import RegisterAndLogin from '@/components/RegisterAndLogin.vue' import { ACCOUNT_API_URL, availableAPIs, selectedAPIKey } from '@/data/constants' @@ -315,13 +315,13 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '弹幕机' : h(NTooltip, {}, { - trigger: () => h( - RouterLink, - { to: { name: 'manage-danmuji' } }, - { default: () => '弹幕机' }, - ), - default: () => '兼容 blivechat 样式 (其实就是直接用的 blivechat 组件', - }), + trigger: () => h( + RouterLink, + { to: { name: 'manage-danmuji' } }, + { default: () => '弹幕机' }, + ), + default: () => '兼容 blivechat 样式 (其实就是直接用的 blivechat 组件', + }), key: 'manage-danmuji', disabled: !isBiliVerified.value, icon: renderIcon(Lottery24Filled), @@ -331,17 +331,17 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '点播' : h( - NTooltip, - {}, - { - trigger: () => h( - RouterLink, - { to: { name: 'manage-liveRequest' } }, - { default: () => '点播' }, - ), - default: () => '歌势之类用的, 可以用来点歌或者跳舞什么的', - }, - ), + NTooltip, + {}, + { + trigger: () => h( + RouterLink, + { to: { name: 'manage-liveRequest' } }, + { default: () => '点播' }, + ), + default: () => '歌势之类用的, 可以用来点歌或者跳舞什么的', + }, + ), key: 'manage-liveRequest', icon: renderIcon(MusicalNote), disabled: !isBiliVerified.value, @@ -351,10 +351,10 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '抽奖' : h( - RouterLink, - { to: { name: 'manage-liveLottery' } }, - { default: () => '抽奖' }, - ), + RouterLink, + { to: { name: 'manage-liveLottery' } }, + { default: () => '抽奖' }, + ), key: 'manage-liveLottery', icon: renderIcon(Lottery24Filled), disabled: !isBiliVerified.value, @@ -364,17 +364,17 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '点歌' : h( - NTooltip, - {}, - { - trigger: () => h( - RouterLink, - { to: { name: 'manage-musicRequest' } }, - { default: () => '点歌机' }, - ), - default: () => '就是传统的点歌机, 发弹幕后播放指定的歌曲', - }, - ), + NTooltip, + {}, + { + trigger: () => h( + RouterLink, + { to: { name: 'manage-musicRequest' } }, + { default: () => '点歌机' }, + ), + default: () => '就是传统的点歌机, 发弹幕后播放指定的歌曲', + }, + ), key: 'manage-musicRequest', icon: renderIcon(MusicalNote), disabled: !isBiliVerified.value, @@ -384,10 +384,10 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '排队' : h( - RouterLink, - { to: { name: 'manage-liveQueue' } }, - { default: () => '排队' }, - ), + RouterLink, + { to: { name: 'manage-liveQueue' } }, + { default: () => '排队' }, + ), key: 'manage-liveQueue', icon: renderIcon(PeopleQueue24Filled), disabled: !isBiliVerified.value, @@ -397,10 +397,10 @@ const menuOptions = computed(() => { label: () => !isBiliVerified.value ? '读弹幕' : h( - RouterLink, - { to: { name: 'manage-speech' } }, - { default: () => '读弹幕' }, - ), + RouterLink, + { to: { name: 'manage-speech' } }, + { default: () => '读弹幕' }, + ), key: 'manage-speech', icon: renderIcon(TabletSpeaker24Filled), disabled: !isBiliVerified.value, @@ -649,16 +649,21 @@ function gotoAuthPage() { } onMounted(() => { - // 检查邮箱验证状态 - if (accountInfo.value?.isEmailVerified === false) { - if ((accountInfo.value?.nextSendEmailTime ?? -1) <= 0) { - canResendEmail.value = true - } - } if (selectedAPIKey.value != 'main') { message.warning('你当前使用的是备用API节点, 可能会速度比较慢') } + setTimeout(() => { + // 检查邮箱验证状态 + if (accountInfo.value?.isEmailVerified === false) { + if ((accountInfo.value?.nextSendEmailTime ?? -1) <= 0) { + canResendEmail.value = true + } + } + if (accountInfo.value?.biliAuthCodeStatus == BiliAuthCodeStatusType.Inactive) { + message.error('你的身份码已失效, 请及时更新', { duration: 5000, closable: true }) + } + }, 500); }) onUnmounted(() => { @@ -682,10 +687,8 @@ onUnmounted(() => { - + 回到展示页 @@ -707,11 +708,9 @@ onUnmounted(() => { - + :scrollbar-props="{ trigger: 'none', style: {} }" :class="{ 'sider-collapsed': width < 150 }"> @@ -746,14 +745,12 @@ onUnmounted(() => { - + :options="menuOptions" /> @@ -772,8 +769,7 @@ onUnmounted(() => { + :style="`font-size: 12px; text-align: center;color: ${isDarkMode ? '#555' : '#c0c0c0'};visibility: ${width < 180 ? 'hidden' : 'visible'}`"> By Megghy @@ -782,10 +778,10 @@ onUnmounted(() => { - + + content-style="margin: var(--vtsuru-content-padding); margin-right: calc(var(--vtsuru-content-padding) + 4px); padding-bottom: 32px;min-width: 370px"> @@ -840,10 +836,8 @@ onUnmounted(() => { - +