✨ 首页和登录页支持全局主题
- index.html 添加亮色主题 CSS 变量和样式 - index.html 添加 JS 自动加载全局主题 - app.js 修改 initTheme,未登录时从公开 API 获取全局主题 - 登录页面现在会跟随管理员设置的全局主题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -288,12 +288,24 @@ createApp({
|
||||
methods: {
|
||||
// ========== 主题管理 ==========
|
||||
// 初始化主题
|
||||
initTheme() {
|
||||
async initTheme() {
|
||||
// 先从localStorage读取,避免页面闪烁
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme) {
|
||||
this.applyTheme(savedTheme);
|
||||
}
|
||||
// 如果没有登录,从公开API获取全局主题
|
||||
if (!this.token) {
|
||||
try {
|
||||
const res = await axios.get(`${this.apiBase}/api/public/theme`);
|
||||
if (res.data.success) {
|
||||
this.globalTheme = res.data.theme;
|
||||
this.applyTheme(res.data.theme);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('无法加载全局主题');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 加载用户主题设置(登录后调用)
|
||||
|
||||
Reference in New Issue
Block a user