From e44af4b1cd4cef6a4276ffb374d3d22c2578e98a Mon Sep 17 00:00:00 2001 From: MikiVL Date: Tue, 5 May 2026 04:48:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Note=20=E6=B7=BB=E5=8A=A0=20deletedAt?= =?UTF-8?q?=20=E8=BD=AF=E5=88=A0=E9=99=A4=E5=AD=97=E6=AE=B5=EF=BC=8CDexie?= =?UTF-8?q?=20=E5=8D=87=E7=BA=A7=20v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/index.ts | 14 ++++++++++++++ src/stores/appStore.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/src/db/index.ts b/src/db/index.ts index 02a41ba..db06ca0 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -10,6 +10,7 @@ export interface Note { createdAt: number updatedAt: number wordCount: number + deletedAt: number | null } export interface Folder { @@ -38,6 +39,17 @@ class NotesDB extends Dexie { folders: 'id, parentId, order', tags: 'id, name', }) + this.version(2).stores({ + notes: 'id, folderId, starred, updatedAt, createdAt, deletedAt, *tags', + folders: 'id, parentId, order', + tags: 'id, name', + }).upgrade(tx => { + return tx.table('notes').toCollection().modify(note => { + if (note.deletedAt === undefined) { + note.deletedAt = null + } + }) + }) } } @@ -86,6 +98,7 @@ async function _doSeed() { createdAt: now - 86400000, updatedAt: now - 3600000, wordCount: 30, + deletedAt: null, }, { id: crypto.randomUUID(), @@ -104,6 +117,7 @@ async function _doSeed() { createdAt: now - 172800000, updatedAt: now - 172800000, wordCount: 45, + deletedAt: null, }, ]) } diff --git a/src/stores/appStore.ts b/src/stores/appStore.ts index 152a087..44f82f7 100644 --- a/src/stores/appStore.ts +++ b/src/stores/appStore.ts @@ -82,6 +82,7 @@ export const useAppStore = create((set, get) => ({ createdAt: now, updatedAt: now, wordCount: 0, + deletedAt: null, } await db.notes.add(note) set(s => ({ notes: [note, ...s.notes], activeNoteId: id, _notesVersion: s._notesVersion + 1, _filteredCache: null }))