From 7302dadaba783c1346b47b40f533280d6c3e4fa2 Mon Sep 17 00:00:00 2001
From: liupengpeng <276665548@qq.com>
Date: 星期五, 10 二月 2023 15:34:31 +0800
Subject: [PATCH] 页面刷新还在本页面

---
 src/router/index.js |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index 66b4e9a..fb520a9 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -53,7 +53,15 @@
 const originalPush = VueRouter.prototype.push;
 
 VueRouter.prototype.push = function push(location) {
-  return originalPush.call(this, location).catch((err) => err);
+  const nowPage = sessionStorage.getItem('routerName')
+  const page = {
+    path: nowPage
+  }
+  if (page === location || location === '/') {
+    return originalPush.call(this, page).catch((err) => err);
+  } else {
+    return originalPush.call(this, location).catch((err) => err);
+  }
 };
 
 // 缇ょ粍绠$悊
@@ -462,6 +470,7 @@
 });
 //璺敱瀹堝崼
 router.beforeEach((to, from, next) => {
+  sessionStorage.setItem('routerName', to.path)
   next();
   if (to.matched.some((auth) => auth.meta.requireAuth)) {
     // 鑾峰彇token

--
Gitblit v1.9.3