Home > front end >  A very tricky question interface call
A very tricky question interface call

Time:12-01

A vue chat software, using the timer online every five minutes to initiate a background request, after five times call timer cleared, the user does not exit chat software let it always hangs, the second day how to revive the timer automatically, begging, put forward valuable ideas, thank you very much!!!!!!

CodePudding user response:

Do not refresh the page can judge that time, recording the time of the day before and then judge the current time is greater than the execution time 24 hours timer, refresh the page each time the timer to go,

 
Var time=new Date (' 2020-08-19 ')
If (Date. Now () - time & gt; 86400000) {
//execution timers
}

CodePudding user response:

The third, fourth, fifth,,, many days later, the user may have been hung

CodePudding user response:

When removing the timer record the date and then walk a timer for the current date when two different dates again after wake up wake up before the timer clear behind this timer

CodePudding user response:

More than 24 hours the time not at the same time!!!!!!!!!!!

CodePudding user response:

SetInterval, 5 minutes at a time always execute

Two global variables: the last execution date (format YYYYMMDD), number of executions

The callback function:
First to get the current date, and the last is the implementation date, if the same, and the number is less than 5, execute the business logic, execution times + 1
If not the same, the number is set to 0, the execution date set to the current date, execute the business logic, execution times + 1
  • Related