/* eslint-disable @typescript-eslint/promise-function-async */ /* eslint-disable @typescript-eslint/explicit-function-return-type */ import VueRouter , {RawLocation } from 'vue-router' import Vue from 'vue' import { setTitle, qoeHook } from './hooks' import routerConfig from './router' Vue.use(VueRouter) // error -> Avoided redundant navigation to current location: //避免重复点击 临时解决方案 const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location : RawLocation ) { return ( originalPush.call(this, location) as any ).catch( ( err : ErrorHandler) => err) } const router = new VueRouter({ routes: routerConfig }) router.beforeEach(qoeHook) // router.beforeEach(setTitle) const originalReplace = VueRouter.prototype.replace; VueRouter.prototype.replace = function replace(location:any ) { return ( originalReplace.call(this, location) as any ).catch( (err: any) => err); }; export default router type ErrorHandler = (err: Error) => void