Skip to content

Commit bcf0f67

Browse files
committed
Ensure login page also follows dark theme setting
1 parent 58fb2ff commit bcf0f67

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

web/src/views/Auth.vue

+23
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
import axios from 'axios';
128128
import { getErrorMessage } from '@/lib/error';
129129
130+
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
131+
130132
export default {
131133
data() {
132134
return {
@@ -138,13 +140,34 @@ export default {
138140
username: null,
139141
140142
loginHelpDialog: null,
143+
144+
darkMode: false,
141145
};
142146
},
143147
148+
watch: {
149+
darkMode(val) {
150+
this.$vuetify.theme.dark = val;
151+
},
152+
},
153+
144154
async created() {
145155
if (this.isAuthenticated()) {
146156
document.location = document.baseURI;
147157
}
158+
159+
const isDarkMode = localStorage.getItem('darkMode');
160+
if (isDarkMode !== null) {
161+
this.darkMode = isDarkMode === '1';
162+
} else {
163+
prefersDarkMode.addEventListener('change', (e) => {
164+
this.darkMode = e.matches;
165+
});
166+
167+
if (prefersDarkMode.matches && localStorage.getItem('darkMode') !== '0') {
168+
this.darkMode = true;
169+
}
170+
}
148171
},
149172
150173
methods: {

0 commit comments

Comments
 (0)