Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/App.vue
<template> | <template> | ||||
<router-view v-if="!isLoading"></router-view> | <router-view v-if="!isLoading && !routerReloading"></router-view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
isLoading: true | isLoading: true, | ||||
routerReloading: false | |||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const token = localStorage.getItem('token') | const token = localStorage.getItem('token') | ||||
if (token) { | if (token) { | ||||
this.$root.startLoading() | this.$root.startLoading() | ||||
axios.defaults.headers.common.Authorization = 'Bearer ' + token | axios.defaults.headers.common.Authorization = 'Bearer ' + token | ||||
Show All 11 Lines | export default { | ||||
this.isLoading = false | this.isLoading = false | ||||
this.$root.errorHandler(error) | this.$root.errorHandler(error) | ||||
}) | }) | ||||
} else { | } else { | ||||
this.$root.stopLoading() | this.$root.stopLoading() | ||||
this.isLoading = false | this.isLoading = false | ||||
} | } | ||||
}, | }, | ||||
methods: { | |||||
routerReload() { | |||||
// Together with beforeRouteUpdate even on a route component | |||||
// allows us to force reload the component. So it is possible | |||||
// to jump from/to page that uses currently loaded component. | |||||
this.routerReloading = true | |||||
this.$nextTick().then(() => { | |||||
this.routerReloading = false | |||||
}) | |||||
} | |||||
} | |||||
} | } | ||||
</script> | </script> |