parsley/app/javascript/components/App.vue
2018-09-13 14:51:41 -05:00

64 lines
1.2 KiB
Vue

<template>
<div>
<vue-progress-bar></vue-progress-bar>
<app-navbar></app-navbar>
<section id="app" class="">
<div class="container">
<router-view v-if="!hasError"></router-view>
<div v-else>
<h1>Error!</h1>
<p>{{error}}</p>
</div>
</div>
</section>
</div>
</template>
<script>
import { mapMutations, mapState } from "vuex";
import api from "../lib/Api";
import TWEEN from '@tweenjs/tween.js';
export default {
data() {
return {
api: api
};
},
computed: {
...mapState({
hasError: state => state.error !== null,
error: state => state.error,
authChecked: state => state.authChecked
})
},
watch: {
isLoading(val) {
if (val) {
this.$Progress.start();
} else {
this.$Progress.finish();
}
}
},
created() {
// Setup global animation loop
function animate () {
TWEEN.update();
requestAnimationFrame(animate);
}
animate();
if (this.user === null && this.authChecked === false) {
this.checkAuthentication();
}
},
components: {
}
}
</script>