fix(system): 修复转码设置菜单误下发导致前端白屏

This commit is contained in:
Zhou Weidong committed 2026-11-09 10:32:46 +08:00
1 parent 3df66c2f4c
commit a36276051d
3 files changed
+28 -9

No files matched your search

@@ -137,15 +137,22 @@ public class MenuService {
List<MenuVO> 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;
}
+7 -1
View File
@@ -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,
@@ -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,