🎉 First commit, from couchbase generator, basic changes
not tested / updated yet
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<router-view></router-view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import { dispatchCheckLoggedIn, readIsLoggedIn } from '@/store/main/accessors';
|
||||
import { store } from '@/store';
|
||||
|
||||
const startRouteGuard = async (to, from, next) => {
|
||||
await dispatchCheckLoggedIn(store);
|
||||
if (readIsLoggedIn(store)) {
|
||||
if (to.path === '/login' || to.path === '/') {
|
||||
next('/main');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else if (readIsLoggedIn(store) === false) {
|
||||
if (to.path === '/' || (to.path as string).startsWith('/main')) {
|
||||
next('/login');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Component
|
||||
export default class Start extends Vue {
|
||||
public beforeRouteEnter(to, from, next) {
|
||||
startRouteGuard(to, from, next);
|
||||
}
|
||||
|
||||
public beforeRouteUpdate(to, from, next) {
|
||||
startRouteGuard(to, from, next);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user