From a1582d574106ac0280fd10e312f47efd05059e38 Mon Sep 17 00:00:00 2001 From: agent-bot Date: Mon, 27 Jul 2026 02:48:01 +0800 Subject: [PATCH] feat: add a now marker to the overview timeline during schedule gaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 条目之间本来就有空隙,此时没有任何一行是高亮的,时间轴完全丢失「现在」这个 锚点——看不出当前时刻落在哪两条之间,滚动定位也失效(原逻辑只找 .is-current)。 指示线只在当前时刻落进空档时出现:有条目进行中时,那一行的高亮本身就是锚点, 再插一条线会读成「现在已经在这条之后」,反而暗示它结束了。 时间取插件自己的时钟并与 _plan_item_runtime_status 用同一来源 (_effective_plan_now_minutes),用浏览器本地时间会和模拟时钟打架, 出现「指示线说现在在这、高亮说在那」。 Co-Authored-By: Claude Opus 5 --- page_api.py | 6 ++++++ pages/陪伴面板/app.js | 29 ++++++++++++++++++++----- pages/陪伴面板/css/polish.css | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/page_api.py b/page_api.py index 4af7e4d..0d2690b 100644 --- a/page_api.py +++ b/page_api.py @@ -18733,10 +18733,16 @@ class PrivateCompanionPageApi(PrivateCompanionPageApiUsersGroupsMixin): ) segments.sort(key=lambda item: item.get("start", 99999)) + # 「现在」必须取插件自己的时钟,且与 _plan_item_runtime_status 用同一个来源 + # (_effective_plan_now_minutes 会考虑计划日期是否为今天)。 + # 用浏览器本地时间会和模拟时钟打架,出现「指示线说现在在这、高亮说在那」。 + plan_now_minutes = self.plugin._effective_plan_now_minutes(str(plan.get("date") or "")) return { "plan_date": plan.get("date", ""), "story_date": story.get("date", ""), "detail_day": data.get("detail_enhanced_day", ""), + "now_minutes": plan_now_minutes, + "now_text": self.plugin._minutes_to_hhmm(plan_now_minutes) if plan_now_minutes is not None else "", "segment_count": len(segments), "plan_quality": plan.get("quality") if isinstance(plan.get("quality"), dict) else {}, "segments": segments, diff --git a/pages/陪伴面板/app.js b/pages/陪伴面板/app.js index 2ed7620..88c4875 100644 --- a/pages/陪伴面板/app.js +++ b/pages/陪伴面板/app.js @@ -8390,17 +8390,35 @@ function renderDashboardLifeDesk(overview = {}) { item, })); const entries = [...scheduleEntries, ...changeEntries].sort((left, right) => left.sort - right.sort); + // 「现在」指示线:只在当前时刻落进空档时插入。 + // 有条目正在进行时,那一行的高亮本身就是锚点;此时再插一条线会读成 + // 「现在已经在这条之后」,反而暗示它结束了。空档期则相反——整条时间轴 + // 没有任何锚点,看不出现在在哪两条之间。 + const nowMinutes = Number.isFinite(Number(timeline.now_minutes)) ? Number(timeline.now_minutes) : null; + const nowText = String(timeline.now_text || ""); + const nowInsideSegment = nowMinutes !== null && segments.some((segment) => { + const start = Number(segment.start); + const end = Number(segment.end); + return Number.isFinite(start) && Number.isFinite(end) && start <= nowMinutes && nowMinutes < end; + }); + const nowMarkerIndex = (nowMinutes === null || nowInsideSegment) + ? -1 + : (() => { + const index = entries.findIndex((entry) => entry.sort > nowMinutes); + return index === -1 ? entries.length : index; + })(); + const nowMarkerHtml = ``; // 四段式分组小标:不依赖颜色也能读懂(色觉障碍、打印、换肤时颜色语义会失效)。 // 只在窗口发生变化时插一条,日程条目本身的结构不变。 let lastAgendaWindow = ""; - timelineRoot.innerHTML = entries.length ? entries.map((entry) => { - let windowHeading = ""; + timelineRoot.innerHTML = entries.length ? entries.map((entry, entryIndex) => { + let windowHeading = entryIndex === nowMarkerIndex ? nowMarkerHtml : ""; if (entry.kind === "schedule") { const agendaWindow = String(entry.segment?.agenda_window || ""); if (agendaWindow && agendaWindow !== lastAgendaWindow) { lastAgendaWindow = agendaWindow; const slug = String(entry.segment?.agenda_window_slug || ""); - windowHeading = ``; + windowHeading += ``; } } if (entry.kind === "change") { @@ -8437,10 +8455,11 @@ function renderDashboardLifeDesk(overview = {}) { `; - }).join("") : `
  • 暂无时间轴
  • `; + }).join("") + (nowMarkerIndex === entries.length ? nowMarkerHtml : "") : `
  • 暂无时间轴
  • `; if (typeof requestAnimationFrame === "function") { requestAnimationFrame(() => { - const active = timelineRoot.querySelector(".is-current"); + // 空档期没有 .is-current,退回到「现在」指示线,否则时间轴根本不滚动 + const active = timelineRoot.querySelector(".is-current") || timelineRoot.querySelector(".life-timeline-now"); if (!active || timelineRoot.clientHeight <= 0) return; timelineRoot.scrollTop = Math.max( 0, diff --git a/pages/陪伴面板/css/polish.css b/pages/陪伴面板/css/polish.css index 345e7ee..a8cad44 100644 --- a/pages/陪伴面板/css/polish.css +++ b/pages/陪伴面板/css/polish.css @@ -3162,3 +3162,43 @@ small { height: 1px; background: linear-gradient(to right, var(--line-soft), transparent); } + +/* ── 「现在」指示线 ───────────────────────────────────────────────────── + 只在当前时刻落进日程空档时出现(有条目进行中时,那一行的高亮就是锚点)。 + 用 accent 而非窗口色:它标的是「此刻」,不属于任何一段。 */ +.life-timeline-now { + display: flex; + align-items: center; + gap: 8px; + margin: 6px 0; + padding: 0 2px; + list-style: none; + border: 0; + background: transparent; + min-height: 0; +} + +.life-timeline-now::before { + content: ""; + flex: 0 0 auto; + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--accent); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); +} + +.life-timeline-now > span { + flex: 0 0 auto; + font-size: 11px; + font-weight: 700; + letter-spacing: .1em; + color: var(--accent); +} + +.life-timeline-now::after { + content: ""; + flex: 1 1 auto; + height: 1px; + background: linear-gradient(to right, color-mix(in srgb, var(--accent) 55%, transparent), transparent); +}