permission.js 499 B

123456789101112131415161718192021
  1. import router from "@/router";
  2. // 进度条
  3. import NProgress from "nprogress";
  4. // 进度条样式
  5. import "nprogress/nprogress.css";
  6. NProgress.configure({ showSpinner: false });
  7. // 注册路由跳转的权限控制
  8. router.beforeEach(async (to, from, next) => {
  9. let title = "";
  10. const isCorrect = document.title.includes("test");
  11. title = isCorrect ? document.title : "京铁学堂";
  12. document.title = title;
  13. NProgress.start();
  14. next();
  15. });
  16. router.afterEach(() => {
  17. NProgress.done();
  18. });