import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import { getUser } from "./utils/tool";

Vue.use(ElementUI);

router.beforeEach((to, from, next) => {
  if (to.meta.title) document.title = to.meta.title;
  const traditional = /^\/traditional/g.test(to.path);
  const advertisement = /^\/advertisement/g.test(to.path);
  const Mobile = /^\/Mobile/g.test(to.path);
  const menuDiet1 = /^\/menuDiet/g.test(to.path);
  const Calendar = /^\/Calendar/g.test(to.path);
  if (traditional || advertisement || Mobile || menuDiet1 || Calendar) return next();
  if (!localStorage.user) {
    // apply 必须拿到oa用户数据
    getUser(() => next())
  } else next();
});

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