hunter-open-sdk 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -170,18 +170,14 @@ function downloadDriver(onProgress) {
|
|
|
170
170
|
var received = 0;
|
|
171
171
|
var total = 0;
|
|
172
172
|
|
|
173
|
-
//
|
|
174
|
-
var lastProgressCall = 0;
|
|
173
|
+
// 进度回调限流:进度变化超过5%时调用
|
|
175
174
|
var lastProgressPercent = 0;
|
|
176
|
-
var PROGRESS_THROTTLE_MS = 100; // 100ms限流
|
|
177
175
|
var PROGRESS_THRESHOLD = 5; // 5%阈值
|
|
178
176
|
|
|
179
177
|
var throttledProgressCallback = function throttledProgressCallback(percent) {
|
|
180
|
-
var
|
|
181
|
-
var shouldCall = now - lastProgressCall >= PROGRESS_THROTTLE_MS || Math.abs(percent - lastProgressPercent) >= PROGRESS_THRESHOLD;
|
|
178
|
+
var shouldCall = Math.abs(percent - lastProgressPercent) >= PROGRESS_THRESHOLD;
|
|
182
179
|
if (shouldCall && onProgress) {
|
|
183
180
|
onProgress(percent);
|
|
184
|
-
lastProgressCall = now;
|
|
185
181
|
lastProgressPercent = percent;
|
|
186
182
|
console.log("\u4E0B\u8F7D\u8FDB\u5EA6: ".concat(percent, "% (").concat(received, "/").concat(total, ")"));
|
|
187
183
|
}
|