From 83119adef475ddf9a2148c5fe36778f4954cce2a Mon Sep 17 00:00:00 2001 From: MikiVL Date: Tue, 5 May 2026 04:51:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=BB=BA=20TrashView=20?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E7=AB=99=E5=88=97=E8=A1=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/sidebar/TrashView.tsx | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/components/sidebar/TrashView.tsx diff --git a/src/components/sidebar/TrashView.tsx b/src/components/sidebar/TrashView.tsx new file mode 100644 index 0000000..1a9b93a --- /dev/null +++ b/src/components/sidebar/TrashView.tsx @@ -0,0 +1,75 @@ +import { Trash2, RotateCcw } from 'lucide-react' +import { useAppStore } from '../../stores/appStore' + +function daysLeft(deletedAt: number): number { + const elapsed = Date.now() - deletedAt + return Math.max(0, 30 - Math.floor(elapsed / (24 * 60 * 60 * 1000))) +} + +export function TrashView() { + const { trashNotes, restoreNote, emptyTrash } = useAppStore() + const notes = trashNotes() + + return ( +
+
+ + {notes.length > 0 ? `${notes.length} 条笔记` : '回收站为空'} + + {notes.length > 0 && ( + + )} +
+ +
+ {notes.length === 0 ? ( +
+ +

回收站为空

+
+ ) : ( + notes.map(note => ( +
(e.currentTarget.style.background = 'var(--bg-muted)')} + onMouseLeave={e => (e.currentTarget.style.background = 'transparent')} + > +
+

+ {note.title || '无标题'} +

+

+ {daysLeft(note.deletedAt!)} 天后永久删除 +

+
+ +
+ )) + )} +
+
+ ) +}