diff --git a/komga-webui/src/views/Home.vue b/komga-webui/src/views/Home.vue index 2a580f8a2..80ac6380b 100644 --- a/komga-webui/src/views/Home.vue +++ b/komga-webui/src/views/Home.vue @@ -102,12 +102,12 @@ - mdi-brightness-7 - mdi-brightness-3 - mdi-brightness-auto + mdi-brightness-7 + mdi-brightness-3 + mdi-brightness-auto @@ -148,7 +148,9 @@ export default Vue.extend({ return { drawerVisible: this.$vuetify.breakpoint.lgAndUp, info: {} as ActuatorInfo, - activeTheme: Theme.LIGHT, + settings: { + theme: Theme.LIGHT, + }, Theme, themes: [ { text: Theme.LIGHT.valueOf(), value: Theme.LIGHT }, @@ -157,11 +159,6 @@ export default Vue.extend({ ], } }, - watch: { - activeTheme (val) { - this.changeTheme(val) - }, - }, async created () { if (this.isAdmin) { this.info = await this.$actuator.getInfo() @@ -170,7 +167,7 @@ export default Vue.extend({ if (this.$cookies.isKey(cookieTheme)) { const theme = this.$cookies.get(cookieTheme) if (Object.values(Theme).includes(theme)) { - this.activeTheme = theme as Theme + this.theme = theme as Theme } } @@ -186,18 +183,30 @@ export default Vue.extend({ isAdmin (): boolean { return this.$store.getters.meAdmin }, + + theme: { + get: function (): Theme { + return this.settings.theme + }, + set: function (theme: Theme): void { + if (Object.values(Theme).includes(theme)) { + this.settings.theme = theme + this.changeTheme(theme) + this.$cookies.set(cookieTheme, theme, Infinity) + } + }, + }, }, methods: { toggleDrawer () { this.drawerVisible = !this.drawerVisible }, systemThemeChange () { - if (this.activeTheme === Theme.SYSTEM) { - this.changeTheme(this.activeTheme) + if (this.theme === Theme.SYSTEM) { + this.changeTheme(this.theme) } }, changeTheme (theme: Theme) { - this.$cookies.set(cookieTheme, theme.valueOf()) switch (theme) { case Theme.DARK: this.$vuetify.theme.dark = true