diff --git a/frontend/src/composables/theme.js b/frontend/src/composables/theme.js new file mode 100644 index 000000000..b719b4398 --- /dev/null +++ b/frontend/src/composables/theme.js @@ -0,0 +1,48 @@ +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 } +} diff --git a/frontend/src/layouts/connected/ConnectedLayout.vue b/frontend/src/layouts/connected/ConnectedLayout.vue index 0b954161c..31e82505a 100644 --- a/frontend/src/layouts/connected/ConnectedLayout.vue +++ b/frontend/src/layouts/connected/ConnectedLayout.vue @@ -26,17 +26,16 @@ diff --git a/frontend/src/views/login/LoginCallbackView.vue b/frontend/src/views/login/LoginCallbackView.vue index da0868224..ca47858be 100644 --- a/frontend/src/views/login/LoginCallbackView.vue +++ b/frontend/src/views/login/LoginCallbackView.vue @@ -1,30 +1,34 @@