fix: 修正操作手冊選單顯示邏輯並強化內容
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 54s

This commit is contained in:
2026-02-13 15:55:56 +08:00
parent 8207e6fe94
commit d017d7e5e0
2 changed files with 19 additions and 6 deletions

View File

@@ -309,19 +309,23 @@ export default function AuthenticatedLayout({
const menuItems = useMemo(() => {
return allMenuItems
.map((item) => {
// 如果有子項目,先過濾子項目
// 如果有子項目
if (item.children && item.children.length > 0) {
const filteredChildren = item.children.filter(hasPermissionForItem);
// 若所有子項目都無權限,則隱藏整個群組
if (filteredChildren.length === 0) return null;
return { ...item, children: filteredChildren };
// 若有子項目符合權限,則顯示該群組(群組本身的權限僅作為額外過濾)
if (filteredChildren.length > 0) {
return { ...item, children: filteredChildren };
}
return null;
}
// 無子項目的單一選單,直接檢查權限
if (!hasPermissionForItem(item)) return null;
return item;
})
.filter((item): item is MenuItem => item !== null);
}, [can, canAny]);
}, [allMenuItems, hasPermissionForItem]);
// 初始化狀態:優先讀取 localStorage
const [expandedItems, setExpandedItems] = useState<string[]>(() => {