修复了枢机协律相关页面被误删的问题
This commit is contained in:
1 parent
917d4d1d28
commit
41b982c7b5
2 files changed
+19
-12
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
# GERP 前端部署脚本:全量编译并同步产物到生产目录(TempLate/GERP)
|
||||
# GERP 前端部署脚本:全量编译并同步产物到生产目录(TempLate/GERP)
|
||||
#
|
||||
# 用途:
|
||||
# 1. 清理旧构建产物(dist 与 TempLate/GERP/assets),保证无 hash 残留
|
||||
|
||||
+18
-11
@@ -1,5 +1,6 @@
|
||||
import { nextTick } from 'vue'
|
||||
import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useProgressStore } from '@/stores/progress'
|
||||
import { useTabsStore } from '@/stores/tabs'
|
||||
@@ -298,6 +299,23 @@ let justOpenedNewTab = false
|
||||
router.beforeEach(async (to, _from, next) => {
|
||||
const tabsStore = useTabsStore()
|
||||
justOpenedNewTab = false
|
||||
|
||||
// === 菜单守卫(先于 addTab,避免受限页 tab 误入标签栏)===
|
||||
// menuGuarded 路由(后端菜单驱动的业务页)必须出现在当前用户可见菜单树中。
|
||||
// 用途:URL 直达私有页(如 #/private/CreateE/wallet)时,若菜单树不含该路径
|
||||
// (当前角色公司无权),直接跳回 dashboard,阻止访问公司私有业务。
|
||||
// 注意:不能 next({name:'NotFound'})——catch-all 保留原路径会再次触发守卫,
|
||||
// 造成导航无限循环 + tab 反复增删(栈溢出)。直接 next('/dashboard') 使
|
||||
// URL/tabs/路由三方一致,Dashboard 只挂载一次,无循环。
|
||||
// menus 未加载(首次进入/未登录)时放行,交由下方 restoreSession 处理登录与菜单。
|
||||
const userStore = useUserStore()
|
||||
if (to.meta.requiresAuth === true && to.meta.menuGuarded && userStore.menus.length > 0 && !userStore.hasMenuPath(to.path)) {
|
||||
useProgressStore().done()
|
||||
ElMessage.warning('无权访问该页面')
|
||||
next('/dashboard')
|
||||
return
|
||||
}
|
||||
|
||||
// 立即添加 tab:与 loading 同步出现,不等登录检查或组件加载
|
||||
// addTab 返回 true=新 tab(首次打开,需 loading),false=已存在(已缓存,瞬时切换)
|
||||
if (to.meta.requiresAuth === true && to.meta.title) {
|
||||
@@ -316,8 +334,6 @@ router.beforeEach(async (to, _from, next) => {
|
||||
useProgressStore().done()
|
||||
}
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 登录页:若已处于登录状态(内存态或 Cookie 会话可恢复),跳转面板
|
||||
if (to.name === 'Login') {
|
||||
if (userStore.isLoggedIn) {
|
||||
@@ -353,15 +369,6 @@ router.beforeEach(async (to, _from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 菜单守卫:menuGuarded 路由(后端菜单驱动的业务页)必须出现在当前用户可见菜单树中
|
||||
// 用途:URL 直达私有页(如 #/private/CreateE/wallet)时,若菜单树不含该路径(当前角色
|
||||
// 公司无权),则拦截到 404,避免绕过菜单过滤直接访问公司私有业务
|
||||
if (to.meta.menuGuarded && !userStore.hasMenuPath(to.path)) {
|
||||
tabsStore.removeTab(to.path)
|
||||
next({ name: 'NotFound', replace: true })
|
||||
return
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user