Apply custom theme to login page also.

And improved theme login for frontend.
This commit is contained in:
Antoine Nguyen
2025-09-15 13:50:59 +02:00
parent bcb4050c6c
commit 6afa2d15ac
7 changed files with 116 additions and 75 deletions
+48
View File
@@ -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 }
}
@@ -26,17 +26,16 @@
<script setup>
import { ref, computed } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useTheme } from 'vuetify'
import { useAuthStore, useBusStore } from '@/stores'
import { useModoboaTheme } from '@/composables/theme'
import ConnectedView from './ConnectedView.vue'
import NavBar from '@/components/shared/NavBar.vue'
import TopMenu from '@/components/shared/TopMenu.vue'
import themeApi from '@/api/theme'
const authStore = useAuthStore()
const busStore = useBusStore()
const { $gettext } = useGettext()
const theme = useTheme()
const { enableTheme } = useModoboaTheme()
const props = defineProps({
color: {
@@ -69,41 +68,7 @@ busStore.$onAction(({ name, after }) => {
}, true)
if (props.loadTheme) {
themeApi.getTheme().then((response) => {
if (
response.data.theme_primary_color !==
theme.themes.value.light.colors.primary
) {
theme.themes.value.light.colors.primary =
response.data.theme_primary_color
}
if (
response.data.theme_primary_color_light !==
theme.themes.value.light.colors['primary-lighten-1']
) {
theme.themes.value.light.colors['primary-lighten-1'] =
response.data.theme_primary_color_light
}
if (
response.data.theme_primary_color_dark !==
theme.themes.value.light.colors['primary-darken-1']
) {
theme.themes.value.light.colors['primary-darken-1'] =
response.data.theme_primary_color_dark
}
if (
response.data.theme_secondary_color !==
theme.themes.value.light.colors.secondary
) {
theme.themes.value.light.colors.secondary =
response.data.theme_secondary_color
}
if (
response.data.theme_label_color !== theme.themes.value.light.colors.label
) {
theme.themes.value.light.colors.label = response.data.theme_label_color
}
})
await enableTheme()
}
</script>
+12 -8
View File
@@ -1,30 +1,34 @@
<script setup>
import { onMounted } from 'vue'
import { useAuthStore } from '@/stores'
import { useModoboaTheme } from '@/composables/theme'
const props = defineProps({
redirectUrl: String,
})
const authStore = useAuthStore()
const { enableTheme } = useModoboaTheme()
onMounted(() => {
authStore.completeLogin(props.redirectUrl)
})
await enableTheme()
</script>
<template>
<v-container class="fill-height" fluid>
<v-row align="center" justify="center">
<v-col cols="auto" class="text-center">
<h1 class="ma-5">{{ $gettext('Attempting to log you in.') }}</h1>
<v-progress-circular
color="primary"
indeterminate
:size="128"
:width="12"
align-self="center"
></v-progress-circular>
<h1 class="ma-5">{{ $gettext('Attempting to log you in.') }}</h1>
<v-progress-circular
color="primary"
indeterminate
:size="128"
:width="12"
align-self="center"
></v-progress-circular>
</v-col>
</v-row>
</v-container>