From 12200762574be29238b56277e9747532a652e425 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sun, 22 Jun 2025 10:14:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B9=E6=88=9030s=E7=9A=84=E9=97=B4?= =?UTF-8?q?=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/task/worker.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/task/worker.ts b/src/task/worker.ts index 78a551c..b7d0ed8 100644 --- a/src/task/worker.ts +++ b/src/task/worker.ts @@ -13,7 +13,7 @@ class TimeRecorder { endTime: number; duration: number; updateTime: number; - maxDuration: number = 60 * 1000; // 20s; + maxDuration: number = 30 * 1000; // 30s; constructor() { const now = Date.now(); this.startTime = now; @@ -36,11 +36,14 @@ class TimeRecorder { } getClampDuration() { const duration = Date.now() - this.updateTime; + const nextTime = clamp(this.maxDuration - duration, 0, this.maxDuration); + // console.log('getClampDuration', duration, this.maxDuration, 'nextTime', nextTime); + return { duration: duration, maxDuration: this.maxDuration, updateTime: this.updateTime, - nextTime: clamp(this.maxDuration - duration, 0, this.maxDuration), + nextTime: nextTime, }; } time() { @@ -59,8 +62,9 @@ export const worker = new Worker( async (job) => { const timer = new TimeRecorder(); const data = job.data; + if (data.path === 'task' && data.key === 'getUnread') { - console.log('====run time', dayjs().format('YYYY-MM-DD HH:mm:ss')); + console.log('====run time start', dayjs().format('YYYY-MM-DD HH:mm:ss')); timeRecorder.update(); } const res = await taskApp.call(data);