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');