diff --git a/js/theme.js b/js/theme.js index 48c9209..69c61c9 100644 --- a/js/theme.js +++ b/js/theme.js @@ -24,13 +24,17 @@ function updateThemeUI(theme) { const icon = document.getElementById('themeIcon'); const label = document.getElementById('themeLabel'); if (!icon) return; + + // 确保 t 函数存在,否则用默认文字 + const translate = typeof t === 'function' ? t : function(key) { return key; }; + if (theme === 'dark') { icon.innerHTML = ``; - if (label) label.textContent = '☀️ 亮色模式'; + if (label) label.textContent = translate('亮色模式'); } else { icon.innerHTML = ``; - if (label) label.textContent = '🌙 暗色模式'; + if (label) label.textContent = translate('暗色模式'); } }