From 41e263dee75b6f3524631d6a7d155a96c4b496e3 Mon Sep 17 00:00:00 2001 From: XingQue Date: Mon, 6 Jul 2026 18:40:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8F=9C=E5=8D=95=E4=B8=A5=E6=A0=BC?= =?UTF-8?q?=E6=8C=89=E6=9C=8D=E5=8A=A1=E7=AB=AFvisible=5Fpaths=EF=BC=8C?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=BF=B1=E4=B9=90=E9=83=A8=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- src/utils/club-context.js | 33 ++++++++++++--------------------- src/views/Layout.vue | 2 +- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/utils/club-context.js b/src/utils/club-context.js index c07342f..51e8374 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 = '15'; +const MENU_SESSION_VERSION = '16'; const DEFAULT_CLUB_ID = 'xq'; let menuAccessInflight = null; @@ -196,24 +196,17 @@ function pageAllowedByCodes(pageId, codes) { export function getEffectiveVisiblePaths(access = null) { const a = access || getMenuAccess(); const paths = a?.visible_paths; - if (Array.isArray(paths) && paths.length > 0) { - return paths; - } - return pathsFromPermissionCodes(a?.permission_codes || []); + return Array.isArray(paths) ? paths : []; } export function canShowMenuPage(pageId) { const access = getMenuAccess(); - if (shouldShowAllMenus(access)) return true; + if (!access) return false; const ids = access?.visible_page_ids; - if (Array.isArray(ids) && ids.length > 0) { - if (ids.includes(pageId)) return true; - const children = KEFU_MENU_PARENT_IDS[pageId]; - return children ? children.some((id) => ids.includes(id)) : false; - } - const codes = access?.permission_codes || []; - if (!codes.length) return false; - return pageAllowedByCodes(pageId, codes); + if (!Array.isArray(ids) || ids.length === 0) return false; + if (ids.includes(pageId)) return true; + const children = KEFU_MENU_PARENT_IDS[pageId]; + return children ? children.some((id) => ids.includes(id)) : false; } export function getFirstVisiblePath() { @@ -248,17 +241,15 @@ export function formatNoMenuAccessMessage(access) { } export function canSwitchClubByMenu() { + const ctx = getAdminClubContext(); + if (ctx?.can_switch_club) return true; const access = getMenuAccess(); - if (!access || !isMenuSessionFresh()) { - const ctx = getAdminClubContext(); - return !!ctx?.can_switch_club; - } - return !!access.can_switch_club; + return !!access?.can_switch_club; } -export async function ensureMenuAccess(fetcher) { +export async function ensureMenuAccess(fetcher, { force = false } = {}) { if (!localStorage.getItem('token')) return getMenuAccess(); - if (isMenuSessionFresh() && getMenuAccess()) { + if (!force && isMenuSessionFresh() && getMenuAccess()) { return getMenuAccess(); } if (!menuAccessInflight) { diff --git a/src/views/Layout.vue b/src/views/Layout.vue index 3eefd4a..6be6514 100644 --- a/src/views/Layout.vue +++ b/src/views/Layout.vue @@ -317,7 +317,7 @@ const loadMenuAccess = async () => { await ensureMenuAccess(async () => { const res = await request.get(JITUAN_API.menuAccess) return res.code === 0 ? res.data : null - }) + }, { force: true }) const data = getMenuAccess() if (data) { menuAccessState.value = data