You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import NProgress from 'nprogress'; // progress bar
|
|
|
|
import 'nprogress/nprogress.css'; // progress bar style
|
|
|
|
import { RouteLocationNormalized } from 'vue-router';
|
|
|
|
import getPageTitle from '@/utils/getPageTitle';
|
|
|
|
import { getAccessToken } from '@/utils/auth'; // get token from cookie
|
|
|
|
import router from './router';
|
|
|
|
|
|
|
|
NProgress.configure({ showSpinner: false }); // NProgress Configuration
|
|
|
|
|
|
|
|
const LOGIN_PATH = '/login';
|
|
|
|
|
|
|
|
router.beforeEach(async (to: RouteLocationNormalized) => {
|
|
|
|
NProgress.start();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
router.afterEach((to: RouteLocationNormalized) => {
|
|
|
|
// set page title
|
|
|
|
document.title = getPageTitle(to.meta.title);
|
|
|
|
// finish progress bar
|
|
|
|
NProgress.done();
|
|
|
|
});
|
|
|
|
|
|
|
|
router.onError((error, to) => {
|
|
|
|
if (error.message.includes('Failed to fetch dynamically imported module')) {
|
|
|
|
window.location = to.fullPath;
|
|
|
|
}
|
|
|
|
});
|