Commit 0b32fa25 by 杨北旺

修改上报策略

1 parent 15b127dc
...@@ -7,7 +7,7 @@ class sendStrategy { ...@@ -7,7 +7,7 @@ class sendStrategy {
dataHasSend = true dataHasSend = true
dataHasChange = false dataHasChange = false
syncStorage = false syncStorage = false
failTime = 0 time = 0
is_first_batch_write = false is_first_batch_write = false
DEFAULT_SETTING!: ReportOption DEFAULT_SETTING!: ReportOption
init(options: ReportOption) { init(options: ReportOption) {
...@@ -28,9 +28,17 @@ class sendStrategy { ...@@ -28,9 +28,17 @@ class sendStrategy {
} }
function loopSend() { function loopSend() {
setTimeout(() => { setTimeout(() => {
const totalDdata = storage.getTrack()
_this.time++
if (totalDdata.length === _this.DEFAULT_SETTING.send_count) {
_this.time = 0
_this.batchSend() _this.batchSend()
} else if (_this.time === _this.DEFAULT_SETTING.send_time) {
_this.time = 0
_this.batchSend()
}
loopSend() loopSend()
}, 1000 * _this.DEFAULT_SETTING.send_time * Math.pow(2, _this.failTime)) }, 1000)
} }
loopWrite() loopWrite()
loopSend() loopSend()
...@@ -73,11 +81,9 @@ class sendStrategy { ...@@ -73,11 +81,9 @@ class sendStrategy {
this.dataHasSend = true this.dataHasSend = true
this.dataHasChange = true this.dataHasChange = true
this.batchWrite() this.batchWrite()
this.failTime = 0
} }
sendFail(data: any) { sendFail(data: any) {
this.dataHasSend = true this.dataHasSend = true
this.failTime++
storage.removeUploadData(data) storage.removeUploadData(data)
} }
webrequest(option: { data: any; success: any; fail: any }) { webrequest(option: { data: any; success: any; fail: any }) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!