Commit 9e4805ee by yixinjj

添加停止逻辑

1 parent 8eba779c
...@@ -215,7 +215,7 @@ export default { ...@@ -215,7 +215,7 @@ export default {
* 这个函数的目的是在一定条件下,通过持续轮询来执行上传记录的操作。它检查一个队列(snapshot)的大小。如果队列为空,它会等待十分钟(1000 毫秒 * 60 秒 * 10 分钟)后再次检查。如果队列中有记录,它会取出一条记录并上传它。 * 这个函数的目的是在一定条件下,通过持续轮询来执行上传记录的操作。它检查一个队列(snapshot)的大小。如果队列为空,它会等待十分钟(1000 毫秒 * 60 秒 * 10 分钟)后再次检查。如果队列中有记录,它会取出一条记录并上传它。
*/ */
polling() { polling() {
console.log(this.snapshot.size, "this.snapshot.size"); if (this.snapshot === null) return;
if (this.snapshot.size == 0) { if (this.snapshot.size == 0) {
this.enQueue(); this.enQueue();
setTimeout(() => { setTimeout(() => {
...@@ -228,5 +228,12 @@ export default { ...@@ -228,5 +228,12 @@ export default {
this.uploadRecord(record); this.uploadRecord(record);
} }
}, },
stopPolling() {
this.snapshot.clear();
this.snapshot = null
},
onUnload() {
this.stopPolling();
}
}, },
}; };
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!