chen.lin
9 小时以前 da15785661f7832cdcb78fb6504752c0cb385e63
rsf-admin/src/layout/TabsBar.jsx
@@ -405,24 +405,24 @@
    };
    // 判断指定标签页是否可以关闭左侧标签
    // const canCloseLeftForTab = (tabPath) => {
    //     const tabIndex = tabs.findIndex(tab => tab.path === tabPath);
    //     if (tabIndex <= 0) {
    //         return false; // 没有左侧标签或这是第一个标签
    //     }
    //     // 检查左侧是否有可关闭的标签(排除dashboard)
    //     return tabs.slice(0, tabIndex).some(tab => tab.closable);
    // };
    const canCloseLeftForTab = (tabPath) => {
        const tabIndex = tabs.findIndex(tab => tab.path === tabPath || isSameResource(tab.path, tabPath));
        if (tabIndex <= 0) {
            return false; // 没有左侧标签或这是第一个标签
        }
        // 检查左侧是否有可关闭的标签(排除dashboard)
        return tabs.slice(0, tabIndex).some(tab => tab.closable);
    };
    // 判断指定标签页是否可以关闭右侧标签
    // const canCloseRightForTab = (tabPath) => {
    //     const tabIndex = tabs.findIndex(tab => tab.path === tabPath);
    //     if (tabIndex < 0 || tabIndex >= tabs.length - 1) {
    //         return false; // 没有右侧标签或这是最后一个标签
    //     }
    //     // 检查右侧是否有可关闭的标签
    //     return tabs.slice(tabIndex + 1).some(tab => tab.closable);
    // };
    const canCloseRightForTab = (tabPath) => {
        const tabIndex = tabs.findIndex(tab => tab.path === tabPath || isSameResource(tab.path, tabPath));
        if (tabIndex < 0 || tabIndex >= tabs.length - 1) {
            return false; // 没有右侧标签或这是最后一个标签
        }
        // 检查右侧是否有可关闭的标签
        return tabs.slice(tabIndex + 1).some(tab => tab.closable);
    };
    return (
        <Box
@@ -481,16 +481,18 @@
                                                display: 'inline-flex',
                                                alignItems: 'center',
                                                justifyContent: 'center',
                                                p: 0.25,
                                                p: 0.35,
                                                ml: 0.5,
                                                borderRadius: '50%',
                                                cursor: 'pointer',
                                                color: 'inherit',
                                                '&:hover': {
                                                    backgroundColor: 'rgba(0, 0, 0, 0.1)',
                                                    color: '#d32f2f',
                                                },
                                            }}
                                        >
                                            <CloseIcon sx={{ fontSize: 14 }} />
                                            <CloseIcon sx={{ fontSize: 16 }} />
                                        </Box>
                                    </Tooltip>
                                )}
@@ -562,6 +564,7 @@
                    sx: { py: 0 },
                }}
            >
                {/* 关闭当前标签
                {contextMenuTab && contextMenuTab.closable && (
                    <MenuItem
                        onClick={handleCloseCurrentTab}
@@ -575,13 +578,30 @@
                        {t('ra.action.close', '关闭当前标签')}
                    </MenuItem>
                )}
                */}
                {contextMenuTab && canCloseLeftForTab(contextMenuTab.path) && (
                    <MenuItem onClick={handleCloseLeftTabs}>
                    <MenuItem
                        onClick={handleCloseLeftTabs}
                        sx={{
                            fontSize: '0.8125rem',
                            py: 0.75,
                            px: 1.5,
                            minHeight: 'auto',
                        }}
                    >
                        {t('ra.action.closeLeft', '关闭左侧标签')}
                    </MenuItem>
                )}
                {contextMenuTab && canCloseRightForTab(contextMenuTab.path) && (
                    <MenuItem onClick={handleCloseRightTabs}>
                    <MenuItem
                        onClick={handleCloseRightTabs}
                        sx={{
                            fontSize: '0.8125rem',
                            py: 0.75,
                            px: 1.5,
                            minHeight: 'auto',
                        }}
                    >
                        {t('ra.action.closeRight', '关闭右侧标签')}
                    </MenuItem>
                )}