fix: 超级管理000001本地兜底显示后台用户/角色管理菜单

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-26 02:21:19 +08:00
parent db386a0953
commit cacae6cfc7

View File

@@ -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 = '25';
const MENU_SESSION_VERSION = '26';
const DEFAULT_CLUB_ID = 'xq';
let menuAccessInflight = null;
@@ -142,6 +142,10 @@ const KEFU_MENU_ROWS = [
{ page_id: 'withdraw.audit', parent_id: 'withdraw', path: '/withdraw/audit', sort_order: 61, perm_codes: ['005bb'] },
{ page_id: 'withdraw.data', parent_id: 'withdraw', path: '/withdraw/data', sort_order: 63, perm_codes: ['005bb'] },
{ page_id: 'withdraw.settings', parent_id: 'withdraw', path: '/withdraw/settings', sort_order: 64, perm_codes: ['5500a', '5500b', '5500c'] },
// 管理员:超级管理 000001 可见(不靠 perm_codes
{ page_id: 'admin.role', parent_id: 'admin', path: '/admin/role', sort_order: 71, require_super: true },
{ page_id: 'admin.user', parent_id: 'admin', path: '/admin/user', sort_order: 74, require_super: true },
{ page_id: 'admin.operation-log', parent_id: 'admin', path: '/admin/operation-log', sort_order: 75, perm_codes: ['czrz666'] },
{ page_id: 'punishment', parent_id: '', path: '/punishment', sort_order: 80, perm_codes: ['005aa', '66693a', '66693b', '66693c', '66694c', '99933abs'] },
{ page_id: 'gongdan', parent_id: '', path: '/gongdan', sort_order: 81, perm_codes: ['gdck666', 'gdcl666'] },
{ page_id: 'product.list', parent_id: 'product', path: '/product/list', sort_order: 91, perm_codes: ['2200a'] },
@@ -157,6 +161,9 @@ const KEFU_MENU_ROWS = [
{ page_id: 'miniapp.leixing', parent_id: 'miniapp', path: '/miniapp/leixing', sort_order: 115, perm_codes: ['8080a'] },
{ page_id: 'miniapp.kaohe-tags', parent_id: 'miniapp', path: '/miniapp/kaohe-tags', sort_order: 116, perm_codes: ['8080a'] },
{ page_id: 'miniapp.dashou-exam', parent_id: 'miniapp', path: '/miniapp/dashou-exam', sort_order: 117, perm_codes: ['dsks666', '8080a'] },
{ page_id: 'miniapp.rank-reward', parent_id: 'miniapp', path: '/miniapp/rank-reward', sort_order: 118, perm_codes: ['phbj666', '8080a'] },
{ page_id: 'miniapp.recharge-copy', parent_id: 'miniapp', path: '/miniapp/recharge-copy', sort_order: 119, perm_codes: ['8080a'] },
{ page_id: 'miniapp.withdraw-settings', parent_id: 'miniapp', path: '/withdraw/settings', sort_order: 114, perm_codes: ['5500a', '5500b', '5500c'] },
{ page_id: 'shop.list', parent_id: 'shop', path: '/shop/list', sort_order: 121, perm_codes: ['999a', '999b', '999c', '999d', '999e'] },
{ page_id: 'shop.withdraw', parent_id: 'shop', path: '/shop/withdraw-apply', sort_order: 122, perm_codes: ['999a', '999b', '999c', '999d', '999e'] },
{ page_id: 'shop.products', parent_id: 'shop', path: '/shop/products', sort_order: 123, perm_codes: ['999a', '999b', '999c', '999d', '999e'] },
@@ -173,7 +180,7 @@ const KEFU_MENU_PARENT_IDS = {
withdraw: ['withdraw.audit', 'withdraw.data', 'withdraw.settings'],
product: ['product.list', 'product.type-zone', 'product.turntable', 'product.data', 'product.fake-orders'],
member: ['member.list', 'member.data'],
miniapp: ['miniapp.carousel', 'miniapp.assets', 'miniapp.popup', 'miniapp.leixing', 'miniapp.kaohe-tags', 'miniapp.dashou-exam', 'miniapp.withdraw-settings'],
miniapp: ['miniapp.carousel', 'miniapp.assets', 'miniapp.popup', 'miniapp.leixing', 'miniapp.kaohe-tags', 'miniapp.dashou-exam', 'miniapp.rank-reward', 'miniapp.recharge-copy', 'miniapp.withdraw-settings'],
shop: ['shop.list', 'shop.withdraw', 'shop.products'],
};
@@ -232,6 +239,17 @@ export function hasMerchantOrderPerm(access) {
export function canShowMenuPage(pageId) {
const access = getMenuAccess();
if (!access) return false;
const codes = access.permission_codes || [];
const hasSuper = !!access.is_super || codes.includes('000001');
// 本店超级管理:管理员分组 / 角色管理 / 后台用户(不依赖服务端是否漏 seed
if (
hasSuper &&
(pageId === 'admin' || pageId === 'admin.role' || pageId === 'admin.user')
) {
return true;
}
const ids = access?.visible_page_ids;
if (Array.isArray(ids) && ids.length > 0) {
if (ids.includes(pageId)) return true;
@@ -240,13 +258,17 @@ export function canShowMenuPage(pageId) {
// 兼容尚未 seed 的新菜单:本地已定义 + 用户有对应权限(或超管)
const row = KEFU_MENU_ROWS.find((r) => r.page_id === pageId);
if (!row) return false;
if (access.is_super) return true;
return pageAllowedByCodes(pageId, access.permission_codes || []);
if (access.is_super || hasSuper) {
if (row.require_super) return true;
}
return pageAllowedByCodes(pageId, codes);
}
if (access.is_super || access.is_group_admin) {
if (access.is_super || access.is_group_admin || hasSuper) {
const row = KEFU_MENU_ROWS.find((r) => r.page_id === pageId);
if (row?.require_super && hasSuper) return true;
return !!KEFU_MENU_ROWS.find((r) => r.page_id === pageId);
}
return pageAllowedByCodes(pageId, access.permission_codes || []);
return pageAllowedByCodes(pageId, codes);
}
/** 写入菜单缓存,并同步服务端校正后的 effective_club_id */
@@ -374,6 +396,7 @@ export const JITUAN_API = {
dashouList: '/jituan/houtai/kefuhqdslb',
guanshiList: '/jituan/houtai/hthqgslb',
shangjiaList: '/jituan/houtai/hqsjgllb',
shangjiaAdd: '/jituan/houtai/tjsj',
zuzhangList: '/jituan/houtai/hthqzzlb',
operationLog: '/jituan/houtai/hqczrz',
withdrawGet: '/jituan/houtai/hthqtxpz',
@@ -381,6 +404,8 @@ export const JITUAN_API = {
lunboList: '/jituan/houtai/lunbo-list',
lunboManage: '/jituan/houtai/lunbo-manage',
gonggao: '/jituan/houtai/gonggao',
rechargePageCopyGet: '/jituan/houtai/recharge-page-copy/get',
rechargePageCopySave: '/jituan/houtai/recharge-page-copy/save',
tupianList: '/jituan/houtai/tupian-list',
tupianManage: '/jituan/houtai/tupian-manage',
popupList: '/jituan/houtai/hthqtcxx',