Simple and stupid way to customize theme colors.

This commit is contained in:
Antoine Nguyen
2025-07-26 18:40:11 +02:00
parent 81e52cbf07
commit b3ed8bd0a3
9 changed files with 205 additions and 4 deletions
+41 -1
View File
@@ -4,4 +4,44 @@
</Suspense>
</template>
<script setup></script>
<script setup>
import { useTheme } from 'vuetify'
import themeApi from '@/api/theme'
const theme = useTheme()
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
}
})
</script>
+7
View File
@@ -0,0 +1,7 @@
import repository from './repository'
export default {
getTheme() {
return repository.get(`/theme/`)
},
}
@@ -68,6 +68,16 @@
v-model="parameters[param.name]"
>
</HtmlEditor>
<v-color-picker
v-else-if="param.widget === 'ColorPicker'"
v-model="parameters[param.name]"
:hint="param.help_text"
persistent-hint
:error="formErrors[param.name] !== undefined"
:error-messages="formErrors[param.name]"
density="compact"
variant="outlined"
/>
<v-text-field
v-else
v-model="parameters[param.name]"
+15 -1
View File
@@ -1,6 +1,6 @@
<template>
<v-toolbar flat>
<v-toolbar-title>{{ $gettext('Welcome to Modoboa') }}</v-toolbar-title>
<v-toolbar-title>{{ welcomeMsg }}</v-toolbar-title>
</v-toolbar>
<v-row>
@@ -11,7 +11,21 @@
</template>
<script setup>
import { ref } from 'vue'
import { useGettext } from 'vue3-gettext'
import NewsFeedWidget from '@/components/admin/dashboard/NewsFeedWidget'
import parametersApi from '@/api/parameters'
const { $gettext } = useGettext()
const welcomeMsg = ref('')
const response = await parametersApi.getGlobalApplication('core')
if (response.data.params.custom_welcome_message) {
welcomeMsg.value = response.data.params.custom_welcome_message
} else {
welcomeMsg.value = $gettext('Welcome to Modoboa')
}
</script>
<style scoped>