fix: 修复状态控制按钮显示逻辑,解决getControlButtonProps返回null时按钮不显示的问题
1 files modified
85 ■■■■ changed files
web-app/src/components/dashboard/TabContainer.jsx 85 ●●●● patch | view | raw | blame | history
web-app/src/components/dashboard/TabContainer.jsx
@@ -510,46 +510,51 @@
      </div>
      {/* 状态控制按钮区域 */}
      {shouldShowControlButton() && (
        <div style={{
          marginTop: 20,
          paddingTop: 15,
          borderTop: '1px solid #e9ecef',
          display: 'flex',
          justifyContent: 'center',
          gap: 12
        }}>
          <button
            onClick={() => handleControlButtonClick(getControlButtonProps().action)}
            disabled={controlLoading}
            style={{
              padding: '10px 20px',
              borderRadius: 'var(--border-radius)',
              fontWeight: 600,
              fontSize: '0.9rem',
              cursor: controlLoading ? 'not-allowed' : 'pointer',
              display: 'flex',
              alignItems: 'center',
              gap: 6,
              border: 'none',
              ...(getControlButtonProps().style === 'terminate' ? {
                background: '#1A6FB8',
                color: 'white',
              } : {
                background: '#52c41a',
                color: 'white',
              }),
              opacity: controlLoading ? 0.6 : 1,
            }}
          >
            {controlLoading ? (
              <><i className="fas fa-spinner fa-spin"></i>处理中...</>
            ) : (
              <><i className="fas fa-pause-circle"></i>{getControlButtonProps().text}</>
            )}
          </button>
        </div>
      )}
      {shouldShowControlButton() && (() => {
        const buttonProps = getControlButtonProps();
        if (!buttonProps) return null;
        return (
          <div style={{
            marginTop: 20,
            paddingTop: 15,
            borderTop: '1px solid #e9ecef',
            display: 'flex',
            justifyContent: 'center',
            gap: 12
          }}>
            <button
              onClick={() => handleControlButtonClick(buttonProps.action)}
              disabled={controlLoading}
              style={{
                padding: '10px 20px',
                borderRadius: 'var(--border-radius)',
                fontWeight: 600,
                fontSize: '0.9rem',
                cursor: controlLoading ? 'not-allowed' : 'pointer',
                display: 'flex',
                alignItems: 'center',
                gap: 6,
                border: 'none',
                ...(buttonProps.style === 'terminate' ? {
                  background: '#1A6FB8',
                  color: 'white',
                } : {
                  background: '#52c41a',
                  color: 'white',
                }),
                opacity: controlLoading ? 0.6 : 1,
              }}
            >
              {controlLoading ? (
                <><i className="fas fa-spinner fa-spin"></i>处理中...</>
              ) : (
                <><i className="fas fa-pause-circle"></i>{buttonProps.text}</>
              )}
            </button>
          </div>
        );
      })()}
      {/* 状态控制确认对话框 */}
      <Modal