Skip to content

Instantly share code, notes, and snippets.

@xanf

xanf/Demo.js Secret

Created January 4, 2017 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xanf/771ad7fddfce688bbc29b1a0964e23f5 to your computer and use it in GitHub Desktop.
Save xanf/771ad7fddfce688bbc29b1a0964e23f5 to your computer and use it in GitHub Desktop.
Before hook in vue
/* @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