main.js 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * @Author: zouwenying
  3. * @Date: 2020-10-21 18:14:35
  4. * @LastEditTime: 2021-03-25 16:56:49
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 主入口js文件
  7. */
  8. import Vue from 'vue';
  9. import App from './App.vue';
  10. import router from './router';
  11. import Vuex from 'vuex';
  12. import ElementUI from 'element-ui';
  13. import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
  14. import '@utils/rem.js';
  15. import http from '@utils/http.js';
  16. import store from "./store/store.js"
  17. Vue.config.productionTip = false;
  18. Vue.use(Vuex);
  19. Vue.use(ElementUI, {
  20. size: 'small'
  21. });
  22. Vue.prototype.$http = http;
  23. //使用钩子函数对路由进行权限跳转
  24. router.beforeEach((to, from, next) => {
  25. if(!/^(\/|\/login)$/.test(to.path)) {
  26. // 判断是否登录
  27. if(localStorage.getItem('SC_token')) {
  28. next();
  29. } else {
  30. next('/');
  31. }
  32. } else {
  33. next();
  34. }
  35. });
  36. new Vue({
  37. router,
  38. store,
  39. render: h => h(App)
  40. }).$mount('#app');