fix: dark mode

This commit is contained in:
AnotiaWang
2025-02-11 22:11:08 +08:00
parent 501e25d835
commit 066aafa9b2
6 changed files with 108 additions and 64 deletions

View File

@ -6,6 +6,7 @@
const preference = computed(() => {
// 默认为自动,会跟随用户的浏览器切换
if (colorMode.preference === 'system') {
if (preferredColor.value === 'no-preference') return 'dark'
return preferredColor.value
}
return colorMode.preference
@ -18,14 +19,6 @@
<template>
<div>
<UButton
:icon="
preference === 'dark'
? 'i-heroicons-sun-20-solid'
: 'i-heroicons-moon-20-solid'
"
color="primary"
@click="toggleColorMode"
/>
<UButton :icon="preference === 'dark' ? 'i-lucide-sun' : 'i-lucide-moon'" color="primary" @click="toggleColorMode" />
</div>
</template>