修正了公司定制内容隔离
This commit is contained in:
1 parent
15bcb072f9
commit
917d4d1d28
7 files changed
+564
-63
No files matched your search
+17
-4
@@ -69,6 +69,20 @@ export const useUserStore = defineStore('user', () => {
|
||||
return result
|
||||
})
|
||||
|
||||
/** 目标路径是否在用户可见菜单树中(含子菜单;供路由守卫校验 URL 直达私有页) */
|
||||
function hasMenuPath(path: string): boolean {
|
||||
if (!path) return false
|
||||
const normalized = path.split('?')[0].replace(/\/+$/, '')
|
||||
const walk = (items: MenuItem[]): boolean => {
|
||||
for (const item of items) {
|
||||
if (item.Path && item.Path === normalized) return true
|
||||
if (item.Children?.length && walk(item.Children)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return walk(menus.value)
|
||||
}
|
||||
|
||||
// === 动作 ===
|
||||
/** 登录 */
|
||||
async function login(params: LoginParams): Promise<void> {
|
||||
@@ -135,10 +149,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
|
||||
/** 切换当前角色(身份切换) */
|
||||
async function switchRole(role: RoleItem | string): Promise<void> {
|
||||
// 传对象时取 RoleName(后端 SwitchRole 期望角色名)
|
||||
const roleName = typeof role === 'string' ? role : role.RoleName
|
||||
await apiSwitchRole(roleName)
|
||||
async function switchRole(role: RoleItem): Promise<void> {
|
||||
await apiSwitchRole(role)
|
||||
// 刷新用户信息和菜单(不同角色可能有不同菜单权限)
|
||||
await fetchUserInfo()
|
||||
await fetchMenus()
|
||||
@@ -198,6 +210,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
avatar,
|
||||
displayName,
|
||||
flatMenus,
|
||||
hasMenuPath,
|
||||
// 动作
|
||||
login,
|
||||
logout,
|
||||
|
||||
Reference in new issue
Block a user