diff --git a/agenda_contracts.py b/agenda_contracts.py
index 0598be8..dc995f1 100644
--- a/agenda_contracts.py
+++ b/agenda_contracts.py
@@ -37,6 +37,27 @@ WINDOW_DEFINITIONS = (
("晚上", 18 * 60, 22 * 60),
)
WINDOW_NAMES = {item[0] for item in WINDOW_DEFINITIONS}
+# 渲染层用的窗口标识(CSS 类名/主题变量都用它,避免把中文名写进样式表)
+WINDOW_SLUGS = {"深夜": "late_night", "早晨": "morning", "下午": "afternoon", "晚上": "evening"}
+
+
+def window_for_minutes(minutes: Any) -> str:
+ """把「当日分钟数」归入四段式窗口。
+
+ 页面时间轴按分钟排段,没有 datetime 可用;跨零点的段会带 +1440 偏移,先取模。
+ 深夜跨零点(22:00-06:00),所以它的判定要拆成两截。
+ """
+ try:
+ value = int(minutes) % (24 * 60)
+ except (TypeError, ValueError):
+ return ""
+ for name, start, end in WINDOW_DEFINITIONS:
+ if start < end:
+ if start <= value < end:
+ return name
+ elif value >= start or value < end:
+ return name
+ return ""
def timezone_or_default(timezone_name: Any = "Asia/Shanghai") -> ZoneInfo:
diff --git a/page_api.py b/page_api.py
index 009a134..4af7e4d 100644
--- a/page_api.py
+++ b/page_api.py
@@ -27,6 +27,7 @@ from quart import request, send_file
from .constants import DEFAULT_DAILY_PLAN_ITEMS, PAGE_FONT_NAMES, PAGE_THEME_NAMES, PLUGIN_NAME, _REASON_TEXT
from .config_migration import _ensure_config_parent_dir
+from .agenda_contracts import WINDOW_SLUGS, window_for_minutes
from .helpers import _flat_get, _normalize_timezone_name, _redact_outbound_secrets, _safe_int, _set_into_config, _set_today_key_timezone, _strip_internal_message_blocks, _text_looks_garbled, _text_similarity, _today_key
from .page_api_users_groups import PrivateCompanionPageApiUsersGroupsMixin
from .planning import evaluate_daily_plan_quality, generate_daily_plan, generate_detail_enhancement
@@ -18663,6 +18664,10 @@ class PrivateCompanionPageApi(PrivateCompanionPageApiUsersGroupsMixin):
{
"key": str(key),
"window": segment.get("window", str(key)),
+ # 四段式窗口。此前时间轴只有条目自己的时钟区间,
+ # 与运维页「当前时间段」、归档里的窗口快照三者口径各说各的。
+ "agenda_window": window_for_minutes(segment.get("start")),
+ "agenda_window_slug": WINDOW_SLUGS.get(window_for_minutes(segment.get("start")), ""),
"start": segment.get("start", 99999),
"end": segment.get("end", 99999),
"lifecycle": lifecycle,
@@ -18706,6 +18711,8 @@ class PrivateCompanionPageApi(PrivateCompanionPageApiUsersGroupsMixin):
{
"key": key,
"window": f"{self.plugin._minutes_to_hhmm(start)}-{self.plugin._minutes_to_hhmm(end)}",
+ "agenda_window": window_for_minutes(start),
+ "agenda_window_slug": WINDOW_SLUGS.get(window_for_minutes(start), ""),
"start": start,
"end": end,
"lifecycle": self.plugin._plan_item_runtime_status(plan, item, index),
diff --git a/pages/陪伴面板/app.js b/pages/陪伴面板/app.js
index be17a97..2ed7620 100644
--- a/pages/陪伴面板/app.js
+++ b/pages/陪伴面板/app.js
@@ -8390,9 +8390,21 @@ function renderDashboardLifeDesk(overview = {}) {
item,
}));
const entries = [...scheduleEntries, ...changeEntries].sort((left, right) => left.sort - right.sort);
+ // 四段式分组小标:不依赖颜色也能读懂(色觉障碍、打印、换肤时颜色语义会失效)。
+ // 只在窗口发生变化时插一条,日程条目本身的结构不变。
+ let lastAgendaWindow = "";
timelineRoot.innerHTML = entries.length ? entries.map((entry) => {
+ let windowHeading = "";
+ 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 = `
${escapeHtml(agendaWindow)}`;
+ }
+ }
if (entry.kind === "change") {
- return `
+ return windowHeading + `
@@ -8410,8 +8422,9 @@ function renderDashboardLifeDesk(overview = {}) {
const windowMatch = windowText.match(/^(\d{1,2}:\d{2})\s*[-~至]\s*(\d{1,2}:\d{2})$/);
const startText = windowMatch ? windowMatch[1] : windowText;
const endText = windowMatch ? windowMatch[2] : "";
- return `
-
+ const windowSlug = String(segment.agenda_window_slug || "");
+ return windowHeading + `
+