/
AppLayout.vue
45 lines (39 loc) · 1.01 KB
/
AppLayout.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<template>
<div id="app">
<app-header></app-header>
<router-view></router-view>
<app-footer></app-footer>
</div>
</template>
<script>
import { mapActions } from 'vuex';
import Header from '@_/theme/Header.vue';
import Footer from '@_/theme/Footer.vue';
export default {
name: 'AppLayout',
components: {
'app-header': Header,
'app-footer': Footer
},
methods: {
...mapActions(['setIsAuthenticatedAction', 'setProfileAction'])
},
created() {
if (typeof window !== 'undefined') {
let authenticationValue = false;
const expiration = window.localStorage.getItem('tokenExpiration');
const timeNow = new Date().getTime() / 1000;
if (expiration !== null && parseInt(expiration) - timeNow > 0) {
authenticationValue = true;
this.setProfileAction(); //no async await to first setAuthentication status
}
this.setIsAuthenticatedAction(authenticationValue);
}
}
};
</script>
<style lang="scss">
.columns {
flex-wrap: wrap;
}
</style>