32 lines
943 B
JavaScript
32 lines
943 B
JavaScript
/* 顶部导航组件 */
|
|
import { systemConfig } from '../config/system.js';
|
|
import { Auth } from '../core/auth.js';
|
|
import { themeConfig } from '../config/theme.js';
|
|
|
|
export function renderHeader() {
|
|
const header = document.createElement('div');
|
|
header.className = 'header';
|
|
|
|
header.innerHTML = `
|
|
<div class="app-name">${systemConfig.appName}</div>
|
|
<div class="header-actions">
|
|
<button onclick="toggleTheme()">切换主题</button>
|
|
<button onclick="Auth.logout()">退出登录</button>
|
|
</div>
|
|
`;
|
|
|
|
return header;
|
|
}
|
|
|
|
// 主题切换函数
|
|
function toggleTheme() {
|
|
const body = document.body;
|
|
if (body.classList.contains(themeConfig.darkThemeClass)) {
|
|
body.classList.remove(themeConfig.darkThemeClass);
|
|
localStorage.setItem(themeConfig.themeStorageKey, 'light');
|
|
} else {
|
|
body.classList.add(themeConfig.darkThemeClass);
|
|
localStorage.setItem(themeConfig.themeStorageKey, 'dark');
|
|
}
|
|
}
|