diff --git a/app/components/CloudConfigModal.jsx b/app/components/CloudConfigModal.jsx index da39be0..f0cdc1c 100644 --- a/app/components/CloudConfigModal.jsx +++ b/app/components/CloudConfigModal.jsx @@ -1,10 +1,53 @@ '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 (
- -
+ {pendingAction && ( + } + confirmVariant="danger" + /> + )} ); }