From 1c169d4d358d8e186ce2eeb006301e16ee38a7a3 Mon Sep 17 00:00:00 2001 From: tianyaxiang Date: Mon, 3 Feb 2025 18:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=9A=84=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/editor/WechatEditor.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/editor/WechatEditor.tsx b/src/components/editor/WechatEditor.tsx index daf0f46..521257e 100644 --- a/src/components/editor/WechatEditor.tsx +++ b/src/components/editor/WechatEditor.tsx @@ -291,7 +291,7 @@ export default function WechatEditor() { setIsDraft(true) toast({ description: "已恢复未保存的草稿", - action: 放弃草稿, + action: 放弃草稿, duration: 5000, }) } else if (savedContent) { @@ -299,6 +299,21 @@ export default function WechatEditor() { } }, [toast]) + // 处理放弃草稿 + const handleDiscardDraft = useCallback(() => { + const savedContent = localStorage.getItem('wechat_editor_content') + // 移除草稿 + localStorage.removeItem('wechat_editor_draft') + // 恢复到最后保存的内容,如果没有则清空 + setValue(savedContent || '') + setIsDraft(false) + toast({ + title: "已放弃草稿", + description: "已恢复到上次保存的内容", + duration: 2000 + }) + }, [toast]) + // 渲染预览内容 const renderPreview = useCallback(() => { return (