2025-08-27 11:00:53 +08:00
|
|
|
import React from "react";
|
2025-09-06 16:21:21 +08:00
|
|
|
import { AlertTriangle, X } from "lucide-react";
|
2025-08-06 16:29:52 +08:00
|
|
|
|
|
|
|
|
interface ConfirmDialogProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
title: string;
|
|
|
|
|
message: string;
|
|
|
|
|
confirmText?: string;
|
|
|
|
|
cancelText?: string;
|
|
|
|
|
onConfirm: () => void;
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
|
|
|
|
|
isOpen,
|
|
|
|
|
title,
|
|
|
|
|
message,
|
2025-08-27 11:00:53 +08:00
|
|
|
confirmText = "确定",
|
|
|
|
|
cancelText = "取消",
|
2025-08-06 16:29:52 +08:00
|
|
|
onConfirm,
|
2025-08-27 11:00:53 +08:00
|
|
|
onCancel,
|
2025-08-06 16:29:52 +08:00
|
|
|
}) => {
|
|
|
|
|
if (!isOpen) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
2025-09-06 16:21:21 +08:00
|
|
|
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
|
|
|
|
{/* Backdrop */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 bg-black/50 backdrop-blur-sm"
|
|
|
|
|
onClick={onCancel}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Dialog */}
|
|
|
|
|
<div className="relative bg-white rounded-xl shadow-lg max-w-md w-full mx-4 overflow-hidden">
|
|
|
|
|
{/* Header */}
|
|
|
|
|
<div className="flex items-center justify-between p-6 border-b border-[var(--color-border)]">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<div className="w-10 h-10 bg-[var(--color-error-light)] rounded-full flex items-center justify-center">
|
|
|
|
|
<AlertTriangle size={20} className="text-[var(--color-error)]" />
|
|
|
|
|
</div>
|
|
|
|
|
<h3 className="text-lg font-semibold text-[var(--color-text-primary)]">
|
|
|
|
|
{title}
|
|
|
|
|
</h3>
|
|
|
|
|
</div>
|
|
|
|
|
<button
|
|
|
|
|
onClick={onCancel}
|
|
|
|
|
className="p-1 text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-bg-tertiary)] rounded-md transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<X size={18} />
|
|
|
|
|
</button>
|
2025-08-06 16:29:52 +08:00
|
|
|
</div>
|
2025-09-06 16:21:21 +08:00
|
|
|
|
|
|
|
|
{/* Content */}
|
|
|
|
|
<div className="p-6">
|
|
|
|
|
<p className="text-[var(--color-text-secondary)] leading-relaxed">
|
|
|
|
|
{message}
|
|
|
|
|
</p>
|
2025-08-06 16:29:52 +08:00
|
|
|
</div>
|
2025-09-06 16:21:21 +08:00
|
|
|
|
|
|
|
|
{/* Actions */}
|
|
|
|
|
<div className="flex items-center justify-end gap-3 p-6 border-t border-[var(--color-border)] bg-[var(--color-bg-tertiary)]">
|
2025-08-27 11:00:53 +08:00
|
|
|
<button
|
2025-08-06 16:29:52 +08:00
|
|
|
onClick={onCancel}
|
2025-09-06 16:21:21 +08:00
|
|
|
className="px-4 py-2 text-sm font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:bg-white rounded-md transition-colors"
|
2025-08-06 16:29:52 +08:00
|
|
|
autoFocus
|
|
|
|
|
>
|
|
|
|
|
{cancelText}
|
|
|
|
|
</button>
|
2025-08-27 11:00:53 +08:00
|
|
|
<button
|
2025-08-06 16:29:52 +08:00
|
|
|
onClick={onConfirm}
|
2025-09-06 16:21:21 +08:00
|
|
|
className="px-4 py-2 text-sm font-medium bg-[var(--color-error)] text-white hover:bg-[var(--color-error)]/90 rounded-md transition-colors"
|
2025-08-06 16:29:52 +08:00
|
|
|
>
|
|
|
|
|
{confirmText}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-08-27 11:00:53 +08:00
|
|
|
};
|