fix: 心跳倒计时按服务器剩余时间显示,服务重启后页面继续更新
This commit is contained in:
@@ -223,7 +223,7 @@ function workerTitle(row: StudyWorker) {
|
||||
}
|
||||
|
||||
function showHeartbeat(row: StudyWorker) {
|
||||
return row.heartbeat_in > 0 || (row.interval > 0 && row.heartbeat_at > 0);
|
||||
return row.interval > 0 && (row.heartbeat_in > 0 || row.heartbeat_at > 0);
|
||||
}
|
||||
|
||||
function workerCount(row: StudyWorker) {
|
||||
@@ -242,19 +242,9 @@ function hoursRefreshLeft() {
|
||||
|
||||
function heartbeatLeft(row: StudyWorker) {
|
||||
void nowTick.value;
|
||||
if (row.heartbeat_in > 0) {
|
||||
const elapsed = (Date.now() - row.seen_at) / 1000;
|
||||
const cap = row.interval > 0 ? row.interval : row.heartbeat_in;
|
||||
const left = Math.max(0, Math.min(cap, row.heartbeat_in - elapsed));
|
||||
return `${Math.ceil(left)}s`;
|
||||
}
|
||||
const now = Date.now() / 1000;
|
||||
const cycle = Math.max(0, row.interval);
|
||||
let left = row.heartbeat_at - now;
|
||||
if (left < 0 && cycle > 0) {
|
||||
left = cycle - ((now - row.heartbeat_at) % cycle);
|
||||
}
|
||||
return `${Math.max(0, Math.ceil(left))}s`;
|
||||
const elapsed = (Date.now() - row.seen_at) / 1000;
|
||||
const left = Math.max(0, row.heartbeat_in - elapsed);
|
||||
return `${Math.ceil(left)}s`;
|
||||
}
|
||||
|
||||
async function loadSummary() {
|
||||
@@ -606,9 +596,15 @@ async function saveProxy() {
|
||||
}
|
||||
|
||||
let lastStudySeq = 0;
|
||||
let lastStudyBoot = "";
|
||||
|
||||
function applyStudyControl(payload: Record<string, unknown>) {
|
||||
const seq = typeof payload.seq === "number" ? payload.seq : 0;
|
||||
const boot = typeof payload.boot === "string" ? payload.boot : "";
|
||||
if (boot && boot !== lastStudyBoot) {
|
||||
lastStudyBoot = boot;
|
||||
lastStudySeq = 0;
|
||||
}
|
||||
if (seq > 0 && seq < lastStudySeq) return;
|
||||
if (seq > 0) lastStudySeq = seq;
|
||||
studyControl.value = {
|
||||
|
||||
Reference in New Issue
Block a user