main.js 660 B

123456789101112131415161718192021222324252627282930313233
  1. import Vue from 'vue';
  2. import App from './App.vue';
  3. import ElementUI from 'element-ui';
  4. import 'element-ui/lib/theme-chalk/index.css';
  5. // 路由跳转进度条
  6. import NProgress from 'nprogress';
  7. import 'nprogress/nprogress.css';
  8. import './index.css';
  9. import router from './router/router';
  10. import store from './store';
  11. Vue.use(ElementUI);
  12. router.beforeEach((to, from, next) => {
  13. NProgress.start();
  14. if (to.path !== '/login' && !localStorage.getItem('token')) {
  15. NProgress.done()
  16. return next('/login')
  17. }
  18. next()
  19. });
  20. router.afterEach(transition => {
  21. NProgress.done();
  22. });
  23. new Vue({
  24. el: '#app',
  25. router,
  26. store,
  27. render: (h) => h(App),
  28. })