From eb5b81eebf0d2713d92c311f05a3d8f325a66d26 Mon Sep 17 00:00:00 2001 From: caorui <3165079241@qq.com> Date: Sat, 14 Jun 2025 10:20:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E6=89=93=E5=BC=80=E7=BC=93=E5=AD=98=E7=9A=84=E9=A1=B5?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/NewMenu/index.vue | 12 +++++----- src/permission.js | 31 +++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/layout/components/NewMenu/index.vue b/src/layout/components/NewMenu/index.vue index 2041f5a..f204656 100644 --- a/src/layout/components/NewMenu/index.vue +++ b/src/layout/components/NewMenu/index.vue @@ -201,9 +201,9 @@ export default { value: false, }); } - this.$router.push({ - path: url, - }); + // this.$router.push({ + // path: url, + // }); } else { this.$store.dispatch("settings/changeSetting", { key: "showTagsView", @@ -211,9 +211,9 @@ export default { }); setMenuNode("/index"); this.$store.commit("SET_CURRENT_MENU_NODE", "/index"); - this.$router.push({ - path: "/index", - }); + // this.$router.push({ + // path: "/index", + // }); } }, mounted() { diff --git a/src/permission.js b/src/permission.js index 4d29677..5b91e00 100644 --- a/src/permission.js +++ b/src/permission.js @@ -3,7 +3,7 @@ import store from './store' import { Message } from 'element-ui' import NProgress from 'nprogress' import 'nprogress/nprogress.css' -import { getToken, getCompanyId } from '@/utils/auth' +import { getToken, getCompanyId, getMenuNode,setMenuNode } from '@/utils/auth' import { isRelogin, getButtonLish } from '@/utils/request' import { authApi } from '@/api/apis/auth' import { getInfo } from '@/utils/auth' @@ -11,7 +11,8 @@ import { getInfo } from '@/utils/auth' NProgress.configure({ showSpinner: false }) - +//判断是否第一次进入页面 +let isFirst = true; const whiteList = [ '/login', '/test', @@ -27,6 +28,32 @@ const whiteList = [ ] router.beforeEach((to, from, next) => { + let reloaded = sessionStorage.getItem('reloaded') + //网站第一次进来逻辑 当from为空 + if (from.path === '/' && !reloaded && isFirst) { + isFirst = false + setMenuNode("/index"); + store.commit("SET_CURRENT_MENU_NODE", "/index"); + next({ + path: '/index', + }) + return + } + //网站刷新后逻辑 + if (reloaded === 'true' && !whiteList.includes(to.path)) { + sessionStorage.setItem('reloaded', 'false') + let url = getMenuNode(); + if (url) { + next({ + path: url, + }) + } else { + next({ + path: '/index', + }) + } + return + } NProgress.start() if (getToken()) { to.meta.title && store.dispatch('settings/setTitle', to.meta.title)