"use client" import { Button } from "@/components/ui/button" import { FileDown, FileText, Copy } from "lucide-react" interface ExportControlsProps { documentUrl: string | null onError: (error: string) => void } export default function ExportControls({ documentUrl, onError }: ExportControlsProps) { const handleDownload = () => { if (!documentUrl) { onError("没有可下载的文档") return } try { // 创建一个临时链接并触发下载 const link = document.createElement("a") link.href = documentUrl link.download = "用户数据资产中台使用手册.docx" document.body.appendChild(link) link.click() document.body.removeChild(link) } catch (err) { onError(`下载文档时出错: ${err instanceof Error ? err.message : String(err)}`) } } const handlePreview = () => { if (!documentUrl) { onError("没有可预览的文档") return } try { // 在新窗口中打开文档 window.open(documentUrl, "_blank") } catch (err) { onError(`预览文档时出错: ${err instanceof Error ? err.message : String(err)}`) } } const handleCopyLink = () => { if (!documentUrl) { onError("没有可复制的文档链接") return } try { // 复制链接到剪贴板 navigator.clipboard .writeText(documentUrl) .then(() => { alert("文档链接已复制到剪贴板") }) .catch((err) => { onError(`复制链接时出错: ${err instanceof Error ? err.message : String(err)}`) }) } catch (err) { onError(`复制链接时出错: ${err instanceof Error ? err.message : String(err)}`) } } return (
文档已生成
{documentUrl}
尚未生成文档
请先完成文档生成步骤