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/TabsBar.jsx |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/rsf-admin/src/layout/TabsBar.jsx b/rsf-admin/src/layout/TabsBar.jsx
index bd77113..d441914 100644
--- a/rsf-admin/src/layout/TabsBar.jsx
+++ b/rsf-admin/src/layout/TabsBar.jsx
@@ -210,6 +210,15 @@
         const tabIndex = tabs.findIndex(tab => tab.path === tabPath);
         const newTabs = tabs.filter(tab => tab.path !== tabPath);
 
+        // 娓呴櫎 KeepAlive 缂撳瓨
+        if (window.__keepAliveController?.drop) {
+            try {
+                window.__keepAliveController.drop(tabPath);
+            } catch (e) {
+                console.warn('Failed to drop KeepAlive cache:', e);
+            }
+        }
+
         // 濡傛灉鍏抽棴鐨勬槸褰撳墠鏍囩椤碉紝闇�瑕佸鑸埌鍏朵粬鏍囩椤�
         if (location.pathname === tabPath || isSameResource(location.pathname, tabPath)) {
             // 浼樺厛瀵艰埅鍒板乏杈圭殑鏍囩椤碉紝鍚﹀垯瀵艰埅鍒板彸杈圭殑
@@ -231,6 +240,19 @@
     const handleCloseAll = () => {
         const dashboardTab = tabs.find(tab => tab.path === '/dashboard');
         const newTabs = [dashboardTab || { ...FIXED_TABS[0] }];
+
+        // 娓呴櫎鎵�鏈� KeepAlive 缂撳瓨锛坉ashboard 闄ゅ锛�
+        if (window.__keepAliveController?.drop) {
+            tabs.forEach(tab => {
+                if (tab.path !== '/dashboard') {
+                    try {
+                        window.__keepAliveController.drop(tab.path);
+                    } catch (e) {
+                        // ignore
+                    }
+                }
+            });
+        }
 
         saveTabs(newTabs);
         setTabs(newTabs);
@@ -297,19 +319,24 @@
                                 <span>{getTabLabel(tab)}</span>
                                 {tab.closable && (
                                     <Tooltip title="鍏抽棴">
-                                        <IconButton
-                                            size="small"
+                                        <Box
+                                            component="span"
                                             onClick={(e) => handleCloseTab(e, tab.path)}
                                             sx={{
+                                                display: 'inline-flex',
+                                                alignItems: 'center',
+                                                justifyContent: 'center',
                                                 p: 0.25,
                                                 ml: 0.5,
+                                                borderRadius: '50%',
+                                                cursor: 'pointer',
                                                 '&:hover': {
                                                     backgroundColor: 'rgba(0, 0, 0, 0.1)',
                                                 },
                                             }}
                                         >
                                             <CloseIcon sx={{ fontSize: 14 }} />
-                                        </IconButton>
+                                        </Box>
                                     </Tooltip>
                                 )}
                             </Box>

--
Gitblit v1.9.1