add now time

This commit is contained in:
Julian Freeman
2026-03-22 23:45:08 -04:00
parent 190d7863fe
commit 880b27f655

View File

@@ -55,6 +55,18 @@ const editingEvent = ref<DBEvent>({ id: 0, date: "", start_minute: 0, end_minute
const hoveredTime = ref<string | null>(null);
const hoveredEventDetails = ref<{ event: DBEvent; x: number; y: number } | null>(null);
const currentLogicalMinute = ref(-1);
let currentMinuteInterval: number | null = null;
const updateCurrentMinute = () => {
const now = new Date();
if (now.toLocaleDateString('sv') === currentDate.value) {
const m = now.getHours() * 60 + now.getMinutes();
currentLogicalMinute.value = (m < TIME_OFFSET_MINUTES ? m + 1440 : m) - TIME_OFFSET_MINUTES;
} else {
currentLogicalMinute.value = -1;
}
};
const handleEventMouseEnter = (ev: DBEvent, e: MouseEvent) => {
hoveredEventDetails.value = { event: ev, x: e.clientX, y: e.clientY };
};
@@ -150,12 +162,19 @@ const calendarDays = computed(() => {
const selectCalendarDate = (date: Date) => {
currentDate.value = date.toLocaleDateString('sv'); // sv locale gives YYYY-MM-DD
isCalendarOpen.value = false;
selectedImage.value = null;
lockedImage.value = null;
previewSrc.value = "";
hoveredTime.value = null;
updateCurrentMinute();
loadTimeline(true); loadEvents();
};
// --- Logic ---
onMounted(async () => {
window.addEventListener('mousedown', handleClickOutside);
updateCurrentMinute();
currentMinuteInterval = window.setInterval(updateCurrentMinute, 60000);
store = await load("config.json");
const path = await store.get("savePath");
const dPath = await store.get("dbPath");
@@ -177,6 +196,7 @@ onMounted(async () => {
onUnmounted(() => {
window.removeEventListener('mousedown', handleClickOutside);
if (currentMinuteInterval) window.clearInterval(currentMinuteInterval);
if (captureUnlisten) captureUnlisten();
});
@@ -539,6 +559,7 @@ const handleExport = async () => {
<div v-for="img in timelineImages" :key="img.path" class="absolute left-[50%] right-2 h-0.5 bg-[#007AFF]/20 rounded-full" :class="[selectedImage?.path === img.path ? 'bg-[#007AFF]/60 h-1 z-10' : '', lockedImage?.path === img.path ? 'bg-[#007AFF] h-1.5 ring-2 ring-[#007AFF]/20 z-20' : '']" :style="{ top: timeToLogicalMinutes(img.time, img.isNextDay) * timelineZoom + 'px' }"></div>
<div v-if="dragStartMin !== null && dragEndMin !== null" class="absolute left-0 w-full bg-[#007AFF]/10 border-y-2 border-[#007AFF] pointer-events-none z-30" :style="{ top: Math.min(dragStartMin, dragEndMin) * timelineZoom + 'px', height: Math.abs(dragEndMin - dragStartMin) * timelineZoom + 'px' }"></div>
<div v-if="hoveredTime" class="absolute left-0 right-0 border-t-2 border-[#007AFF] z-40 pointer-events-none" :style="{ top: timeToLogicalMinutes(hoveredTime, hoveredTime < '03:00') * timelineZoom + 'px' }"><div class="absolute -left-12 -top-3 bg-[#007AFF] text-white text-[9px] px-1 py-0.5 rounded font-bold">{{ hoveredTime }}</div></div>
<div v-if="currentLogicalMinute >= 0" class="absolute left-0 right-0 border-t-2 border-[#FF3B30] z-30 pointer-events-none" :style="{ top: currentLogicalMinute * timelineZoom + 'px' }"><div class="absolute -left-12 -top-2.5 bg-[#FF3B30] text-white text-[9px] px-1 py-0.5 rounded font-bold shadow-[0_0_8px_rgba(255,59,48,0.5)]">{{ logicalMinutesToTime(currentLogicalMinute) }}</div></div>
</div>
</div>