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
-