From 5b89e1b3c8c8969abb19c3d103b8ffebd81fed98 Mon Sep 17 00:00:00 2001 From: XingQue Date: Mon, 6 Jul 2026 18:28:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0=E6=9D=83=E9=99=90=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=B1=95=E7=A4=BA=E5=85=A8=E9=83=A8=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=B8=8E=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- src/router/index.js | 10 +++++++--- src/utils/club-context.js | 9 +++++---- src/views/admin/AdminUser.vue | 9 +++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index cda4949..4dd254f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -324,7 +324,7 @@ const router = createRouter({ /** 详情页等子路由:父模块在 visible_paths 中即允许访问 */ function isRouteAllowed(path, visiblePaths) { - if (!visiblePaths?.length) return true + if (!visiblePaths?.length) return false if (visiblePaths.some((p) => p && (path === p || path.startsWith(`${p}/`)))) { return true } @@ -372,12 +372,16 @@ router.beforeEach(async (to, from, next) => { const access = getMenuAccess() - if (!isMenuSessionFresh()) { + if (to.path === '/welcome') { next() return } - if (to.path === '/welcome') { + if (!access || !isMenuSessionFresh()) { + if (to.path !== '/welcome') { + next('/welcome') + return + } next() return } diff --git a/src/utils/club-context.js b/src/utils/club-context.js index c944eab..9d6bf46 100644 --- a/src/utils/club-context.js +++ b/src/utils/club-context.js @@ -3,7 +3,7 @@ const CLUB_SCOPE_KEY = 'admin_club_scope'; const CLUB_CONTEXT_KEY = 'admin_club_context'; const MENU_ACCESS_KEY = 'kefu_menu_access'; const MENU_SESSION_KEY = 'kefu_menu_session_v'; -const MENU_SESSION_VERSION = '12'; +const MENU_SESSION_VERSION = '13'; const DEFAULT_CLUB_ID = 'xq'; let menuAccessInflight = null; @@ -41,6 +41,8 @@ export function mergeServerClubContext(serverCtx) { } } else if (prevScope === 'all' && serverCtx.is_group_admin) { scopeKey = 'all'; + } else if (!allowedIds.has(clubId) && allowedIds.size > 0) { + clubId = serverCtx.club_id || [...allowedIds][0] || DEFAULT_CLUB_ID; } const merged = { @@ -102,8 +104,7 @@ export function isMenuSessionFresh() { } export function shouldShowAllMenus(access) { - if (!isMenuSessionFresh()) return true; - if (!access) return true; + if (!access) return false; if (Array.isArray(access.visible_page_ids) && access.visible_page_ids.length > 0) { return false; } @@ -113,7 +114,7 @@ export function shouldShowAllMenus(access) { if (Array.isArray(access.permission_codes) && access.permission_codes.length > 0) { return false; } - return true; + return false; } /** ??? kefu_menu_definitions ???visible_paths ???? permission_codes ?? */ diff --git a/src/views/admin/AdminUser.vue b/src/views/admin/AdminUser.vue index 9edeac8..5f09616 100644 --- a/src/views/admin/AdminUser.vue +++ b/src/views/admin/AdminUser.vue @@ -526,10 +526,11 @@ const clubRoleBlocks = computed(() => { }) const visibleClubRoleBlocks = computed(() => { - if (canManageClubAssignments.value) { - return clubRoleBlocks.value - } - return clubRoleBlocks.value.filter((b) => canManageRolesForClub(b.club_id)) + return clubRoleBlocks.value.filter((b) => { + const cid = b.club_id || '' + if (canManageClubAssignments.value) return true + return manageableClubIds.value.includes(cid) + }) }) // 添加用户弹窗