From d23eb6d53cb10362de2b961e77f45c27ec38196d Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 04 二月 2026 15:03:46 +0800
Subject: [PATCH] #页面持久化

---
 rsf-admin/src/layout/index.jsx |   58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/rsf-admin/src/layout/index.jsx b/rsf-admin/src/layout/index.jsx
index 40f6657..faec8e1 100644
--- a/rsf-admin/src/layout/index.jsx
+++ b/rsf-admin/src/layout/index.jsx
@@ -1,13 +1,53 @@
-import { Layout as RALayout, CheckForApplicationUpdate } from "react-admin";
+import { Layout as RALayout, CheckForApplicationUpdate, useSidebarState } from "react-admin";
+import { AliveScope } from 'react-activation';
 import AppBar from './AppBar';
-import { MyMenu } from './MyMenu'
+import { MyMenu } from './MyMenu';
+import TabsBar from './TabsBar';
+import KeepAliveWrapper from './KeepAliveWrapper';
+import { Box } from '@mui/material';
+
+const LayoutContent = ({ children }) => {
+  const [sidebarIsOpen] = useSidebarState();
+  const sidebarWidth = sidebarIsOpen ? 200 : 50;
+
+  return (
+    <RALayout
+      appBar={AppBar}
+      menu={MyMenu}
+      sx={{
+        '& .RaLayout-content': {
+          position: 'absolute',
+          left: `${sidebarWidth}px`,
+          overflowY: 'auto',
+          width: `calc(100% - ${sidebarWidth}px)`,
+          height: 'calc(100% - 86px)', // 鍑忓幓TabsBar鐨勯珮搴� (50px AppBar + 36px TabsBar)
+          top: '86px',
+          // 浼樺寲杩囨浮鍔ㄧ敾锛氱缉鐭椂闂达紝浣跨敤鏇村钩婊戠殑 easing
+          transition: 'left 150ms ease-out, width 150ms ease-out',
+          willChange: 'left, width', // GPU 鍔犻��
+        }
+      }}
+    >
+      <Box sx={{
+        position: 'fixed',
+        top: 48,
+        left: sidebarWidth + 5,
+        right: 0,
+        zIndex: 1100,
+        // 浼樺寲杩囨浮鍔ㄧ敾
+        transition: 'left 150ms ease-out',
+        willChange: 'left', // GPU 鍔犻��
+      }}>
+        <TabsBar />
+      </Box>
+      <KeepAliveWrapper>{children}</KeepAliveWrapper>
+      <CheckForApplicationUpdate />
+    </RALayout>
+  );
+};
 
 export const Layout = ({ children }) => (
-  <RALayout
-    appBar={AppBar}
-    menu={MyMenu}
-  >
-    {children}
-    <CheckForApplicationUpdate />
-  </RALayout>
+  <AliveScope max={10}>
+    <LayoutContent>{children}</LayoutContent>
+  </AliveScope>
 );

--
Gitblit v1.9.1