mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-08 21:44:32 +02:00
Add a Light theme and a theme detection/selection feature
This commit is contained in:
27
resources/js/app.js
vendored
27
resources/js/app.js
vendored
@ -18,7 +18,32 @@ const app = new Vue({
|
||||
appSettings: window.appSettings,
|
||||
appConfig: window.appConfig,
|
||||
isDemoApp: window.isDemoApp,
|
||||
isTestingApp: window.isTestingApp
|
||||
isTestingApp: window.isTestingApp,
|
||||
prefersDarkScheme: window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
},
|
||||
|
||||
computed: {
|
||||
showDarkMode: function() {
|
||||
return this.appSettings.theme == 'dark' ||
|
||||
(this.appSettings.theme == 'system' && this.prefersDarkScheme)
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
this.$nextTick(() => {
|
||||
this.mediaQueryList.addEventListener('change', this.setDarkScheme)
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.mediaQueryList.removeEventListener('change', this.setDarkScheme)
|
||||
},
|
||||
|
||||
methods: {
|
||||
setDarkScheme ({ matches }) {
|
||||
this.prefersDarkScheme = matches
|
||||
}
|
||||
},
|
||||
i18n,
|
||||
router,
|
||||
|
Reference in New Issue
Block a user