From dab36ca32772604d93249e32e5b005ccb70043c0 Mon Sep 17 00:00:00 2001 From: MikiVL Date: Tue, 5 May 2026 03:03:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E7=AC=94=E8=AE=B0?= =?UTF-8?q?=E5=89=8D=E5=A2=9E=E5=8A=A0=E7=A1=AE=E8=AE=A4=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/sidebar/Sidebar.tsx | 35 ++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 31efc28..7a38a67 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -44,6 +44,7 @@ export function Sidebar() { y: number } | null>(null) const [draggingNoteId, setDraggingNoteId] = useState(null) + const [deleteConfirm, setDeleteConfirm] = useState(null) const sensors = useSensors( useSensor(MouseSensor, { activationConstraint: { distance: 6 } }), @@ -332,7 +333,7 @@ export function Sidebar() { if (e.key === 'Escape') setEditingNoteId(null) }} onClick={() => setActiveNote(note.id)} - onDelete={() => deleteNote(note.id)} + onDelete={() => setDeleteConfirm(note.id)} onToggleStar={() => toggleStar(note.id)} onTagClick={(tag) => setActiveTag(activeTag === tag ? null : tag)} onContextMenu={(e) => { @@ -367,7 +368,7 @@ export function Sidebar() { if (n) { setNoteEditValue(n.title); setEditingNoteId(contextMenu.id) } setContextMenu(null) }} /> - } label="删除笔记" danger onClick={async () => { await deleteNote(contextMenu.id); setContextMenu(null) }} /> + } label="删除笔记" danger onClick={() => { setDeleteConfirm(contextMenu.id); setContextMenu(null) }} /> )} @@ -424,6 +425,36 @@ export function Sidebar() { )} + {deleteConfirm && ( +
setDeleteConfirm(null)} + > +
e.stopPropagation()} + > +

确认删除笔记?

+

此操作无法撤销。

+
+ + +
+
+
+ )} ) }