// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import VueRouter from "vue-router";

import Vant from "vant";
import "vant/lib/index.css";
import { Toast } from "vant";

// import Vconsole from "vconsole";
// let vConsole = new Vconsole();
// Vue.use(vConsole);
Vue.use(Toast);
Vue.use(Vant);
Vue.config.productionTip = false;
import axios from "./utils/common.js";
Vue.prototype.$axios = axios;
if (sessionStorage.getItem("token")) {
    axios.defaults.headers.common["token"] = sessionStorage.getItem("token");
}
import uploadFile from "./utils/common.js";
Vue.prototype.$uploadFile = uploadFile;

// sessionStorage.setItem("token", "89cf0730-59e2-4627-baa3-a4451454794b");
import VueClipboard from "vue-clipboard2";
Vue.use(VueClipboard);
router.beforeEach((to, from, next) => {
    const token = sessionStorage.getItem("token");
    // localStorage.setItem("selnav", '');
    // console.log("我是token", token);

    if (!token) {
        if (to.path === "/login") {
            next();
        } else {
            sessionStorage.setItem("now_url", to.fullPath); //当前页url与参数放入缓存
            next("/login");
        }
    } else {
        next();
    }
});

/* eslint-disable no-new */
new Vue({
    el: "#app",
    router,
    components: { App },
    template: "<App/>"
});