From a36276051dd417b6bfc303621a36afb45fd7dcf0 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Mon, 9 Nov 2026 10:32:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(system):=20=E4=BF=AE=E5=A4=8D=E8=BD=AC?= =?UTF-8?q?=E7=A0=81=E8=AE=BE=E7=BD=AE=E8=8F=9C=E5=8D=95=E8=AF=AF=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=E5=AF=BC=E8=87=B4=E5=89=8D=E7=AB=AF=E7=99=BD=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/MenuService.java | 21 ++++++++++++------- sql/data.sql | 8 ++++++- ...tch-2026-10-22-transcode-settings-menu.sql | 8 ++++++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/fruitshorts-module-system/src/main/java/com/fruitshorts/system/service/MenuService.java b/fruitshorts-module-system/src/main/java/com/fruitshorts/system/service/MenuService.java index 874fb57..9f8d217 100644 --- a/fruitshorts-module-system/src/main/java/com/fruitshorts/system/service/MenuService.java +++ b/fruitshorts-module-system/src/main/java/com/fruitshorts/system/service/MenuService.java @@ -137,15 +137,22 @@ public class MenuService { List roots = new ArrayList<>(); for (Menu menu : menus) { MenuVO node = nodes.get(menu.getId()); - MenuVO parent = menu.getParentId() == null ? null : nodes.get(menu.getParentId()); - if (parent == null) { + long parentId = menu.getParentId() == null ? 0L : menu.getParentId(); + if (parentId == 0L) { roots.add(node); - } else { - if (parent.getChildren() == null) { - parent.setChildren(new ArrayList<>()); - } - parent.getChildren().add(node); + continue; } + MenuVO parent = nodes.get(parentId); + if (parent == null) { + // 父级被权限/状态过滤掉时,不能把子菜单提升为一级路由: + // 子菜单的 routePath 是相对路径(如 transcode-settings), + // 提升后缺少前导 "/",前端注册动态路由会报错并白屏。 + continue; + } + if (parent.getChildren() == null) { + parent.setChildren(new ArrayList<>()); + } + parent.getChildren().add(node); } return roots; } diff --git a/sql/data.sql b/sql/data.sql index 972c339..82caf38 100644 --- a/sql/data.sql +++ b/sql/data.sql @@ -80,9 +80,15 @@ ON CONFLICT (id) DO UPDATE SET parent_id = EXCLUDED.parent_id, title = EXCLUDED. type = EXCLUDED.type, always_show = EXCLUDED.always_show, affix = EXCLUDED.affix, sort = EXCLUDED.sort; -- 转码设置菜单(挂在后台管理下,仅超级管理员可见) +-- 权限码必须独立:早期误用 episode:upload,会让具备上传权限的创作者角色 +-- 也下发这条子菜单,而父级「后台管理」不在其可见范围内,菜单被提升为一级路由 +-- 后因路径缺少前导 "/" 导致前端路由注册报错、白屏。 +INSERT INTO sys_permission (id, code, name, group_name, type, sort) +VALUES (50000105, 'system:transcode:settings', '转码设置', '后台管理', 'MENU', 7) +ON CONFLICT (code) DO NOTHING; INSERT INTO sys_menu (id, parent_id, title, route_path, route_name, component, redirect, icon, permission_code, type, always_show, affix, sort) VALUES - (35, 6, '转码设置', 'transcode-settings', 'transcode-settings', 'views/systemManagement/TranscodeSettingsView', '', '', 'episode:upload', 'MENU', 0, 0, 7) + (35, 6, '转码设置', 'transcode-settings', 'transcode-settings', 'views/systemManagement/TranscodeSettingsView', '', '', 'system:transcode:settings', 'MENU', 0, 0, 7) ON CONFLICT (id) DO UPDATE SET parent_id = EXCLUDED.parent_id, title = EXCLUDED.title, route_path = EXCLUDED.route_path, route_name = EXCLUDED.route_name, component = EXCLUDED.component, redirect = EXCLUDED.redirect, icon = EXCLUDED.icon, permission_code = EXCLUDED.permission_code, diff --git a/sql/patch-2026-10-22-transcode-settings-menu.sql b/sql/patch-2026-10-22-transcode-settings-menu.sql index c23133e..0b9fa57 100644 --- a/sql/patch-2026-10-22-transcode-settings-menu.sql +++ b/sql/patch-2026-10-22-transcode-settings-menu.sql @@ -1,11 +1,17 @@ -- Author: fruit.com.cn -- 后台「转码设置」独立菜单(幂等,仅提交文件,由发布流程执行) +-- 权限码独立于 episode:upload:否则创作者角色会误得该子菜单,父级不可见时 +-- 会被提升为一级相对路径路由,前端注册报错。 + +INSERT INTO sys_permission (id, code, name, group_name, type, sort) +VALUES (50000105, 'system:transcode:settings', '转码设置', '后台管理', 'MENU', 7) +ON CONFLICT (code) DO NOTHING; INSERT INTO sys_menu (id, parent_id, title, route_path, route_name, component, redirect, icon, permission_code, type, always_show, affix, sort) VALUES (35, 6, '转码设置', 'transcode-settings', 'transcode-settings', 'views/systemManagement/TranscodeSettingsView', '', '', - 'episode:upload', 'MENU', 0, 0, 7) + 'system:transcode:settings', 'MENU', 0, 0, 7) ON CONFLICT (id) DO UPDATE SET parent_id = EXCLUDED.parent_id, title = EXCLUDED.title, route_path = EXCLUDED.route_path, route_name = EXCLUDED.route_name, component = EXCLUDED.component, redirect = EXCLUDED.redirect, icon = EXCLUDED.icon,