fix time duration

This commit is contained in:
Julian Freeman
2026-03-26 13:08:47 -04:00
parent 1e1307b8d4
commit 05a6ee59ff
3 changed files with 42 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ import { load as loadStore } from "@tauri-apps/plugin-store";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import {
RefreshCw, Calendar, ChevronLeft, ChevronRight, Play, Pause, SquarePlus, Tag as TagIcon, Download, Settings, Maximize2, X, Image as ImageIcon, BarChart2
RefreshCw, Calendar, ChevronLeft, ChevronRight, Play, Pause, SquarePlus, Tag as TagIcon, Download, Settings, Maximize2, X, Image as ImageIcon, BarChart2, Trash2
} from "lucide-vue-next";
import {
@@ -219,6 +219,10 @@ const calendarDays = computed(() => {
});
const saveEvent = async () => {
if (editingEvent.value.end_minute <= editingEvent.value.start_minute) {
showToast("结束时间必须晚于开始时间", "error");
return;
}
try {
await invoke("save_event", { event: editingEvent.value });
isEventModalOpen.value = false; await loadEvents(); showToast("事件已保存");
@@ -231,7 +235,7 @@ const deleteEvent = async (id: number) => {
const handleQuickAddEvent = () => {
let start = dayEvents.value.length ? Math.max(...dayEvents.value.map(e => e.end_minute)) : 0;
let end = currentLogicalMinute.value >= 0 ? currentLogicalMinute.value : 1439;
let end = currentLogicalMinute.value >= 0 ? currentLogicalMinute.value : Math.min(start + 30, 1439);
editingEvent.value = { id: 0, date: currentDate.value, start_minute: Math.min(start, end), end_minute: end, main_tag_id: mainTags.value[0]?.id || 0, sub_tag_id: null, content: "" };
isEventModalOpen.value = true;
};