6
0

main.js 531 B

123456789101112131415161718192021222324252627282930
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './routes'
  4. import store from './store'
  5. import vuetify from './plugins/vuetify'
  6. Vue.config.productionTip = false
  7. store.commit('initFromLocalstore');
  8. router.beforeEach((to, from, next) => {
  9. if (to.matched.some(record => record.meta.requiresLogin)) {
  10. if (!store.getters.loggedIn) {
  11. next({ name: 'login' })
  12. } else {
  13. next()
  14. }
  15. } else {
  16. next()
  17. }
  18. })
  19. new Vue({
  20. router,
  21. store,
  22. vuetify,
  23. render: h => h(App)
  24. }).$mount('#app')