From 551646244e7c44ba4c672a139a534367cfc4e56b Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Thu, 27 Nov 2025 23:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E6=B7=BB=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加console.log帮助诊断全局主题设置不生效的问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/app.js b/frontend/app.js index 7eb1472..858318f 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -352,21 +352,30 @@ createApp({ // 设置全局主题(管理员) async setGlobalTheme(theme) { try { + console.log('[主题] 设置全局主题:', theme); const res = await axios.post(`${this.apiBase}/api/admin/settings`, { global_theme: theme }, { headers: { Authorization: `Bearer ${this.token}` }} ); + console.log('[主题] API响应:', res.data); if (res.data.success) { this.globalTheme = theme; + console.log('[主题] globalTheme已更新为:', this.globalTheme); // 如果用户没有设置个人偏好,则跟随全局 if (this.userThemePreference === null) { this.currentTheme = theme; this.applyTheme(theme); localStorage.setItem('theme', theme); + } else { + console.log('[主题] 用户有个人偏好,不更改当前显示主题:', this.userThemePreference); } this.showToast('success', '全局主题已更新', theme === 'dark' ? '默认暗色主题' : '默认亮色主题'); + } else { + console.error('[主题] API返回失败:', res.data); + this.showToast('error', '设置失败', res.data.message || '未知错误'); } } catch (error) { + console.error('[主题] 设置全局主题失败:', error); this.showToast('error', '设置失败', error.response?.data?.message || '请稍后重试'); } }, @@ -2302,8 +2311,10 @@ handleDragLeave(e) { const settings = response.data.settings; this.systemSettings.maxUploadSizeMB = Math.round(settings.max_upload_size / (1024 * 1024)); // 加载全局主题设置 + console.log('[主题] 从服务器加载全局主题:', settings.global_theme); if (settings.global_theme) { this.globalTheme = settings.global_theme; + console.log('[主题] globalTheme已设置为:', this.globalTheme); } if (settings.smtp) { this.systemSettings.smtp.host = settings.smtp.host || '';