feat: 完善暗色主题移动端适配 meta theme color
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
</style>
|
||||
|
||||
<script is:inline>
|
||||
const meta = document.querySelector('meta[name="theme-color"]');
|
||||
|
||||
const theme = (() => {
|
||||
const localStorageTheme = localStorage?.getItem("theme") ?? '';
|
||||
if (['dark', 'light'].includes(localStorageTheme)) {
|
||||
@@ -56,6 +58,8 @@
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
|
||||
meta.setAttribute('content', theme === 'dark' ? '#0a0a0a' : '#ffffff');
|
||||
|
||||
window.localStorage.setItem('theme', theme);
|
||||
|
||||
const handleToggleClick = () => {
|
||||
|
||||
Reference in New Issue
Block a user