|
@@ -4,6 +4,27 @@ import { userStore } from '@/store/userInfo'
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
+// 重写push||replace方法
|
|
|
+// 先将原始push方法复制
|
|
|
+let originPush=VueRouter.prototype.push
|
|
|
+let originReplace=VueRouter.prototype.replace
|
|
|
+// 重写
|
|
|
+VueRouter.prototype.push=function(location,res,rej){
|
|
|
+ // 如果传了成功,失败的回调
|
|
|
+ if(res&&rej){
|
|
|
+ originPush.call(this,location,res,rej)
|
|
|
+ }else{
|
|
|
+ originPush.call(this,location,()=>{},()=>{})
|
|
|
+ }
|
|
|
+}
|
|
|
+VueRouter.prototype.replace=function(location,res,rej){
|
|
|
+ if (res && rej) {
|
|
|
+ originReplace.call(this, location, res, rej)
|
|
|
+ } else {
|
|
|
+ originReplace.call(this, location, () => { }, () => { })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const router = new VueRouter({
|
|
|
mode: "history",
|
|
|
base: import.meta.env.BASE_URL,
|
|
@@ -132,4 +153,5 @@ router.beforeEach((to, from, next) => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+
|
|
|
export default router
|