permission.js 557 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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(() => {});