-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ refactor dark mode using vueuse useDark
- Loading branch information
1 parent
3cbf886
commit d2c4fd2
Showing
10 changed files
with
117 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<div class="my-4"> | ||
<van-cell-group inset> | ||
<van-cell center title="🌓 暗黑模式"> | ||
<template #right-icon> | ||
<i inline-block align-middle i="dark:carbon-moon carbon-sun" /> | ||
<span class="ml-2">{{ isDark ? 'Dark' : 'Light' }}</span> | ||
<span class="mx-2">{{ isDark }}</span> | ||
<van-switch v-model="checked" size="22" @click="toggle()" /> | ||
</template> | ||
</van-cell> | ||
</van-cell-group> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { useDark, useToggle } from '@vueuse/core' | ||
import { useDesignSettingStore } from '@/store/modules/designSetting' | ||
const designStore = useDesignSettingStore() | ||
const isDark = useDark({ | ||
valueDark: 'dark', | ||
valueLight: 'light', | ||
}) | ||
const checked = ref(isDark.value) | ||
const toggleDark = useToggle(isDark) | ||
function toggle() { | ||
toggleDark() | ||
designStore.setDarkMode(isDark.value ? 'dark' : 'light') | ||
} | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.