Add selected theme computed
This commit is contained in:
parent
7c9959831e
commit
298cd1afae
|
@ -28,7 +28,7 @@ const emit = defineEmits<Events>()
|
||||||
defineProps<Props>()
|
defineProps<Props>()
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const theme = useTheme()
|
const { theme } = useTheme()
|
||||||
const themes = useThemeList()
|
const themes = useThemeList()
|
||||||
const { $pgettext } = useGettext()
|
const { $pgettext } = useGettext()
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ const emit = defineEmits<Events>()
|
||||||
|
|
||||||
const { $pgettext } = useGettext()
|
const { $pgettext } = useGettext()
|
||||||
const themes = useThemeList()
|
const themes = useThemeList()
|
||||||
const theme = useTheme()
|
const { theme } = useTheme()
|
||||||
|
|
||||||
const labels = computed(() => ({
|
const labels = computed(() => ({
|
||||||
profile: $pgettext('*/*/*/Noun', 'Profile'),
|
profile: $pgettext('*/*/*/Noun', 'Profile'),
|
||||||
|
|
|
@ -21,7 +21,7 @@ const props = defineProps<Props>()
|
||||||
|
|
||||||
const show = useVModel(props, 'show', emit)
|
const show = useVModel(props, 'show', emit)
|
||||||
|
|
||||||
const theme = useTheme()
|
const { theme } = useTheme()
|
||||||
const themes = useThemeList()
|
const themes = useThemeList()
|
||||||
|
|
||||||
const { $pgettext } = useGettext()
|
const { $pgettext } = useGettext()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { useColorMode } from '@vueuse/core'
|
import { useColorMode, usePreferredDark } from '@vueuse/core'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
const theme = useColorMode({
|
const theme = useColorMode({
|
||||||
selector: 'body',
|
selector: 'body',
|
||||||
|
@ -10,4 +11,13 @@ const theme = useColorMode({
|
||||||
emitAuto: true
|
emitAuto: true
|
||||||
})
|
})
|
||||||
|
|
||||||
export default () => theme
|
const preferredDark = usePreferredDark({ window })
|
||||||
|
const selectedTheme = computed(() => theme.value === 'auto'
|
||||||
|
? preferredDark.value ? 'dark' : 'light'
|
||||||
|
: theme.value
|
||||||
|
)
|
||||||
|
|
||||||
|
export default () => ({
|
||||||
|
theme,
|
||||||
|
selectedTheme
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue