From ed98cbe8268bbe6e04bf58161d4fe0480d176cae Mon Sep 17 00:00:00 2001 From: Orion Date: Thu, 9 Jul 2026 17:41:48 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BC=98=E5=8C=96=E7=94=9F?= =?UTF-8?q?=E5=91=BD=E5=91=A8=E6=9C=9F=E8=AE=B0=E5=BD=95=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=94=B6=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/patch_admin_timeline_ui.py | 34 ++++++++++++------------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/scripts/patch_admin_timeline_ui.py b/scripts/patch_admin_timeline_ui.py index da18ffe..bf28182 100644 --- a/scripts/patch_admin_timeline_ui.py +++ b/scripts/patch_admin_timeline_ui.py @@ -60,10 +60,13 @@ def write_detail_collapse_script(theme_dir: Path) -> bool: return False js_path = assets / 'fcb-detail-collapse.js' js = r'''(() => { - const EVENT_RE = /(第\s*\d+\s*次取件|取件\s*[##]\s*\d+|Retrieval\s*#\s*\d+)/i; const LIFE_RE = /(生命周期|Lifecycle)/i; const STATE = new WeakMap(); - const getRows = section => [...section.querySelectorAll('div.grid')].filter(row => EVENT_RE.test(row.textContent || '')); + const getRows = section => [...section.querySelectorAll('div.grid')].filter(row => { + if (row.classList.contains('fcbx-life-row-skip')) return false; + const text = row.textContent || ''; + return !!row.querySelector('span.rounded-full') && !LIFE_RE.test(text); + }); const apply = section => { const rows = getRows(section); if (rows.length <= 3) return; @@ -71,7 +74,7 @@ def write_detail_collapse_script(theme_dir: Path) -> bool: rows.forEach((row, idx) => { row.hidden = !expanded && idx >= 3; }); const btn = section.querySelector(':scope > .fcbx-life-toggle') || section.querySelector('.fcbx-life-toggle'); if (btn) { - btn.textContent = expanded ? '收起取件记录' : `展开全部取件记录(共 ${rows.length} 次)`; + btn.textContent = expanded ? '收起生命周期记录' : `展开全部生命周期记录(共 ${rows.length} 条)`; btn.setAttribute('aria-expanded', expanded ? 'true' : 'false'); } }; @@ -86,29 +89,18 @@ def write_detail_collapse_script(theme_dir: Path) -> bool: btn = document.createElement('button'); btn.type = 'button'; btn.className = 'fcbx-life-toggle mt-3 rounded-lg border px-3 py-2 text-sm font-medium transition'; - btn.style.cssText = 'border-color:rgba(148,163,184,.55);display:inline-flex;align-items:center;gap:.35rem;touch-action:manipulation;user-select:none;'; + btn.style.cssText = 'border-color:rgba(148,163,184,.55);display:inline-flex;align-items:center;gap:.35rem;touch-action:manipulation;user-select:none;cursor:pointer;'; + btn.onclick = event => { + event.preventDefault(); + event.stopPropagation(); + STATE.set(section, STATE.get(section) !== true); + apply(section); + }; section.appendChild(btn); } apply(section); }; const markRows = () => document.querySelectorAll('section').forEach(ensureSection); - const toggle = target => { - const btn = target.closest?.('.fcbx-life-toggle'); - if (!btn) return false; - const section = btn.closest('section'); - if (!section) return false; - STATE.set(section, STATE.get(section) !== true); - apply(section); - return true; - }; - const onToggle = event => { - if (!toggle(event.target)) return; - event.preventDefault(); - event.stopPropagation(); - event.stopImmediatePropagation?.(); - }; - document.addEventListener('pointerdown', onToggle, true); - document.addEventListener('click', onToggle, true); let raf = 0; const schedule = () => { cancelAnimationFrame(raf); raf = requestAnimationFrame(markRows); }; window.addEventListener('hashchange', schedule);