feat: add dark/light theme toggle, fix cover display, refine overall style

- Add theme toggle button in navbar with sun/moon icons
- Define [data-theme=dark] CSS variables (warm dark palette)
- Persist theme preference in localStorage
- Follow system prefers-color-scheme on first visit
- Anti-flash inline script sets theme before render
- ECharts charts re-render with theme-aware colors on toggle
- Fix reading ranking covers: aspect-ratio 3/4 instead of fixed height
- Fix discover covers: aspect-ratio 3/4 for proper portrait display
- Replace purple hero gradient with warm brown/amber matching accent
- All hardcoded colors replaced with CSS variables
- Smooth 0.3s transitions on all theme-dependent elements
- Update footer text from SQLite to MySQL
This commit is contained in:
admin committed 2026-07-17 11:13:11 +08:00
1 parent 9c32f69f71
commit ae40ed93d6
3 files changed
+406 -93

No files matched your search

+19 -2
View File
@@ -6,6 +6,17 @@
<title>我的读书数据</title>
<link rel="stylesheet" href="/static/css/style.css">
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
<!-- 防闪烁:在 CSS 加载后、页面渲染前设置主题 -->
<script>
(function() {
var saved = localStorage.getItem('theme');
if (saved) {
document.documentElement.setAttribute('data-theme', saved);
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-theme', 'dark');
}
})();
</script>
</head>
<body>
<!-- 数据库连接告警横幅(MySQL 连接失败时显示) -->
@@ -30,7 +41,13 @@
<a href="#notes" class="nav-link">笔记</a>
<a href="#discover" class="nav-link">推荐</a>
</div>
<div class="nav-update" id="fetchTime"></div>
<div class="nav-right">
<span class="nav-update" id="fetchTime"></span>
<button class="theme-toggle" onclick="toggleTheme()" title="切换明亮/黑暗模式" aria-label="切换主题">
<span class="icon-sun">☀️</span>
<span class="icon-moon">🌙</span>
</button>
</div>
</div>
</nav>
@@ -171,7 +188,7 @@
<!-- 页脚 -->
<footer class="footer">
<div class="container">
<p>数据来源:微信读书 · 数据存储:本地 SQLite · 更新时间:<span id="footerTime"></span></p>
<p>数据来源:微信读书 · 数据存储:本地 MySQL · 更新时间:<span id="footerTime"></span></p>
<p class="footer-hint">点击书籍封面可在微信读书 App 中打开</p>
</div>
</footer>