杨磊
19 小时以前 2b8cbeec005f8ac6f65818da28fc239cf82fc716
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
 
// import VideoPlayer from "vue-video-player";
// Vue.use(VideoPlayer);
 
// 自定义配置
import config from "@/assets/js/config";
Vue.prototype.config = config;
 
// axios
import service from "@/plugin/axios";
Vue.prototype.request = service;
 
// ElementUI
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
ElementUI.Dialog.props.lockScroll.default = false;
Vue.use(ElementUI);
 
// 请求处理
import MG from "@/assets/js/middleGround/WebMiddleGroundApi";
Vue.prototype.MG = MG;
 
//工具类
import toolClass from "./assets/js/toolClass";
Vue.prototype.tool = toolClass;
 
// 时间处理
import moment from "moment";
Vue.prototype.moment = moment;
 
// 视频播放
import VideoPlayer from "vue-video-player";
require("video.js/dist/video-js.css");
require("vue-video-player/src/custom-theme.css");
Vue.use(VideoPlayer);
 
Vue.config.productionTip = false;
Vue.directive("dialogDrag", {});
 
// 路由判断登录 根据路由配置文件的参数
router.beforeEach((to, from, next) => {
  if (to.matched.some((record) => record.meta.authentication)) {
    // 判断该路由是否需要登录权限
    if (toolClass.getCookie(config.tokenKey)) {
      // 判断当前的token是否存在; 登录存入的token
      next();
    } else {
      next({
        path: "/login",
        query: {
          redirect: to.fullPath,
        }, // 将跳转的路由path作为参数,登录成功后跳转到该路由
      });
    }
  } else {
    next();
  }
});
 
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");