hunter-open-sdk 0.0.17 → 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) {
@@ -201,12 +208,12 @@ function downloadDriver(onProgress) {
201
208
  console.error('驱动下载失败', err);
202
209
  fileStream.end(); // 确保关闭文件流
203
210
  reject(err);
204
- }).pipe(fileStream).on('finish', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
211
+ }).pipe(fileStream).once('close', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
205
212
  var uncopressing;
206
213
  return _regenerator.default.wrap(function _callee2$(_context2) {
207
214
  while (1) switch (_context2.prev = _context2.next) {
208
215
  case 0:
209
- console.log('=== FINISH 事件被触发 ===');
216
+ console.log('=== CLOSE 事件被触发 ===');
210
217
  console.log('文件下载完成,开始解压...');
211
218
 
212
219
  // 确保最后一次进度回调被调用(100%)
@@ -245,7 +252,7 @@ function downloadDriver(onProgress) {
245
252
  return _context2.stop();
246
253
  }
247
254
  }, _callee2, null, [[3, 11]]);
248
- }))).on('error', function (err) {
255
+ }))).once('error', function (err) {
249
256
  console.error('文件流写入错误:', err);
250
257
  reject(err);
251
258
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hunter-open-sdk",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",