From 10583fd882bcb2c9b5abb8010f092a12e40e7d76 Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Thu, 26 Mar 2026 18:52:40 -0400 Subject: [PATCH] improve --- src/App.vue | 5 +- src/components/modals/ReminderManager.vue | 76 ++++++++++++++++------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/App.vue b/src/App.vue index 2a9c052..9dec544 100644 --- a/src/App.vue +++ b/src/App.vue @@ -373,7 +373,8 @@ const togglePause = async () => {
@@ -405,7 +406,7 @@ const togglePause = async () => { -
import { ref, computed, onMounted, onUnmounted, nextTick } from "vue"; -import { X, Plus, Trash2, Check, Clock, Calendar } from "lucide-vue-next"; +import { X, Plus, Trash2, Check, Clock, Calendar, Edit2 } from "lucide-vue-next"; import { invoke } from "@tauri-apps/api/core"; import { reminders, loadReminders, showToast, currentDate, logicalMinutesToTime, logicalMinutesFromTime, currentLogicalMinute, getLogicDateStr, TIME_OFFSET_MINUTES } from "../../store"; import { Reminder } from "../../types"; @@ -17,6 +17,7 @@ const getInitialMinute = () => { const newContent = ref(""); const newMinute = ref(getInitialMinute()); +const editingId = ref(null); const isTimePickerOpen = ref(false); const timePickerRef = ref(null); @@ -45,18 +46,33 @@ const addReminder = async () => { showToast("请输入提醒内容", "error"); return; } + const isEditing = editingId.value !== null; try { await invoke("save_reminder", { - reminder: { id: 0, date: currentDate.value, minute: newMinute.value, content: newContent.value, is_completed: false } + reminder: { id: editingId.value || 0, date: currentDate.value, minute: newMinute.value, content: newContent.value, is_completed: false } }); newContent.value = ""; + newMinute.value = getInitialMinute(); + editingId.value = null; await loadReminders(); - showToast("提醒已添加"); + showToast(isEditing ? "提醒已更新" : "提醒已添加"); } catch (e) { - showToast("添加失败: " + e, "error"); + showToast("保存失败: " + e, "error"); } }; +const editReminder = (r: Reminder) => { + editingId.value = r.id; + newContent.value = r.content; + newMinute.value = r.minute; +}; + +const cancelEdit = () => { + editingId.value = null; + newContent.value = ""; + newMinute.value = getInitialMinute(); +}; + const toggleStatus = async (r: Reminder) => { try { await invoke("toggle_reminder", { id: r.id, isCompleted: !r.is_completed }); @@ -96,10 +112,10 @@ const completedReminders = computed(() => safeReminders.value.filter(r => r.is_c
-
+
-
@@ -115,53 +131,69 @@ const completedReminders = computed(() => safeReminders.value.filter(r => r.is_c
- - +
+ + +
+
-
+ +

已超时未办

-
+
{{ logicalMinutesToTime(r.minute) }}
-
{{ r.content }}
- +
{{ r.content }}
+
+ + +
-
+ +

即将到来

-
+
{{ logicalMinutesToTime(r.minute) }}
-
{{ r.content }}
- +
{{ r.content }}
+
+ + +
-
+ +

已完成

-
+
{{ logicalMinutesToTime(r.minute) }}
-
{{ r.content }}
- +
{{ r.content }}
+
+ + +
-
+ +

今天没有提醒事项

- + \ No newline at end of file