onspot-frontend/src/App.vue

105 lines
1.9 KiB
Vue
Raw Normal View History

2020-11-25 16:19:00 +01:00
<template>
2020-11-26 01:30:15 +01:00
<div id="app" v-if="$store.state.appReady">
<navbar/>
<div id="content">
2020-11-26 23:09:59 +01:00
<router-view :key="$route.fullPath"/>
2020-11-26 01:30:15 +01:00
</div>
<div id="footer">
<footer-nav/>
2020-11-26 19:48:43 +01:00
</div>
2020-11-26 21:18:34 +01:00
<spotify-player/>
2020-11-26 01:30:15 +01:00
</div>
<div id="app-loader" v-else>
2020-11-26 04:44:55 +01:00
<big-chungus-loader id="loading-screen"/>
2020-11-25 16:19:00 +01:00
</div>
</template>
2020-11-26 01:30:15 +01:00
<script>
import FooterNav from "@/components/FooterNav";
import Navbar from "@/components/Navbar";
2020-11-26 04:44:55 +01:00
import BigChungusLoader from "@/components/BigChungusLoader";
2020-11-26 21:18:34 +01:00
import SpotifyPlayer from "@/components/SpotifyPlayer";
2020-11-26 01:30:15 +01:00
export default {
name: "Login",
components: {
Navbar,
FooterNav,
2020-11-26 21:18:34 +01:00
BigChungusLoader,
SpotifyPlayer
2020-11-26 01:30:15 +01:00
},
created() {
// The basic app is created... Currently showing a loading screen (as soon as mounted)
2020-11-26 03:18:28 +01:00
if (this.$api.haveToken) {
this.$api.getMyInfo().then(({name}) => {
this.$store.dispatch('storeUserData', name).then(() => {
2020-11-26 06:42:04 +01:00
if (this.$route.path === '/login') {
// TODO: ez igy nagyon gagyi solution
this.$router.push({name: "Collections"}).catch(() => {
});
}
this.$store.dispatch('setAppReady');
2020-11-26 03:18:28 +01:00
});
}).catch(({status, text}) => {
if (status === 401) {
this.$api.clearTokenFromLocalStorage();
this.$router.push('/login').catch(() => {});
this.$store.dispatch('setAppReady');
} else {
this.$showToast(text);
}
});
} else {
this.$router.push('/login').catch(() => {});
2020-11-26 01:30:15 +01:00
this.$store.dispatch('setAppReady');
2020-11-26 03:18:28 +01:00
}
2020-11-26 01:30:15 +01:00
}
}
</script>
2020-11-25 16:19:00 +01:00
<style>
2020-11-26 01:30:15 +01:00
#content {
margin-top: 70px;
margin-bottom: 20px;
2020-11-25 16:19:00 +01:00
}
2020-11-26 01:30:15 +01:00
#app {
display: flex;
flex-direction: column;
min-height: 100vh;
2020-11-25 16:19:00 +01:00
}
2020-11-26 01:30:15 +01:00
#footer {
padding: 1em;
margin-top: auto;
background: #E9ECEF;
2020-11-25 16:19:00 +01:00
}
2020-11-26 01:30:15 +01:00
#app-loader {
height: 100%;
2020-11-25 16:19:00 +01:00
}
2020-11-26 04:44:55 +01:00
#loading-screen {
margin: 45vh auto 0 auto;
}
2020-11-26 19:48:43 +01:00
#player-spacer {
2020-11-26 21:18:34 +01:00
height: 80px;
2020-11-26 19:48:43 +01:00
}
2020-11-26 21:18:34 +01:00
2020-11-25 16:19:00 +01:00
</style>