|
|
@ -4,7 +4,7 @@ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches |
|
|
|
const localTheme = |
|
|
|
const localTheme = |
|
|
|
localStorage.getItem(Keys.STORAGE_THEME) || (prefersDark ? 'dark' : 'light') |
|
|
|
localStorage.getItem(Keys.STORAGE_THEME) || (prefersDark ? 'dark' : 'light') |
|
|
|
|
|
|
|
|
|
|
|
const theme = ref<'light' | 'dark'>(localTheme as 'light' | 'dark'); |
|
|
|
const theme = ref<'light' | 'dark'>(localTheme as 'light' | 'dark') |
|
|
|
|
|
|
|
|
|
|
|
const chartGraphicTextColor = computed(() => |
|
|
|
const chartGraphicTextColor = computed(() => |
|
|
|
theme.value === 'dark' ? '#ccc' : '#4d4d4d' |
|
|
|
theme.value === 'dark' ? '#ccc' : '#4d4d4d' |
|
|
@ -13,6 +13,7 @@ const chartGraphicTextColor = computed(() => |
|
|
|
watchEffect(() => { |
|
|
|
watchEffect(() => { |
|
|
|
const html = document.querySelector('html') |
|
|
|
const html = document.querySelector('html') |
|
|
|
if (theme.value === 'dark') { |
|
|
|
if (theme.value === 'dark') { |
|
|
|
|
|
|
|
html?.classList.remove('light') |
|
|
|
html?.classList.add('dark') |
|
|
|
html?.classList.add('dark') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
html?.classList.remove('dark') |
|
|
|
html?.classList.remove('dark') |
|
|
@ -25,11 +26,15 @@ watchEffect(() => { |
|
|
|
function toggle() { |
|
|
|
function toggle() { |
|
|
|
theme.value = theme.value === 'light' ? 'dark' : 'light' |
|
|
|
theme.value = theme.value === 'light' ? 'dark' : 'light' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function setTheme(value: 'light' | 'dark') { |
|
|
|
|
|
|
|
theme.value = value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function useTheme() { |
|
|
|
export function useTheme() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
theme, |
|
|
|
theme, |
|
|
|
toggle, |
|
|
|
toggle, |
|
|
|
|
|
|
|
setTheme, |
|
|
|
chartGraphicTextColor, |
|
|
|
chartGraphicTextColor, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|