"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog" import { Send } from "lucide-react" import { useToast } from "@/components/ui/use-toast" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip" interface SendDialogProps { emailId: string fromAddress: string onSendSuccess?: () => void } export function SendDialog({ emailId, fromAddress, onSendSuccess }: SendDialogProps) { const [open, setOpen] = useState(false) const [loading, setLoading] = useState(false) const [to, setTo] = useState("") const [subject, setSubject] = useState("") const [content, setContent] = useState("") const { toast } = useToast() const handleSend = async () => { if (!to.trim() || !subject.trim() || !content.trim()) { toast({ title: "错误", description: "收件人、主题和内容都是必填项", variant: "destructive" }) return } setLoading(true) try { const response = await fetch(`/api/emails/${emailId}/send`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ to, subject, content }) }) if (!response.ok) { const data = await response.json() toast({ title: "错误", description: (data as { error: string }).error, variant: "destructive" }) return } toast({ title: "成功", description: "邮件已发送" }) setOpen(false) setTo("") setSubject("") setContent("") onSendSuccess?.() } catch { toast({ title: "错误", description: "发送邮件失败", variant: "destructive" }) } finally { setLoading(false) } } return (

使用此邮箱发送新邮件

发送新邮件
发件人: {fromAddress}
) => setTo(e.target.value)} placeholder="收件人邮箱地址" /> ) => setSubject(e.target.value)} placeholder="邮件主题" />