fix: ARL not setting correctly in the store; feat: removed some document.getElementById; feat: added v-cloak style

This commit is contained in:
Roberto Tonino
2020-09-17 23:55:57 +02:00
parent bd54f7e8d9
commit cda31a93ff
12 changed files with 78 additions and 75 deletions

View File

@@ -1,6 +1,6 @@
const getDefaultState = () => {
return {
arl: '',
arl: localStorage.getItem('arl') || '',
status: null,
user: {
id: null,
@@ -13,21 +13,22 @@ const getDefaultState = () => {
const state = getDefaultState()
const actions = {
login({ commit }, payload) {
login({ commit, dispatch }, payload) {
const { arl, user, status } = payload
commit('SET_ARL', arl)
dispatch('setARL', { arl })
commit('SET_USER', user)
commit('SET_STATUS', status)
},
logout({ commit }) {
console.log('logout')
commit('RESET_LOGIN')
localStorage.removeItem('arl')
commit('RESET_LOGIN')
},
setARL({ commit }, payload) {
const { arl, saveOnLocalStorage } = payload
let { arl, saveOnLocalStorage } = payload
saveOnLocalStorage = typeof saveOnLocalStorage === 'undefined' ? true : saveOnLocalStorage
commit('SET_ARL', arl)
@@ -48,7 +49,8 @@ const actions = {
const getters = {
getARL: state => state.arl,
getUser: state => state.user,
isLoggedIn: state => [1, 2, 3].indexOf(state.status) !== -1
// isLoggedIn: state => [1, 2, 3].indexOf(state.status) !== -1
isLoggedIn: state => !!state.arl
}
const mutations = {