diff --git a/src/App.vue b/src/App.vue index 0cb4397..e0af868 100644 --- a/src/App.vue +++ b/src/App.vue @@ -100,7 +100,7 @@ const calendarDays = computed(() => { const selectCalendarDate = (date: Date) => { currentDate.value = date.toLocaleDateString('sv'); // sv locale gives YYYY-MM-DD isCalendarOpen.value = false; - loadTimeline(); loadEvents(); + loadTimeline(true); loadEvents(); }; // --- Logic --- @@ -119,7 +119,7 @@ onMounted(async () => { timelineZoom.value = (await store.get("timelineZoom")) as number || 1.5; await invoke("update_interval", { seconds: captureInterval.value }); isPaused.value = await invoke("get_pause_state"); - await loadTimeline(); await loadTags(); await loadEvents(); + await loadTimeline(true); await loadTags(); await loadEvents(); } await listen("pause-state-changed", (event) => { isPaused.value = event.payload; }); captureUnlisten = await listen("refresh-timeline", () => { loadTimeline(); }); @@ -138,7 +138,7 @@ const completeSetup = async () => { await store.save(); await invoke("update_db_path", { path: dbPath.value }); isSetupComplete.value = true; - await loadTimeline(); await loadTags(); await loadEvents(); + await loadTimeline(true); await loadTags(); await loadEvents(); } }; @@ -299,7 +299,20 @@ const updateSettings = async () => { }; const togglePauseState = async () => { isPaused.value = await invoke("toggle_pause"); }; -const loadTimeline = async () => { if (savePath.value) timelineImages.value = await invoke("get_timeline", { date: currentDate.value, baseDir: savePath.value }); }; +const loadTimeline = async (autoScrollToCurrentTime = false) => { + if (savePath.value) { + timelineImages.value = await invoke("get_timeline", { date: currentDate.value, baseDir: savePath.value }); + await nextTick(); + if (autoScrollToCurrentTime && timelineRef.value) { + const now = new Date(); + const currentMin = now.getHours() * 60 + now.getMinutes(); + const logicalMin = (currentMin < TIME_OFFSET_MINUTES ? currentMin + 1440 : currentMin) - TIME_OFFSET_MINUTES; + const targetY = logicalMin * timelineZoom.value; + const containerHeight = timelineRef.value.clientHeight; + timelineRef.value.scrollTop = Math.max(0, targetY - containerHeight / 2); + } + } +}; const newTagName = ref(""); const newTagParent = ref(null); const newTagColor = ref("#007AFF"); const resetTagForm = () => { newTagName.value = ""; newTagParent.value = null; newTagColor.value = "#007AFF"; }; @@ -341,7 +354,7 @@ const isTagSelectOpen = ref(false);
-

历史活动

+

历史活动