From fbb320fea6d9b09da8b4823ef8edf3ac7d532348 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sun, 16 Aug 2020 12:55:15 +0200 Subject: [PATCH] feat: global debugMode functions --- src/App.vue | 16 ++++++++++++++-- src/store/index.ts | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1259643..725cf85 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,9 +20,21 @@ export default Vue.extend({ created () { console.log('Using ' + process.env.VUE_APP_BASE_URL) - if (window.localStorage.getItem('associations_condorcet_debug') === 'YES') { - this.$store.commit('SET_DEBUG', true) + + // @ts-ignore + window.enableDebug = () => { + this.$store.commit('SET_DEBUG_MODE', true) + window.localStorage.setItem('pagesAssos__debugMode', 'true') } + + // @ts-ignore + window.disableDebug = () => { + this.$store.commit('SET_DEBUG_MODE', false) + window.localStorage.setItem('pagesAssos__debugMode', 'true') + } + + const debugMode = window.localStorage.getItem('pagesAssos__debugMode') + this.$store.commit('SET_DEBUG_MODE', debugMode === 'true') }, data: () => ({}) diff --git a/src/store/index.ts b/src/store/index.ts index f6cf71d..678d7a2 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -62,7 +62,7 @@ const defaultState: State = { email: '', publicUrl: '' }, - debug: false, + debugMode: false, validateMain: false, onMainReady: () => false, validateMainCallback: (d = false) => d, @@ -84,8 +84,8 @@ const defaultState: State = { export default new Vuex.Store({ state: defaultState, mutations: { - SET_DEBUG (state: State, payload) { - state.debug = payload + SET_DEBUG_MODE (state: State, payload) { + state.debugMode = payload }, SET_TITLE (state: State, payload) { state.title = payload