add addEvent button
This commit is contained in:
37
src/App.vue
37
src/App.vue
@@ -4,7 +4,7 @@ import { load } from "@tauri-apps/plugin-store";
|
|||||||
import { open, save } from "@tauri-apps/plugin-dialog";
|
import { open, save } from "@tauri-apps/plugin-dialog";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { Tag as TagIcon, FolderOpen, Settings, Play, Pause, Maximize2, X, RefreshCw, Plus, Trash2, ChevronDown, ChevronLeft, ChevronRight, Calendar, Download } from "lucide-vue-next";
|
import { Tag as TagIcon, FolderOpen, Settings, Play, Pause, Maximize2, X, RefreshCw, Plus, Trash2, ChevronDown, ChevronLeft, ChevronRight, Calendar, Download, SquarePlus } from "lucide-vue-next";
|
||||||
|
|
||||||
// --- Types ---
|
// --- Types ---
|
||||||
interface Tag { id: number; name: string; parent_id: number | null; color: string; }
|
interface Tag { id: number; name: string; parent_id: number | null; color: string; }
|
||||||
@@ -401,6 +401,32 @@ const loadTimeline = async (autoScrollToCurrentTime = false) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleQuickAddEvent = () => {
|
||||||
|
let start = 0;
|
||||||
|
if (dayEvents.value && dayEvents.value.length > 0) {
|
||||||
|
const lastEvent = dayEvents.value.reduce((prev, curr) => curr.end_minute > prev.end_minute ? curr : prev, dayEvents.value[0]);
|
||||||
|
start = lastEvent.end_minute;
|
||||||
|
}
|
||||||
|
|
||||||
|
let end = 1439;
|
||||||
|
if (currentLogicalMinute.value >= 0) {
|
||||||
|
end = currentLogicalMinute.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start > end) start = end;
|
||||||
|
|
||||||
|
editingEvent.value = {
|
||||||
|
id: 0,
|
||||||
|
date: currentDate.value,
|
||||||
|
start_minute: start,
|
||||||
|
end_minute: end,
|
||||||
|
main_tag_id: mainTags.value[0]?.id || 0,
|
||||||
|
sub_tag_id: null,
|
||||||
|
content: ""
|
||||||
|
};
|
||||||
|
isEventModalOpen.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
const newTagName = ref(""); const newTagParent = ref<number | null>(null); const newTagColor = ref("#007AFF");
|
const newTagName = ref(""); const newTagParent = ref<number | null>(null); const newTagColor = ref("#007AFF");
|
||||||
const resetTagForm = () => { newTagName.value = ""; newTagParent.value = null; newTagColor.value = "#007AFF"; };
|
const resetTagForm = () => { newTagName.value = ""; newTagParent.value = null; newTagColor.value = "#007AFF"; };
|
||||||
|
|
||||||
@@ -565,10 +591,11 @@ const handleExport = async () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 border-t border-[#E5E5E7] bg-white/50 flex justify-around">
|
<div class="p-4 border-t border-[#E5E5E7] bg-white/50 flex justify-around">
|
||||||
<button @click="togglePauseState" class="p-3 rounded-2xl" :class="isPaused ? 'text-[#FF3B30]' : 'text-[#86868B]'"><Play v-if="isPaused" :size="22" /><Pause v-else :size="22" /></button>
|
<button @click="togglePauseState" class="p-3 rounded-2xl" :class="isPaused ? 'text-[#FF3B30]' : 'text-[#86868B]'" :title="isPaused ? '恢复记录' : '暂停记录'"><Play v-if="isPaused" :size="22" /><Pause v-else :size="22" /></button>
|
||||||
<button @click="isTagManagerOpen = true" class="p-3 rounded-2xl text-[#86868B]"><TagIcon :size="22" /></button>
|
<button @click="handleQuickAddEvent" class="p-3 rounded-2xl text-[#86868B]" title="添加记录"><SquarePlus :size="22" /></button>
|
||||||
<button @click="openExportModal" class="p-3 rounded-2xl text-[#86868B]"><Download :size="22" /></button>
|
<button @click="isTagManagerOpen = true" class="p-3 rounded-2xl text-[#86868B]" title="标签管理"><TagIcon :size="22" /></button>
|
||||||
<button @click="isSettingsOpen = true" class="p-3 rounded-2xl text-[#86868B]"><Settings :size="22" /></button>
|
<button @click="openExportModal" class="p-3 rounded-2xl text-[#86868B]" title="导出记录"><Download :size="22" /></button>
|
||||||
|
<button @click="isSettingsOpen = true" class="p-3 rounded-2xl text-[#86868B]" title="设置"><Settings :size="22" /></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user