generated from tailored/router-template
fix: 改成30s的间隔
This commit is contained in:
parent
530a4f21f5
commit
1220076257
@ -13,7 +13,7 @@ class TimeRecorder {
|
|||||||
endTime: number;
|
endTime: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
updateTime: number;
|
updateTime: number;
|
||||||
maxDuration: number = 60 * 1000; // 20s;
|
maxDuration: number = 30 * 1000; // 30s;
|
||||||
constructor() {
|
constructor() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
this.startTime = now;
|
this.startTime = now;
|
||||||
@ -36,11 +36,14 @@ class TimeRecorder {
|
|||||||
}
|
}
|
||||||
getClampDuration() {
|
getClampDuration() {
|
||||||
const duration = Date.now() - this.updateTime;
|
const duration = Date.now() - this.updateTime;
|
||||||
|
const nextTime = clamp(this.maxDuration - duration, 0, this.maxDuration);
|
||||||
|
// console.log('getClampDuration', duration, this.maxDuration, 'nextTime', nextTime);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
duration: duration,
|
duration: duration,
|
||||||
maxDuration: this.maxDuration,
|
maxDuration: this.maxDuration,
|
||||||
updateTime: this.updateTime,
|
updateTime: this.updateTime,
|
||||||
nextTime: clamp(this.maxDuration - duration, 0, this.maxDuration),
|
nextTime: nextTime,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
time() {
|
time() {
|
||||||
@ -59,8 +62,9 @@ export const worker = new Worker(
|
|||||||
async (job) => {
|
async (job) => {
|
||||||
const timer = new TimeRecorder();
|
const timer = new TimeRecorder();
|
||||||
const data = job.data;
|
const data = job.data;
|
||||||
|
|
||||||
if (data.path === 'task' && data.key === 'getUnread') {
|
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();
|
timeRecorder.update();
|
||||||
}
|
}
|
||||||
const res = await taskApp.call(data);
|
const res = await taskApp.call(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user