diff --git a/src/common/base.css b/src/common/base.css index 3527254..dee286c 100644 --- a/src/common/base.css +++ b/src/common/base.css @@ -23,6 +23,9 @@ text { box-sizing: border-box; flex-shrink: 0; } +button { + border: none; +} #app { width: 100vw; diff --git a/src/components/NoteItem.vue b/src/components/NoteItem.vue index c8d705a..63b28be 100644 --- a/src/components/NoteItem.vue +++ b/src/components/NoteItem.vue @@ -1,91 +1,186 @@ - - - - - + + + + + diff --git a/src/components/NoteItem_old.vue b/src/components/NoteItem_old.vue deleted file mode 100644 index ca193c8..0000000 --- a/src/components/NoteItem_old.vue +++ /dev/null @@ -1,211 +0,0 @@ - - - - - diff --git a/src/pages/NoteListPage.vue b/src/pages/NoteListPage.vue index b63ca51..ad5c4c7 100644 --- a/src/pages/NoteListPage.vue +++ b/src/pages/NoteListPage.vue @@ -32,21 +32,27 @@ } " /> + +
-
-
- -
+
+
- - -
{ return store.notes.filter(note => note.isStarred).length }) +// 计算置顶便签数量 +const topNotesCount = computed(() => { + return filteredAndSortedNotes.value.filter(note => note.isTop).length +}) + // 根据当前文件夹过滤便签 const filteredNotes = computed(() => { return store.notes.filter(note => { @@ -122,6 +133,10 @@ const filteredAndSortedNotes = computed(() => { return filteredNotes.value .filter(note => note.title.toLowerCase().includes(searchQuery.value.toLowerCase()) || note.content.toLowerCase().includes(searchQuery.value.toLowerCase())) .sort((a, b) => { + // 置顶的便签排在前面 + if (a.isTop && !b.isTop) return -1 + if (!a.isTop && b.isTop) return 1 + if (sortBy.value === 'title') { return a.title.localeCompare(b.title) } else if (sortBy.value === 'starred') { @@ -161,6 +176,20 @@ const handleDeleteNote = noteId => { showAlert.value = true } +const handleStarToggle = async noteId => { + const note = store.notes.find(n => n.id === noteId) + if (note) { + await store.updateNote(noteId, { isStarred: !note.isStarred }) + } +} + +const handleTopToggle = async noteId => { + const note = store.notes.find(n => n.id === noteId) + if (note) { + await store.updateNote(noteId, { isTop: !note.isTop }) + } +} + const confirmDeleteNote = () => { if (noteToDelete.value) { store.deleteNote(noteToDelete.value) diff --git a/src/stores/useAppStore.js b/src/stores/useAppStore.js index 5bd934d..b031fd4 100644 --- a/src/stores/useAppStore.js +++ b/src/stores/useAppStore.js @@ -50,7 +50,9 @@ export const useAppStore = defineStore('app', { createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), folderId: null, - isStarred: true + isStarred: true, + isTop: true, + hasImage: false }, { id: '2', @@ -59,7 +61,9 @@ export const useAppStore = defineStore('app', { createdAt: new Date(Date.now() - 86400000).toISOString(), // 昨天 updatedAt: new Date(Date.now() - 86400000).toISOString(), folderId: null, - isStarred: true + isStarred: true, + isTop: false, + hasImage: true }, { id: '3', @@ -68,7 +72,9 @@ export const useAppStore = defineStore('app', { createdAt: new Date(Date.now() - 172800000).toISOString(), // 前天 updatedAt: new Date(Date.now() - 172800000).toISOString(), folderId: null, - isStarred: false + isStarred: false, + isTop: false, + hasImage: false }, { id: '4', @@ -77,7 +83,9 @@ export const useAppStore = defineStore('app', { createdAt: new Date(Date.now() - 259200000).toISOString(), // 3天前 updatedAt: new Date(Date.now() - 259200000).toISOString(), folderId: null, - isStarred: false + isStarred: false, + isTop: false, + hasImage: false }, { id: '5', @@ -86,7 +94,9 @@ export const useAppStore = defineStore('app', { createdAt: new Date(Date.now() - 345600000).toISOString(), // 4天前 updatedAt: new Date(Date.now() - 345600000).toISOString(), folderId: null, - isStarred: false + isStarred: false, + isTop: false, + hasImage: false } ]; diff --git a/src/utils/storage.js b/src/utils/storage.js index 731a43d..b9e1069 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -28,6 +28,9 @@ export const addNote = async (note) => { id: Date.now().toString(), createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), + isStarred: note.isStarred || false, + isTop: note.isTop || false, + hasImage: note.hasImage || false }; const notes = await getNotes(); diff --git a/src/utils/types.js b/src/utils/types.js index f65d06c..0e3e31c 100644 --- a/src/utils/types.js +++ b/src/utils/types.js @@ -6,7 +6,9 @@ export const Note = { createdAt: Date, updatedAt: Date, folderId: String, - isStarred: Boolean + isStarred: Boolean, + isTop: Boolean, + hasImage: Boolean }; export const Folder = {