feat: 初步完成评查详情页面的work文档和pdf文档的加载的页面三栏设计的重构。
This commit is contained in:
@@ -15,6 +15,8 @@ interface LayoutProps {
|
||||
// 添加一个接口表示路由handle可能包含的属性
|
||||
interface RouteHandle {
|
||||
hideBreadcrumb?: boolean;
|
||||
collapseSidebar?: boolean;
|
||||
noPadding?: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -42,6 +44,11 @@ export function Layout({ children, userRole = 'developer' as UserRole, frontendJ
|
||||
match.handle && match.handle.hideBreadcrumb === true
|
||||
);
|
||||
|
||||
// 检查当前路由是否要求无 padding
|
||||
const shouldNoPadding = matches.some(match =>
|
||||
match.handle && match.handle.noPadding === true
|
||||
);
|
||||
|
||||
// 从 localStorage 读取用户信息和 JWT 作为备用方案
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
@@ -80,16 +87,23 @@ export function Layout({ children, userRole = 'developer' as UserRole, frontendJ
|
||||
// 检查是否为移动端
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
|
||||
// 从localStorage获取侧边栏状态
|
||||
const savedState = localStorage.getItem('sidebarCollapsed');
|
||||
// 检查当前路由是否要求收缩侧边栏
|
||||
const shouldCollapse = matches.some(match =>
|
||||
match.handle && match.handle.collapseSidebar === true
|
||||
);
|
||||
|
||||
// 移动端默认收起,桌面端使用保存的状态
|
||||
if (isMobile) {
|
||||
setSidebarCollapsed(true);
|
||||
} else if (savedState) {
|
||||
setSidebarCollapsed(savedState === 'true');
|
||||
} else if (shouldCollapse) {
|
||||
setSidebarCollapsed(true);
|
||||
} else {
|
||||
// 从localStorage获取侧边栏状态
|
||||
const savedState = localStorage.getItem('sidebarCollapsed');
|
||||
if (savedState) {
|
||||
setSidebarCollapsed(savedState === 'true');
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
}, [location.pathname]);
|
||||
|
||||
const toggleSidebar = () => {
|
||||
const newState = !sidebarCollapsed;
|
||||
@@ -135,7 +149,7 @@ export function Layout({ children, userRole = 'developer' as UserRole, frontendJ
|
||||
))}
|
||||
</div> */}
|
||||
|
||||
<div className="content-container">
|
||||
<div className={`content-container${shouldNoPadding ? ' !p-0' : ''}`}>
|
||||
{!shouldHideBreadcrumb && <Breadcrumb />}
|
||||
{children}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user