diff --git a/index.html b/index.html index 1224ecca..4b54d7f5 100644 --- a/index.html +++ b/index.html @@ -296,6 +296,7 @@ } } + // 安全读取本地存储,隐私模式或存储不可用时返回空值。 function getLocalStorageValue(key) { try { return localStorage.getItem(key) @@ -322,12 +323,18 @@ background: '#1C1C1C', primary: '#A370F7', }, + glass: { + background: '#0B1322', + primary: '#E4B863', + }, } + // 读取已保存的主题偏好,缺省时跟随系统。 function getSavedThemePreference() { return getLocalStorageValue('theme') || 'auto' } + // 将启动阶段的主题偏好解析为实际主题。 function resolveLaunchTheme(themePreference) { if (themePreference === 'auto') { return checkPrefersColorSchemeIsDark() ? 'dark' : 'light' @@ -340,16 +347,19 @@ return launchThemePalettes[themePreference] ? themePreference : 'light' } + // 返回启动阶段浏览器原生控件应使用的明暗配色。 function getLaunchColorScheme(themeName) { - return ['dark', 'purple', 'transparent'].includes(themeName) ? 'dark' : 'light' + return ['dark', 'glass', 'purple', 'transparent'].includes(themeName) ? 'dark' : 'light' } + // 批量同步匹配选择器的 meta 内容。 function setMetaContent(selector, content) { document.querySelectorAll(selector).forEach(meta => { meta.setAttribute('content', content) }) } + // 更新或创建浏览器主题色 meta 标签。 function syncThemeColorMeta(themeColor) { const metas = document.querySelectorAll('meta[name="theme-color"]') diff --git a/src/App.vue b/src/App.vue index d711eaa5..a1b19bd0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -73,10 +73,13 @@ const backgroundImages = ref([]) const activeImageIndex = ref(0) const previousImageIndex = ref(null) const isTransparentTheme = computed(() => globalTheme.name.value === 'transparent') +const isGlassTheme = computed(() => globalTheme.name.value === 'glass') +const isBackdropTheme = computed(() => isTransparentTheme.value || isGlassTheme.value) const isLoginWallpaperRoute = computed(() => !isLogin.value && route.path === LOGIN_WALLPAPER_ROUTE) const shouldUseTransparentBackgroundTreatment = computed(() => Boolean(isLogin.value) && isTransparentTheme.value) +const shouldUseGlassBackgroundTreatment = computed(() => Boolean(isLogin.value) && isGlassTheme.value) const shouldLoadBackgroundImages = computed( - () => isLoginWallpaperRoute.value || (Boolean(isLogin.value) && isTransparentTheme.value), + () => isLoginWallpaperRoute.value || (Boolean(isLogin.value) && isBackdropTheme.value), ) const transparentBackgroundBlur = ref(16) const transparencyGlassQuality = ref( @@ -434,7 +437,7 @@ function startBackgroundRotation() { } } -// 停止登录页或透明主题背景图加载、重试和轮播。 +// 停止登录页、透明主题或玻璃主题背景图加载、重试和轮播。 function stopBackgroundLoading() { backgroundRequestController?.abort() backgroundRequestController = null @@ -597,7 +600,7 @@ onMounted(async () => { stopBackgroundLoading() if (shouldLoad) { loadBackgroundImages() - } else if (!isTransparentTheme.value) { + } else if (!isBackdropTheme.value) { backgroundImages.value = [] } }, @@ -652,12 +655,13 @@ onUnmounted(() => {