|
|
@@ -249,19 +249,16 @@ export default {
|
|
|
const now = new Date()
|
|
|
let currentEndDate = null
|
|
|
let next = null
|
|
|
- if (current) {
|
|
|
- currentEndDate = getFinishDate(current, now)
|
|
|
- } else {
|
|
|
+ if (!current) {
|
|
|
for (let i = 0; i < this.timeline.length; i++) {
|
|
|
const event = this.timeline[i]
|
|
|
if (!current && isHit(event, now)) {
|
|
|
current = event
|
|
|
- currentEndDate = getFinishDate(current, now)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- console.log('currentEndDate', currentEndDate)
|
|
|
+ currentEndDate = current && getFinishDate(current, now)
|
|
|
let nextStartDate = null
|
|
|
for (let i = 0; i < this.timeline.length; i++) {
|
|
|
const event = this.timeline[i]
|
|
|
@@ -276,14 +273,24 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ console.log('current', current, currentEndDate)
|
|
|
+ console.log('next', next, nextStartDate)
|
|
|
+ if (nextStartDate && (!currentEndDate || currentEndDate > nextStartDate)) {
|
|
|
+ currentEndDate = nextStartDate
|
|
|
+ }
|
|
|
+ this.current = current && this.getEventInfo(current, getStartDate(current, now), currentEndDate)
|
|
|
+ this.next = next && this.getEventInfo(next, nextStartDate)
|
|
|
clearTimeout(this.$timer)
|
|
|
if (currentEndDate) {
|
|
|
- this.$timer = setTimeout(() => {
|
|
|
- this.checkTimeline(this.next)
|
|
|
- }, Math.min(604800000, currentEndDate - now))
|
|
|
+ const delay = currentEndDate - now
|
|
|
+ // delay有最大限制2^31-1,超过后会直接执行
|
|
|
+ // 当前限制最多1天
|
|
|
+ if (delay > 86400000) {
|
|
|
+ this.$timer = setTimeout(this.checkTimeline, 86400000, current)
|
|
|
+ } else {
|
|
|
+ this.$timer = setTimeout(this.checkTimeline, delay, next)
|
|
|
+ }
|
|
|
}
|
|
|
- this.current = current && this.getEventInfo(current, getStartDate(current, now), nextStartDate > currentEndDate ? currentEndDate : nextStartDate)
|
|
|
- this.next = next && this.getEventInfo(next, nextStartDate)
|
|
|
},
|
|
|
getEventInfo (event, startDate, endDate) {
|
|
|
event.invoke?.()
|