Added vuex module for setting if darkmode is supported in users browser
This commit is contained in:
		@@ -17,6 +17,8 @@ Vue.use(Toast)
 | 
			
		||||
Vue.use(DataTablee)
 | 
			
		||||
Vue.use(VModal, { dialog: true })
 | 
			
		||||
 | 
			
		||||
store.dispatch('darkmodeModule/findAndSetDarkmodeSupported')
 | 
			
		||||
 | 
			
		||||
new Vue({
 | 
			
		||||
  el: '#app',
 | 
			
		||||
  router,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								src/modules/darkmodeModule.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/modules/darkmodeModule.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
export default {
 | 
			
		||||
  namespaced: true,
 | 
			
		||||
  state: {
 | 
			
		||||
    darkmodeSupported: undefined,
 | 
			
		||||
    userChoice: undefined
 | 
			
		||||
  },
 | 
			
		||||
  getters: {
 | 
			
		||||
    darkmodeSupported: (state) => {
 | 
			
		||||
      return state.darkmodeSupported
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  mutations: {
 | 
			
		||||
    SET_DARKMODE_SUPPORT: (state, browserSupported) => {
 | 
			
		||||
      state.darkmodeSupported = browserSupported
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  actions: {
 | 
			
		||||
    findAndSetDarkmodeSupported({ commit }) {
 | 
			
		||||
      const browserSupported = window.matchMedia('(prefers-color-scheme)').media !== 'not all'
 | 
			
		||||
      commit('SET_DARKMODE_SUPPORT', browserSupported)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,12 +2,14 @@ import Vue from 'vue'
 | 
			
		||||
import Vuex from 'vuex'
 | 
			
		||||
 | 
			
		||||
import torrentModule from './modules/torrentModule.js'
 | 
			
		||||
import darkmodeModule from './modules/darkmodeModule.js'
 | 
			
		||||
 | 
			
		||||
Vue.use(Vuex)
 | 
			
		||||
 | 
			
		||||
const store = new Vuex.Store({
 | 
			
		||||
  modules: {
 | 
			
		||||
    torrentModule
 | 
			
		||||
    torrentModule,
 | 
			
		||||
    darkmodeModule
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user