import router from "./routers";
import store from "./store";
import { Message } from "element-ui";

/**
 * 可在这里做鉴权
 */
router.beforeEach(async (to, from, next) => {
  // 限制页签的数量
  if (to.path.startsWith("/business")) {
    if (store.state.TagsView.visitedViews.length >= store.state.TagsView.visitedViewsMaxVal) {
      Message.warning(
        `页签数超过最大限制（${store.state.TagsView.visitedViewsMaxVal}），请先关闭其他页签！`
      );
      return;
    }
  }
  next();
});

router.afterEach(() => {});
