diff --git a/js/about.js b/js/about.js index e1faaa4..83675fe 100644 --- a/js/about.js +++ b/js/about.js @@ -17,7 +17,6 @@ function setStoredTheme(theme) { localStorage.setItem(cacheKey, JSON.stringify({ value: theme, time: new Date().getTime() })); - console.log("已保存主题设置:", theme); } // 公共方法:获取本地存储的主题设置 @@ -33,7 +32,6 @@ function getStoredTheme() { const night = hour >= 18 || prefersDark; theme = night ? 'night' : 'day'; setStoredTheme(theme) - console.log("已初始化主题设置:", theme); } else if (saved.value) { theme = saved.value; } @@ -41,10 +39,16 @@ function getStoredTheme() { } $(document).ready(function () { - // 启动应用核心 const app = new AppCore(); }); +function escapeHtml(s) { + if (s == null) return ''; + return String(s).replace(/[&<>\"]/g, function (c) { + return ({'&': '&', '<': '<', '>': '>', '"': '"'})[c]; + }); +} + class AppCore { constructor() { this.i18n = new I18nManager(); @@ -59,7 +63,7 @@ class AppCore { =========================== */ class I18nManager { constructor() { - this.lang = localStorage.getItem('lang') || (navigator.language.startsWith('zh') ? 'zh' : 'en'); + this.lang = getStoredLanguage(); this.dict = { zh: { "nav.home": "首页", @@ -282,20 +286,20 @@ class DataManager { // Fix: API field compatibility const stars = repo.stargazers_count !== undefined ? repo.stargazers_count : (repo.stars || 0); const forks = repo.forks_count !== undefined ? repo.forks_count : (repo.forks || 0); - const desc = repo.description || repo.desc || 'No description.'; + const descRaw = repo.description || repo.desc || 'No description.'; const url = repo.html_url || repo.url || '#'; - const dShort = (desc || '').length > 120 ? (desc.slice(0, 117) + '...') : desc; + const dShort = (descRaw || '').length > 120 ? (descRaw.slice(0, 117) + '...') : descRaw; html += ` -