mirror of
https://github.com/langgenius/dify.git
synced 2026-03-29 18:09:57 +08:00
Problems: - Identical useEffect + router.replace guard for dataset_operator role duplicated across 4 leaf components (tools/page, appDetail/layout, explore/index, apps/list), violating DRY and risking permission gaps when new routes are added - datasets/list had a redundant role guard already covered by datasets/layout - datasets/layout used useEffect for redirect, causing content flash - useEffect-based guards render unauthorized content before redirect - explore/index used useState + useEffect to derive hasEditPermission, an unnecessary render cycle (rerender-derived-state-no-effect) - apps/list imported 6 @remixicon/react components instead of using Tailwind CSS icon classes, inflating JS bundle - apps/list contained unused validTabs Set (dead code) Solutions: - Create RoleRouteGuard component at (commonLayout)/layout.tsx level that synchronously checks role during render and returns null before children mount, preventing content flash - Remove all 5 duplicated useEffect guards from leaf components - Replace datasets/layout useEffect guard with synchronous render check - Derive hasEditPermission directly during render in explore/index - Replace @remixicon/react imports with i-ri-* CSS icon classes - Remove dead code (validTabs)