hunter-open-sdk 0.0.17 → 0.0.19

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) {
@@ -121,11 +128,6 @@ var installDriver = function installDriver() {
121
128
  console.log('安装 error>>', error);
122
129
  console.log('安装 stdout>>>', stdout);
123
130
  console.log('安装 stderr>>>', stderr);
124
- if ((0, _utils.isDev)()) {
125
- (0, _utils2.command)(path.join(process.cwd(), './extraResources/ightools.exe'));
126
- } else {
127
- (0, _utils2.command)(path.join(process.resourcesPath, './extraResources/ightools.exe'));
128
- }
129
131
  checkProcessTimer();
130
132
  if (error) {
131
133
  console.error('驱动安装失败:', error);
@@ -201,12 +203,12 @@ function downloadDriver(onProgress) {
201
203
  console.error('驱动下载失败', err);
202
204
  fileStream.end(); // 确保关闭文件流
203
205
  reject(err);
204
- }).pipe(fileStream).on('finish', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
206
+ }).pipe(fileStream).once('close', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
205
207
  var uncopressing;
206
208
  return _regenerator.default.wrap(function _callee2$(_context2) {
207
209
  while (1) switch (_context2.prev = _context2.next) {
208
210
  case 0:
209
- console.log('=== FINISH 事件被触发 ===');
211
+ console.log('=== CLOSE 事件被触发 ===');
210
212
  console.log('文件下载完成,开始解压...');
211
213
 
212
214
  // 确保最后一次进度回调被调用(100%)
@@ -245,7 +247,7 @@ function downloadDriver(onProgress) {
245
247
  return _context2.stop();
246
248
  }
247
249
  }, _callee2, null, [[3, 11]]);
248
- }))).on('error', function (err) {
250
+ }))).once('error', function (err) {
249
251
  console.error('文件流写入错误:', err);
250
252
  reject(err);
251
253
  });
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.19",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",