This commit is contained in:
zyronon
2023-09-22 18:11:22 +08:00
parent 7791bf37a8
commit 763cb74cd9
7 changed files with 118 additions and 117 deletions

View File

@@ -1,15 +1,16 @@
import {useBaseStore} from "@/stores/base.ts";
import {useSettingStore} from "@/stores/setting.ts";
export default function useTheme() {
const store = useBaseStore()
const settingStore = useSettingStore()
function toggle() {
if (store.theme === 'auto') {
store.theme = 'dark'
if (settingStore.theme === 'auto') {
settingStore.theme = 'dark'
} else {
store.theme = store.theme === 'light' ? 'dark' : 'light'
settingStore.theme = settingStore.theme === 'light' ? 'dark' : 'light'
}
document.documentElement.setAttribute('data-theme', store.theme)
document.documentElement.setAttribute('data-theme', settingStore.theme)
}
return {