hunter-open-sdk 0.0.16 → 0.0.18
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.
|
@@ -36,17 +36,7 @@ var Service = /*#__PURE__*/function () {
|
|
|
36
36
|
mainWindow.webContents.send("checkDriver", true);
|
|
37
37
|
} else {
|
|
38
38
|
mainWindow.webContents.send("checkDriver", false);
|
|
39
|
-
|
|
40
|
-
(0, _winDriver.downloadDriver)(function (percent) {
|
|
41
|
-
console.log('下载进度:', percent + '%');
|
|
42
|
-
mainWindow.webContents.send("downloadProgress", percent);
|
|
43
|
-
}).then(function () {
|
|
44
|
-
console.log('驱动下载安装成功');
|
|
45
|
-
mainWindow.webContents.send("checkDriver", true);
|
|
46
|
-
}).catch(function (err) {
|
|
47
|
-
console.error('驱动下载安装失败:', err);
|
|
48
|
-
mainWindow.webContents.send("checkDriver", false);
|
|
49
|
-
});
|
|
39
|
+
(0, _winDriver.downloadDriver)(mainWindow);
|
|
50
40
|
}
|
|
51
41
|
});
|
|
52
42
|
}
|
|
@@ -29,6 +29,13 @@ var msiStr = 'AppleMobileDeviceService';
|
|
|
29
29
|
var cmdStr = process.platform === 'win32' ? 'tasklist' : 'ps aux';
|
|
30
30
|
var CACHE_PATH = (0, _utils.isDev)() ? path.join(process.cwd(), './cache') : path.join(process.resourcesPath, './cache');
|
|
31
31
|
var filePath = path.join(CACHE_PATH, './iTunesOL_Lite_64_12.10.0.7.zip');
|
|
32
|
+
|
|
33
|
+
// 确保缓存目录存在,避免后续写入流抛出 ENOENT
|
|
34
|
+
try {
|
|
35
|
+
_fsExtra.default.ensureDirSync(CACHE_PATH);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error('创建缓存目录失败:', e);
|
|
38
|
+
}
|
|
32
39
|
var checkProcess = function checkProcess() {
|
|
33
40
|
return new Promise(function (resolve, reject) {
|
|
34
41
|
exec(cmdStr, function (err, stdout, stderr) {
|
|
@@ -170,18 +177,14 @@ function downloadDriver(onProgress) {
|
|
|
170
177
|
var received = 0;
|
|
171
178
|
var total = 0;
|
|
172
179
|
|
|
173
|
-
//
|
|
174
|
-
var lastProgressCall = 0;
|
|
180
|
+
// 进度回调限流:进度变化超过5%时调用
|
|
175
181
|
var lastProgressPercent = 0;
|
|
176
|
-
var PROGRESS_THROTTLE_MS = 100; // 100ms限流
|
|
177
182
|
var PROGRESS_THRESHOLD = 5; // 5%阈值
|
|
178
183
|
|
|
179
184
|
var throttledProgressCallback = function throttledProgressCallback(percent) {
|
|
180
|
-
var
|
|
181
|
-
var shouldCall = now - lastProgressCall >= PROGRESS_THROTTLE_MS || Math.abs(percent - lastProgressPercent) >= PROGRESS_THRESHOLD;
|
|
185
|
+
var shouldCall = Math.abs(percent - lastProgressPercent) >= PROGRESS_THRESHOLD;
|
|
182
186
|
if (shouldCall && onProgress) {
|
|
183
187
|
onProgress(percent);
|
|
184
|
-
lastProgressCall = now;
|
|
185
188
|
lastProgressPercent = percent;
|
|
186
189
|
console.log("\u4E0B\u8F7D\u8FDB\u5EA6: ".concat(percent, "% (").concat(received, "/").concat(total, ")"));
|
|
187
190
|
}
|
|
@@ -205,12 +208,12 @@ function downloadDriver(onProgress) {
|
|
|
205
208
|
console.error('驱动下载失败', err);
|
|
206
209
|
fileStream.end(); // 确保关闭文件流
|
|
207
210
|
reject(err);
|
|
208
|
-
}).pipe(fileStream).
|
|
211
|
+
}).pipe(fileStream).once('close', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
209
212
|
var uncopressing;
|
|
210
213
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
211
214
|
while (1) switch (_context2.prev = _context2.next) {
|
|
212
215
|
case 0:
|
|
213
|
-
console.log('===
|
|
216
|
+
console.log('=== CLOSE 事件被触发 ===');
|
|
214
217
|
console.log('文件下载完成,开始解压...');
|
|
215
218
|
|
|
216
219
|
// 确保最后一次进度回调被调用(100%)
|
|
@@ -249,7 +252,7 @@ function downloadDriver(onProgress) {
|
|
|
249
252
|
return _context2.stop();
|
|
250
253
|
}
|
|
251
254
|
}, _callee2, null, [[3, 11]]);
|
|
252
|
-
}))).
|
|
255
|
+
}))).once('error', function (err) {
|
|
253
256
|
console.error('文件流写入错误:', err);
|
|
254
257
|
reject(err);
|
|
255
258
|
});
|