From 1c3168c0243fa7f6695c9c99cb70a372d6af7e8b Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Mon, 26 Jan 2026 23:29:29 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E6=98=BC=E5=A4=9C=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Ying/assets/js/barrage.js | 14 ++++++++++++++ themes/Ying/assets/js/main.js | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/themes/Ying/assets/js/barrage.js b/themes/Ying/assets/js/barrage.js index 609786c6..94ff80f7 100644 --- a/themes/Ying/assets/js/barrage.js +++ b/themes/Ying/assets/js/barrage.js @@ -260,8 +260,22 @@ } } + // 判断是否为移动端 + function isMobile() { + if (window.innerWidth < 768) { + return true; + } + return window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i); + } + // 加载弹幕主函数 async function loadBarrager() { + // 移动端不加载弹幕 + if (isMobile()) { + console.log('[Barrage] 移动端已禁用弹幕'); + return; + } + try { const commentsData = await initArtalkAndGetComments(); if (commentsData) { diff --git a/themes/Ying/assets/js/main.js b/themes/Ying/assets/js/main.js index 8ec94df0..ac39c190 100644 --- a/themes/Ying/assets/js/main.js +++ b/themes/Ying/assets/js/main.js @@ -231,6 +231,31 @@ function toggleTheme() { } } +// Listen for system theme changes +try { + const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); + const handleSystemThemeChange = (e) => { + // Only follow system if user hasn't manually set a preference + if (!localStorage.getItem('theme')) { + const newTheme = e.matches ? 'dark' : 'light'; + document.documentElement.setAttribute('data-theme', newTheme); + if (window.Artalk) { + Artalk.setDarkMode(newTheme === 'dark'); + } + } + }; + + // Modern browsers + if (mediaQuery.addEventListener) { + mediaQuery.addEventListener('change', handleSystemThemeChange); + } else if (mediaQuery.addListener) { + // Old Safari/IE + mediaQuery.addListener(handleSystemThemeChange); + } +} catch (e) { + console.warn('System theme detection not supported', e); +} + // Update Floating Tools Visibility based on current page function updateFloatingToolsVisibility() { const tools = document.querySelector('.floating-tools');