🔧 添加全局主题设置调试日志
添加console.log帮助诊断全局主题设置不生效的问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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 || '';
|
||||
|
||||
Reference in New Issue
Block a user