修复点击今天定位失效:改用scrollIntoView定位上周行实现第二行布局;版本号升至1.5.8

This commit is contained in:
2026-08-13 17:32:00 +08:00
parent 685999ba8a
commit 9b54fffb56
2 files changed
+9 -16

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ops_vue_js",
"version": "1.5.7",
"version": "1.5.8",
"private": true,
"type": "module",
"engines": {
@@ -812,7 +812,6 @@ function handleDragEnd() {
function goToToday() {
generateInitialWeeks()
lastEventsSnapshot = null
if (scrollContainerRef.value) scrollContainerRef.value.scrollTop = 0
const { start, end } = getLoadedRange()
fetchEvents(start, end).then(() => scrollToToday())
}
@@ -852,22 +851,16 @@ function applyTodayScroll() {
const todayCell = container.querySelector(`.day-cell[data-date="${todayStr}"]`)
if (!todayCell) return
const idx = weeks.value.findIndex(w => weekKey(w) === dateToStr(getWeekStart(new Date())))
let desiredTop = idx > 0
? (weekLayouts.get(weekKey(weeks.value[idx - 1]))?.weekHeight ?? 90)
: 0
const todayWeekEl = todayCell.closest('.week-row')
const prevSib = todayWeekEl?.previousElementSibling
if (prevSib?.classList.contains('month-separator')) {
desiredTop += prevSib.getBoundingClientRect().height
let targetEl = todayWeekEl?.previousElementSibling
if (targetEl && !targetEl.classList.contains('week-row')) {
targetEl = targetEl.previousElementSibling
}
if (targetEl && targetEl.classList.contains('week-row')) {
targetEl.scrollIntoView({ block: 'start' })
} else {
todayCell.scrollIntoView({ block: 'start' })
}
const contRect = container.getBoundingClientRect()
const cellRect = todayCell.getBoundingClientRect()
const currentTop = cellRect.top - contRect.top
container.scrollTop += (currentTop - desiredTop)
}
function applyScrollToTitle(titleEl) {