feat: add a now marker to the overview timeline during schedule gaps
条目之间本来就有空隙,此时没有任何一行是高亮的,时间轴完全丢失「现在」这个 锚点——看不出当前时刻落在哪两条之间,滚动定位也失效(原逻辑只找 .is-current)。 指示线只在当前时刻落进空档时出现:有条目进行中时,那一行的高亮本身就是锚点, 再插一条线会读成「现在已经在这条之后」,反而暗示它结束了。 时间取插件自己的时钟并与 _plan_item_runtime_status 用同一来源 (_effective_plan_now_minutes),用浏览器本地时间会和模拟时钟打架, 出现「指示线说现在在这、高亮说在那」。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
这个提交存在于:
父节点
eb8b1dd3b1
当前提交
a1582d5741
共有 3 个文件被更改,包括 70 次插入 和 5 次删除
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 = `<li class="life-timeline-now" role="presentation"><span>现在${nowText ? ` ${escapeHtml(nowText)}` : ""}</span></li>`;
|
||||
// 四段式分组小标:不依赖颜色也能读懂(色觉障碍、打印、换肤时颜色语义会失效)。
|
||||
// 只在窗口发生变化时插一条,日程条目本身的结构不变。
|
||||
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 = `<li class="life-timeline-window is-window-${escapeHtml(slug)}" role="presentation"><span>${escapeHtml(agendaWindow)}</span></li>`;
|
||||
windowHeading += `<li class="life-timeline-window is-window-${escapeHtml(slug)}" role="presentation"><span>${escapeHtml(agendaWindow)}</span></li>`;
|
||||
}
|
||||
}
|
||||
if (entry.kind === "change") {
|
||||
|
|
@ -8437,10 +8455,11 @@ function renderDashboardLifeDesk(overview = {}) {
|
|||
</div>
|
||||
</li>
|
||||
`;
|
||||
}).join("") : `<li class="life-desk-empty">暂无时间轴</li>`;
|
||||
}).join("") + (nowMarkerIndex === entries.length ? nowMarkerHtml : "") : `<li class="life-desk-empty">暂无时间轴</li>`;
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用