添加合同和卷宗数据隔离
This commit is contained in:
@@ -5,6 +5,16 @@ import { Breadcrumb } from './Breadcrumb';
|
||||
import { useMatches, useLocation } from '@remix-run/react';
|
||||
import type { UserRole } from '~/root';
|
||||
|
||||
// 定义应用模块类型
|
||||
type AppModule = 'contract' | 'record' | 'model';
|
||||
|
||||
// 应用模块与reviewType的映射
|
||||
const REVIEW_TYPE_TO_APP: Record<string, AppModule> = {
|
||||
'contract': 'contract', // 合同管理
|
||||
'record': 'record', // 案卷智能评查
|
||||
'model': 'model' // 智慧法务大模型
|
||||
};
|
||||
|
||||
interface LayoutProps {
|
||||
children: React.ReactNode;
|
||||
userRole?: UserRole;
|
||||
@@ -24,6 +34,7 @@ interface Match {
|
||||
|
||||
export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||
const [selectedApp, setSelectedApp] = useState<AppModule>('contract');
|
||||
const matches = useMatches() as Match[];
|
||||
const location = useLocation();
|
||||
|
||||
@@ -36,12 +47,25 @@ export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
match.handle && match.handle.hideBreadcrumb === true
|
||||
);
|
||||
|
||||
// 从本地存储中获取侧边栏状态
|
||||
// 从sessionStorage中获取侧边栏状态和reviewType
|
||||
useEffect(() => {
|
||||
// 从localStorage获取侧边栏状态
|
||||
const savedState = localStorage.getItem('sidebarCollapsed');
|
||||
if (savedState) {
|
||||
setSidebarCollapsed(savedState === 'true');
|
||||
}
|
||||
|
||||
// 从sessionStorage获取reviewType并设置对应的应用模块
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
const reviewType = sessionStorage.getItem('reviewType');
|
||||
if (reviewType && REVIEW_TYPE_TO_APP[reviewType]) {
|
||||
setSelectedApp(REVIEW_TYPE_TO_APP[reviewType]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取reviewType失败:', error);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const toggleSidebar = () => {
|
||||
@@ -50,6 +74,12 @@ export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
localStorage.setItem('sidebarCollapsed', String(newState));
|
||||
};
|
||||
|
||||
// 切换应用模块
|
||||
// const changeAppModule = (appId: AppModule) => {
|
||||
// setSelectedApp(appId);
|
||||
// localStorage.setItem('selectedApp', appId);
|
||||
// };
|
||||
|
||||
// 如果是无布局页面,只渲染内容
|
||||
if (shouldHideSidebar) {
|
||||
return <>{children}</>;
|
||||
@@ -61,10 +91,26 @@ export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
collapsed={sidebarCollapsed}
|
||||
onToggle={toggleSidebar}
|
||||
userRole={userRole}
|
||||
selectedApp={selectedApp}
|
||||
/>
|
||||
|
||||
<div className={`main-content ${sidebarCollapsed ? 'sidebar-collapsed' : ''}`}>
|
||||
{/* <Header username="系统管理员" /> */}
|
||||
{/* 应用模块选择器 */}
|
||||
{/* <div className="app-module-selector py-2 px-4 border-b border-gray-100 flex items-center">
|
||||
{APP_MODULES.map(app => (
|
||||
<button
|
||||
key={app.id}
|
||||
onClick={() => changeAppModule(app.id as AppModule)}
|
||||
className={`app-module-btn mr-4 py-2 px-4 rounded-md flex items-center ${
|
||||
selectedApp === app.id ? 'bg-green-50 text-green-700 border border-green-200' : 'hover:bg-gray-50'
|
||||
}`}
|
||||
>
|
||||
<i className={`${app.icon} mr-2`}></i>
|
||||
<span>{app.name}</span>
|
||||
</button>
|
||||
))}
|
||||
</div> */}
|
||||
|
||||
<div className="content-container">
|
||||
{!shouldHideBreadcrumb && <Breadcrumb />}
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user