1// 主é¢åæ¢åè½ 2function toggleTheme(isDark) { 3 document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light'); 4 localStorage.setItem('theme-preference', isDark ? 'dark' : 'light'); 5 6 // æ´æ°ä¸»é¢å¾æ 7 const themeIcon = document.getElementById('theme-icon'); 8 if (themeIcon) { 9 themeIcon.className = isDark ? 'ri-sun-line' : 'ri-moon-line'; 10 } 11} 12 13// æ£æ¥å¹¶è®¾ç½®ä¸»é¢ 14function checkAndSetTheme() { 15 const savedTheme = localStorage.getItem('theme-preference'); 16 if (savedTheme) { 17 toggleTheme(savedTheme === 'dark'); 18 } else { 19 // æ ¹æ®ä¸å «åºï¼å京æ¶é´ï¼èªå¨è®¾ç½® 20 const hour = (new Date().getUTCHours() + 8) % 24; 21 const isDayTime = hour >= 6 && hour < 18; 22 toggleTheme(!isDayTime); 23 } 24} 25 26// æå¨åæ¢ä¸»é¢ 27function manualToggleTheme() { 28 const currentTheme = document.documentElement.getAttribute('data-theme'); 29 toggleTheme(currentTheme === 'light'); 30} 31 32// åå§å主é¢
33checkAndSetTheme(); 34 35// åå§å主é¢å¾æ 36document.addEventListener('DOMContentLoaded', () => { 37 const currentTheme = document.documentElement.getAttribute('data-theme'); 38 const themeIcon = document.getElementById('theme-icon'); 39 if (themeIcon) { 40 themeIcon.className = currentTheme === 'dark' ? 'ri-sun-line' : 'ri-moon-line'; 41 } 42}); 43 44// æ¯å°æ¶æ£æ¥ä¸æ¬¡æ¶é´å¹¶æ´æ°ä¸»é¢ï¼ä» å½ç¨æ·æ²¡ææå¨è®¾ç½®ä¸»é¢æ¶ï¼ 45setInterval(() => { 46 if (!localStorage.getItem('theme-preference')) { 47 checkAndSetTheme(); 48 } 49}, 3600000); 50
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.