import Vue from "vue";
|
import App from "./App.vue";
|
import router from "./router";
|
import store from "./store";
|
|
// 自定义配置
|
|
import "@/assets/iconfont/iconfont.css";
|
import config from "@/assets/js/config";
|
Vue.prototype.config = config;
|
|
// axios
|
import service from "@/plugin/axios";
|
Vue.prototype.request = service;
|
|
import {
|
setNewView
|
} from "@/assets/js/userAction"
|
Vue.prototype.setNewView = setNewView;
|
// ElementUI
|
import ElementUI from "element-ui";
|
import "@/assets/theme/index.css";
|
Vue.use(ElementUI);
|
|
import {
|
tokenKey
|
} from "@/assets/js/config";
|
//工具类
|
import tool from "@/assets/js/toolClass";
|
Vue.prototype.tool = tool;
|
|
// 路由判断登录 根据路由配置文件的参数
|
router.beforeEach((to, from, next) => {
|
if (to.matched.some((record) => record.meta.authentication)) {
|
// 判断该路由是否需要登录权限
|
if (tool.getCookie(tokenKey)) {
|
// 判断当前的token是否存在 ; 登录存入的token
|
if (to.path === "/login") {
|
tool.delCookie(tokenKey);
|
// removeToken();
|
window.location.reload();
|
} else {
|
next();
|
}
|
} else {
|
next({
|
path: "/login",
|
query: {
|
redirect: to.fullPath
|
}, // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
});
|
}
|
} else {
|
next();
|
}
|
});
|
// 请求处理
|
import MG from "@/assets/js/middleGround/WebMiddleGroundApi";
|
Vue.prototype.MG = MG;
|
|
// 时间处理
|
import moment from "moment";
|
Vue.prototype.moment = moment;
|
|
Vue.config.productionTip = false;
|
|
new Vue({
|
router,
|
store,
|
render: (h) => h(App),
|
}).$mount("#app");
|