'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import ConfirmModal from './ConfirmModal'; import { CloseIcon, CloudIcon } from './Icons'; export default function CloudConfigModal({ onConfirm, onCancel, type = 'empty' }) { const [pendingAction, setPendingAction] = useState(null); // 'local' | 'cloud' | null const isConflict = type === 'conflict'; const handlePrimaryClick = () => { if (isConflict) { setPendingAction('local'); } else { onConfirm?.(); } }; const handleSecondaryClick = () => { if (isConflict) { setPendingAction('cloud'); } else { onCancel?.(); } }; const handleConfirmModalCancel = () => { setPendingAction(null); }; const handleConfirmModalConfirm = () => { if (pendingAction === 'local') { onConfirm?.(); } else if (pendingAction === 'cloud') { onCancel?.(); } setPendingAction(null); }; const confirmTitle = pendingAction === 'local' ? '确认使用本地配置覆盖云端?' : '确认使用云端配置覆盖本地?'; const confirmMessage = pendingAction === 'local' ? '此操作会将当前本地配置同步到云端,覆盖云端原有配置,且可能无法恢复,请谨慎操作。' : '此操作会使用云端配置覆盖当前本地配置,导致本地修改丢失,且可能无法恢复,请谨慎操作。'; return ( e.stopPropagation()} >
{isConflict ? '发现配置冲突' : '云端暂无配置'}
{!isConflict && ( )}

{isConflict ? '检测到本地配置与云端不一致,请选择操作:' : '是否将本地配置同步到云端?'}

{pendingAction && ( } confirmVariant="danger" /> )}
); }