新增主页,优化评查点结果一致性的显示效果

This commit is contained in:
2025-05-28 17:37:23 +08:00
parent 690d369f57
commit 08fb737cbf
10 changed files with 2596 additions and 458 deletions
+13 -3
View File
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Sidebar } from './Sidebar';
// import { Header } from './Header';
import { Breadcrumb } from './Breadcrumb';
import { useMatches } from '@remix-run/react';
import { useMatches, useLocation } from '@remix-run/react';
interface LayoutProps {
children: React.ReactNode;
@@ -11,7 +11,7 @@ interface LayoutProps {
// 添加一个接口表示路由handle可能包含的属性
interface RouteHandle {
hideBreadcrumb?: boolean;
[key: string]: any;
[key: string]: unknown;
}
interface Match {
@@ -23,9 +23,14 @@ interface Match {
export function Layout({ children }: LayoutProps) {
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const matches = useMatches() as Match[];
const location = useLocation();
// 检查当前路径是否应该隐藏侧边栏
const noLayoutPaths = ['/login', '/'];
const shouldHideSidebar = noLayoutPaths.includes(location.pathname);
// 检查当前路由是否应该隐藏默认面包屑
const shouldHideBreadcrumb = matches.some(match =>
const shouldHideBreadcrumb = shouldHideSidebar || matches.some(match =>
match.handle && match.handle.hideBreadcrumb === true
);
@@ -43,6 +48,11 @@ export function Layout({ children }: LayoutProps) {
localStorage.setItem('sidebarCollapsed', String(newState));
};
// 如果是无布局页面,只渲染内容
if (shouldHideSidebar) {
return <>{children}</>;
}
return (
<div className="layout-container">
<Sidebar
+8 -1
View File
@@ -19,10 +19,17 @@ export function Sidebar({ onToggle, collapsed }: SidebarProps) {
const [expandedMenus, setExpandedMenus] = useState<Record<string, boolean>>({});
const menuItems: MenuItem[] = [
{
id: 'contract-search',
title: '智能搜索',
path: '/contract-search',
hideBreadcrumb: true,
icon: 'ri-search-line'
},
{
id: 'home',
title: '系统概览',
path: '/',
path: '/home',
icon: 'ri-home-line'
},
{