Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/App.vue
<template> | <template> | ||||
<router-view v-if="!isLoading && !routerReloading"></router-view> | <router-view v-if="!isLoading && !routerReloading" :key="key"></router-view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
export default { | export default { | ||||
computed: { | |||||
key() { | |||||
// The 'key' property is used to reload the Page component | |||||
// whenever a route changes. Normally vue does not do that. | |||||
return this.$route.name == '404' ? this.$route.path : 'static' | |||||
} | |||||
}, | |||||
data() { | data() { | ||||
return { | return { | ||||
isLoading: true, | isLoading: true, | ||||
routerReloading: false | routerReloading: false | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const token = localStorage.getItem('token') | const token = localStorage.getItem('token') | ||||
this.$root.updateBodyClass() | |||||
if (token) { | if (token) { | ||||
this.$root.startLoading() | this.$root.startLoading() | ||||
axios.defaults.headers.common.Authorization = 'Bearer ' + token | axios.defaults.headers.common.Authorization = 'Bearer ' + token | ||||
axios.get('/api/auth/info?refresh_token=1') | axios.get('/api/auth/info?refresh_token=1') | ||||
.then(response => { | .then(response => { | ||||
this.$root.loginUser(response.data, false) | this.$root.loginUser(response.data, false) | ||||
this.$root.stopLoading() | this.$root.stopLoading() | ||||
Show All 26 Lines |