-
-
Save xanf/771ad7fddfce688bbc29b1a0964e23f5 to your computer and use it in GitHub Desktop.
Before hook in vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
import type { NavigationGuard } from 'vue-router'; | |
import router from 'src/router'; | |
import store from 'src/store'; | |
import { IS_LOGGED_IN } from 'src/store/modules/user/user-getters'; | |
import Sidebar from './components/Sidebar/Sidebar.vue'; | |
import ChatSidebar from './components/ChatSidebar/ChatSidebar.vue'; | |
import TopBar from './components/TopBar/TopBar.vue'; | |
const beforeRouteEnter :NavigationGuard = (to, from, next) => { | |
if (!store.getters[IS_LOGGED_IN]) { | |
router.push({ path: '/login' }); | |
next(false); | |
} | |
next(); | |
}; | |
export default { | |
components: { | |
'bsm-top-bar': TopBar, | |
'bsm-left-sidebar': Sidebar, | |
'bsm-chat-sidebar': ChatSidebar, | |
}, | |
beforeRouteEnter, | |
mounted() { | |
// Init template logic when layout is ready & mounted | |
// eslint-disable-next-line global-require | |
require('assets/theme/js/jquery.app'); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment