zhou zhou
3 天以前 d23eb6d53cb10362de2b961e77f45c27ec38196d
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 缓存(dashboard 除外)
        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>