Files
modoboa/frontend/src/composables/theme.js
T
Antoine Nguyen 6afa2d15ac Apply custom theme to login page also.
And improved theme login for frontend.
2025-09-15 13:50:59 +02:00

49 lines
1.4 KiB
JavaScript

import { ref } from 'vue'
import { useTheme } from 'vuetify'
import themeApi from '@/api/theme'
export function useModoboaTheme() {
const vTheme = useTheme()
const theme = ref(null)
const enableTheme = async () => {
const response = await themeApi.getTheme()
theme.value = response.data
if (
theme.value.theme_primary_color !==
vTheme.themes.value.light.colors.primary
) {
vTheme.themes.value.light.colors.primary = theme.value.theme_primary_color
}
if (
theme.value.theme_primary_color_light !==
vTheme.themes.value.light.colors['primary-lighten-1']
) {
vTheme.themes.value.light.colors['primary-lighten-1'] =
theme.value.theme_primary_color_light
}
if (
theme.value.theme_primary_color_dark !==
vTheme.themes.value.light.colors['primary-darken-1']
) {
vTheme.themes.value.light.colors['primary-darken-1'] =
theme.value.theme_primary_color_dark
}
if (
theme.value.theme_secondary_color !==
vTheme.themes.value.light.colors.secondary
) {
vTheme.themes.value.light.colors.secondary =
theme.value.theme_secondary_color
}
if (
theme.value.theme_label_color !== vTheme.themes.value.light.colors.label
) {
vTheme.themes.value.light.colors.label = theme.value.theme_label_color
}
}
return { theme, enableTheme }
}