diff --git a/src/App.vue b/src/App.vue index 87f94f9a..8c71ffa1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -68,9 +68,7 @@ const activeImageIndex = ref(0) const previousImageIndex = ref(null) const isTransparentTheme = computed(() => globalTheme.name.value === 'transparent') const isLoginWallpaperRoute = computed(() => !isLogin.value && route.path === LOGIN_WALLPAPER_ROUTE) -const shouldUseTransparentBackgroundTreatment = computed( - () => (Boolean(isLogin.value) && isTransparentTheme.value) || isLoginWallpaperRoute.value, -) +const shouldUseTransparentBackgroundTreatment = computed(() => Boolean(isLogin.value) && isTransparentTheme.value) const shouldLoadBackgroundImages = computed( () => isLoginWallpaperRoute.value || (Boolean(isLogin.value) && isTransparentTheme.value), ) @@ -89,6 +87,7 @@ let backgroundRequestController: AbortController | null = null let backgroundCrossfadeTimer: number | null = null let authenticatedStateTimer: number | null = null +// 读取并同步透明主题背景设置到根组件响应式状态。 function applyTransparentBackgroundSettings() { const settings = applyStoredTransparencySettings() @@ -96,6 +95,7 @@ function applyTransparentBackgroundSettings() { transparencyGlassQuality.value = settings.glassQuality } +// 响应透明主题设置变更事件,刷新背景模糊和玻璃质量。 function handleTransparencySettingsChanged(event: Event) { const { backgroundBlur, glassQuality } = (event as CustomEvent).detail @@ -143,6 +143,7 @@ function updateHtmlThemeAttribute(themeName: string) { syncRootLaunchPalette() } +// 从本地存储重新同步主题偏好、DOM 主题属性和相关外观配置。 function syncThemePreferenceFromStorage() { themeValue = localStorage.getItem('theme') || 'auto' @@ -166,22 +167,26 @@ function syncThemePreferenceFromStorage() { }) } +// 系统配色变化时,在自动主题模式下刷新当前实际主题。 function handleSystemThemeChange() { if ((localStorage.getItem('theme') || 'auto') === 'auto') { syncThemePreferenceFromStorage() } } +// 页面重新可见时同步主题,修复后台期间设置被外部修改后的外观漂移。 function handleVisibilityThemeSync() { if (document.visibilityState === 'visible') { syncThemePreferenceFromStorage() } } +// 页面从缓存或重新聚焦恢复时刷新主题偏好。 function handlePageShowThemeSync() { syncThemePreferenceFromStorage() } +// 清理背景图交叉淡入淡出定时器。 function clearBackgroundCrossfadeTimer() { if (backgroundCrossfadeTimer) { window.clearTimeout(backgroundCrossfadeTimer) @@ -189,6 +194,7 @@ function clearBackgroundCrossfadeTimer() { } } +// 重置背景图交叉淡入淡出状态。 function resetBackgroundCrossfade() { clearBackgroundCrossfadeTimer() previousImageIndex.value = null @@ -256,6 +262,7 @@ function startBackgroundRotation() { } } +// 停止登录页或透明主题背景图加载、重试和轮播。 function stopBackgroundLoading() { backgroundRequestController?.abort() backgroundRequestController = null @@ -269,6 +276,7 @@ function stopBackgroundLoading() { removeBackgroundTimer('background-rotation') } +// 初始化登录后的全局设置和用户设置状态。 async function initializeAuthenticatedState() { if (!isLogin.value) return @@ -281,6 +289,7 @@ async function initializeAuthenticatedState() { } } +// 延迟初始化登录态数据,避开登录成功后的即时路由跳转窗口。 function scheduleAuthenticatedStateInitialization() { if (authenticatedStateTimer) { window.clearTimeout(authenticatedStateTimer) diff --git a/src/pages/login.vue b/src/pages/login.vue index e660abaf..c85f02da 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -8,7 +8,6 @@ import logo from '@images/logo.png' import { bufferToBase64Url, base64UrlToUint8Array, urlBase64ToUint8Array } from '@/@core/utils/navigator' import { SUPPORTED_LOCALES, SupportedLocale } from '@/types/i18n' import { getCurrentLocale, setI18nLanguage } from '@/plugins/i18n' -import { useTheme } from 'vuetify' import { getNavMenus } from '@/router/i18n-menu' import { buildUserPermissionContext, filterMenusByPermission } from '@/utils/permission' import type { ApiResponse } from '@/api/types' @@ -65,14 +64,6 @@ const langMenu = ref(false) // 当前语言 const currentLocale = ref(getCurrentLocale()) -// 当前主题 -const vuetifyTheme = useTheme() - -// 判断是否为透明主题 -const isTransparentTheme = computed(() => { - return vuetifyTheme.name.value === 'transparent' -}) - // 可用的语言列表 const locales = Object.values(SUPPORTED_LOCALES) @@ -279,6 +270,7 @@ interface PassKeyFinishResponse { wizard: boolean } +// 执行 PassKey WebAuthn 认证并返回登录完成信息。 async function authenticateWithPassKey(options: PassKeyAuthOptions = {}): Promise { const { username, isConditional = false, signal } = options @@ -734,8 +726,7 @@ onUnmounted(() => {