import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import "umy-ui/lib/theme-chalk/index.css"; // 引入样式
// import "element-ui/lib/theme-chalk/index.css";
import "../src/assets/css/theme/index.css"; //cac主题

Vue.use(ElementUI, {
  size: "small",
});

//引入Echarts;
import * as echarts from "echarts";
Vue.prototype.$echarts = echarts;

//字体自适应
import "./utils/rem";

//引入日期// 注册全局 moment
import moment from "moment";
Vue.prototype.$moment = moment;

//挂载弹出信息
import { message } from "@/utils/resetMessage";
Vue.prototype.$message = message;

Vue.config.productionTip = false;
//虚拟列表

import { UTable, UTableColumn } from "umy-ui";
Vue.component(UTable.name, UTable);
Vue.component(UTableColumn.name, UTableColumn);

//使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title} | 运维管理系统`;
  const token = localStorage.getItem("token");
  if (!token && to.path !== "/login") {
    next({
      path: "/login",
    });
  } else {
    next();
  }
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
