generated from tailored/router-template
fix: 改成30s的间隔
This commit is contained in:
parent
530a4f21f5
commit
1220076257
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user