feat: 新数据高亮每 30 秒自动清除一次

- 新增独立定时器 startHlAutoClear:每 hlAutoClearSec(默认30)秒扫描一次,
  若仍有高亮则清空并重新渲染表格与计数徽标;无高亮时不打扰。
- 既保留'比闪一下停留更久'的可见性,又避免绿色底纹长期堆积失去重点。
- 清除按钮 tooltip 同步说明'每 30 秒自动清除一次'。
- 与手动清除(#btnClearHl)、切换项目重置高亮互不冲突。
This commit is contained in:
2026-09-10 10:55:19 +08:00
parent 0174b2abc2
commit e031b3858e
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -25,7 +25,9 @@
connFail: 0, connFail: 0,
historyDisplay: 'click', // click=点击成员弹窗查看历史;inline=成绩明细内全部展开 historyDisplay: 'click', // click=点击成员弹窗查看历史;inline=成绩明细内全部展开
exportSort: 'time', // time=按提交时间;sid=按学号 exportSort: 'time', // time=按提交时间;sid=按学号
highlight: new Set(), // 出现过新提交/新数据的学号,绿色底纹常亮直到清除 highlight: new Set(), // 出现过新提交/新数据的学号,绿色底纹
hlTimer: null, // 自动清除高亮的定时器
hlAutoClearSec: 30, // 新数据高亮每隔多少秒自动清除一次
}; };
/* ---------------- 本地存储 ---------------- */ /* ---------------- 本地存储 ---------------- */
@@ -703,6 +705,20 @@
state.timer = setInterval(() => refresh(true), sec * 1000); state.timer = setInterval(() => refresh(true), sec * 1000);
} }
/* ---------------- 新数据高亮自动清除 ---------------- */
// 绿色高亮用于标记"有更新的成员",停留更易察觉(不再只闪一下),
// 但长时间堆积会失去重点——故每 hlAutoClearSec 秒自动清除一次。
function startHlAutoClear() {
if (state.hlTimer) clearInterval(state.hlTimer);
const sec = state.hlAutoClearSec || 30;
state.hlTimer = setInterval(() => {
if (state.highlight.size === 0) return; // 无高亮时不打扰
state.highlight = new Set();
renderTable();
renderHlBadge();
}, sec * 1000);
}
/* ---------------- 全屏 ---------------- */ /* ---------------- 全屏 ---------------- */
function toggleFullscreen() { function toggleFullscreen() {
const el = document.documentElement; const el = document.documentElement;
@@ -1135,6 +1151,7 @@
// 启动:主界面在 PHP 端已做会话校验(未登录会跳到 login.php),此处直接加载数据 // 启动:主界面在 PHP 端已做会话校验(未登录会跳到 login.php),此处直接加载数据
schedule(); schedule();
startHlAutoClear(); // 新数据高亮每 30s 自动清除一次
loadProjects(); loadProjects();
// 4) 读取展示偏好(历史成绩展示方式 / 导出排序),避免必须打开设置弹窗才生效 // 4) 读取展示偏好(历史成绩展示方式 / 导出排序),避免必须打开设置弹窗才生效
+1 -1
View File
@@ -109,7 +109,7 @@ $rosterCount = Roster::count();
<div class="panel-head"> <div class="panel-head">
<h2>成绩明细 <small id="tableHint"></small></h2> <h2>成绩明细 <small id="tableHint"></small></h2>
<div class="updated"> <div class="updated">
<button class="btn sm" id="btnClearHl" hidden title="清除新数据的绿色高亮标记">清除高亮 <b id="hlBadge">0</b></button> <button class="btn sm" id="btnClearHl" hidden title="清除新数据的绿色高亮标记(每 30 秒自动清除一次)">清除高亮 <b id="hlBadge">0</b></button>
最后更新:<span id="lastUpdate">—</span><i id="liveDot" class="dot"></i> 最后更新:<span id="lastUpdate">—</span><i id="liveDot" class="dot"></i>
</div> </div>
</div> </div>