alibaba / ice

🚀 ice.js: The Progressive App Framework Based On React(基于 React 的渐进式应用框架)
https://ice.work
MIT License
17.81k stars 2.09k forks source link

当有多级别layout,如何使某层的页面只是用最近的layout #6815

Closed Bingjiajia closed 4 months ago

Bingjiajia commented 4 months ago

Describe the bug

现在有两层layout,第二层layout下面有多个页面,对应了多个url,url是两级的或者三级比如:/backend/overview /backend/setting/project,那么如何在第一层layout过滤掉所有的/backend开头的url,让其只使用第二层级的layout

Expected behavior

期望第一层或者某层的layout可以过滤到子layout的下的页面 // 过滤未套用该布局的页面 if (['/login', '/register', '/backend'].includes(location.pathname)) { return <Outlet />; }

Actual behavior

No response

Version of ice.js

ice3

Content of build.json or ice.config.mts

No response

Additional context

No response

ClarkXia commented 4 months ago

期望第一层或者某层的layout可以过滤到子layout的下的页面 // 过滤未套用该布局的页面 if (['/login', '/register', '/backend'].includes(location.pathname)) { return <Outlet />; }

现在通过这种方式有什么障碍吗

ClarkXia commented 4 months ago

默认情况下多级 layout 均会生效,如果希望只用最近的 layout,在其他 layout 里通过 pathname 过滤。或者直接通过 defineRoute 的方式直接定义