hunter-open-sdk 0.0.20 → 0.0.21

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.
@@ -15,6 +15,7 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
15
15
  // import { app } from 'electron'
16
16
  // import { command } from '../../utils/utils.command'
17
17
 
18
+ var Sentry = require("@sentry/browser");
18
19
  var sudo = require('sudo-prompt');
19
20
  var path = require('path');
20
21
  var fs = require('fs');
@@ -35,6 +36,7 @@ try {
35
36
  _fsExtra.default.ensureDirSync(CACHE_PATH);
36
37
  } catch (e) {
37
38
  console.error('创建缓存目录失败:', e);
39
+ Sentry.captureException('创建缓存目录失败:' + JSON.stringify(e));
38
40
  }
39
41
  var checkProcess = function checkProcess() {
40
42
  return new Promise(function (resolve, reject) {
@@ -131,6 +133,7 @@ var installDriver = function installDriver() {
131
133
  checkProcessTimer();
132
134
  if (error) {
133
135
  console.error('驱动安装失败:', error);
136
+ Sentry.captureException('驱动安装失败:' + JSON.stringify(error));
134
137
  reject(error); // 安装失败
135
138
  } else {
136
139
  console.log('驱动安装成功');
@@ -148,6 +151,7 @@ var uncopressingFile = function uncopressingFile(filePath) {
148
151
  resolve(true);
149
152
  }).catch(function (err) {
150
153
  console.error('文件解压失败:', err);
154
+ Sentry.captureException('文件解压失败:' + JSON.stringify(err));
151
155
  resolve(false);
152
156
  });
153
157
  });
@@ -201,6 +205,7 @@ function downloadDriver(onProgress) {
201
205
  }
202
206
  }).on('error', function (err) {
203
207
  console.error('驱动下载失败', err);
208
+ Sentry.captureException('驱动下载失败:' + JSON.stringify(err));
204
209
  fileStream.end(); // 确保关闭文件流
205
210
  reject(err);
206
211
  }).pipe(fileStream).once('close', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
@@ -229,26 +234,30 @@ function downloadDriver(onProgress) {
229
234
  resolve();
230
235
  }).catch(function (err) {
231
236
  console.error('驱动安装失败:', err);
237
+ Sentry.captureException('驱动安装失败:' + JSON.stringify(err));
232
238
  reject(err);
233
239
  });
234
240
  } else {
235
241
  console.error('解压失败');
242
+ Sentry.captureException('解压失败');
236
243
  reject(new Error('解压失败'));
237
244
  }
238
- _context2.next = 15;
245
+ _context2.next = 16;
239
246
  break;
240
247
  case 11:
241
248
  _context2.prev = 11;
242
249
  _context2.t0 = _context2["catch"](3);
243
250
  console.error('解压或安装过程中出错:', _context2.t0);
251
+ Sentry.captureException('解压或安装过程中出错:' + JSON.stringify(_context2.t0));
244
252
  reject(_context2.t0);
245
- case 15:
253
+ case 16:
246
254
  case "end":
247
255
  return _context2.stop();
248
256
  }
249
257
  }, _callee2, null, [[3, 11]]);
250
258
  }))).once('error', function (err) {
251
259
  console.error('文件流写入错误:', err);
260
+ Sentry.captureException('文件流写入错误:' + JSON.stringify(err));
252
261
  reject(err);
253
262
  });
254
263
  });
@@ -1,35 +1,77 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var _path = _interopRequireDefault(require("path"));
7
9
  var _utils = require("../utils/utils.global");
8
- var GetGeneralReport = function GetGeneralReport(params, callBack) {
9
- var reportRes = (0, _utils.callHunterInspectionKit)('InspectionKit', params, 'saas_report', params);
10
- if (reportRes) {
11
- var reportResObj = JSON.parse(reportRes);
12
- var Code = reportResObj.Code,
13
- Data = reportResObj.Data;
14
- if (Code == 0 && Data) {
15
- callBack({
16
- code: 0,
17
- data: Data,
18
- message: '获取报告成功'
19
- });
20
- } else {
21
- callBack({
22
- code: -1,
23
- data: {},
24
- message: '获取报告结果为空'
25
- });
10
+ // 预定义worker
11
+ var worker = null;
12
+
13
+ // 获取进程类型
14
+ function getProccessType() {
15
+ // console.log('process.type', process.type)
16
+ return process.type;
17
+ }
18
+
19
+ // 是否在主进程
20
+ function isInMainProcess() {
21
+ return getProccessType() === 'browser';
22
+ }
23
+
24
+ // 是否在渲染进程
25
+ // eslint-disable-next-line no-unused-vars
26
+ function isInRenderProcess() {
27
+ return getProccessType() === 'renderer';
28
+ }
29
+
30
+ // 初始化worker
31
+ function initWorker() {
32
+ if (!worker) {
33
+ worker = new Worker('file://' + _path.default.resolve(__dirname, "./worker.js"));
34
+ }
35
+ }
36
+
37
+ // 添加worker监听
38
+ function addWorkerListener(callBack) {
39
+ worker && (worker.onmessage = function (event) {
40
+ // console.log('main thread onmessage event.data', event.data)
41
+
42
+ var _event$data = event.data,
43
+ type = _event$data.type,
44
+ data = _event$data.data;
45
+ switch (type) {
46
+ case 'getGeneralReportSuccess':
47
+ callBack(data);
48
+ break;
49
+ case 'getGeneralReportFail':
50
+ callBack(data);
51
+ break;
26
52
  }
27
- } else {
28
- callBack({
29
- code: -1,
30
- data: {},
31
- message: '获取报告失败'
32
- });
53
+ });
54
+ }
55
+
56
+ // 发起获取报告消息
57
+ function getReport(params) {
58
+ worker && worker.postMessage({
59
+ type: 'getGeneralReport',
60
+ params: params
61
+ });
62
+ }
63
+
64
+ // 获取报告
65
+ function GetGeneralReport(params, callBack) {
66
+ // 如果是在主进程,则直接获取报告
67
+ if (isInMainProcess()) {
68
+ var reportRes = (0, _utils.getGeneralReportCallKit)(params);
69
+ return callBack(reportRes.data);
33
70
  }
34
- };
71
+
72
+ // 如果是在渲染进程,则通过worker获取报告
73
+ initWorker();
74
+ addWorkerListener(callBack);
75
+ getReport(params);
76
+ }
35
77
  var _default = exports.default = GetGeneralReport;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _utils = require("../utils/utils.global");
4
+ // 处理主进程消息
5
+ function onMainMessage(event) {
6
+ // console.log('worker thread worker onmessage event.data', event.data)
7
+
8
+ var _event$data = event.data,
9
+ type = _event$data.type,
10
+ params = _event$data.params;
11
+ switch (type) {
12
+ case 'getGeneralReport':
13
+ var reportRes = (0, _utils.getGeneralReportCallKit)(params);
14
+ self.postMessage(reportRes);
15
+ break;
16
+ default:
17
+ break;
18
+ }
19
+ }
20
+ self.onmessage = onMainMessage;
package/lib/index.js CHANGED
@@ -8,6 +8,12 @@ exports.default = void 0;
8
8
  var _registerEvent = _interopRequireDefault(require("./registerEvent"));
9
9
  var _getGeneralReport = _interopRequireDefault(require("./getGeneralReport"));
10
10
  var _getAndroidSn = _interopRequireDefault(require("./getAndroidSn"));
11
+ var Sentry = require("@sentry/browser");
12
+ Sentry.init({
13
+ dsn: "https://8a5296c59083430fbac0756f56ddbf5d@sentry.zhuanzhuan.com/2300",
14
+ tracesSampleRate: 1.0
15
+ });
16
+ console.log('Sentry initialized');
11
17
  // 初始化
12
18
  var _default = exports.default = {
13
19
  registerEvent: _registerEvent.default,
@@ -8,13 +8,13 @@ exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _utils = require("../utils/utils");
11
- var _utils2 = require("../utils/utils.initDll");
12
11
  var _winDriver = require("../events/driver/winDriver");
13
- var _utils3 = require("../utils/utils.global");
12
+ var _utils2 = require("../utils/utils.global");
14
13
  var usbmux = require('usbmux');
15
14
  var path = require('path');
16
15
  var request = require("request");
17
16
  var fs = require('fs');
17
+ var Sentry = require("@sentry/browser");
18
18
 
19
19
  // saas回调
20
20
  var saasCallBack;
@@ -23,9 +23,6 @@ var saasCallBack;
23
23
  var isDriverInstalling = false;
24
24
  var isDriverReady = false;
25
25
 
26
- // 初始化dll
27
- (0, _utils2.HunterInspectionKit)();
28
-
29
26
  /**
30
27
  * 获取资源文件的基础路径
31
28
  */
@@ -65,7 +62,7 @@ var DevicePair = /*#__PURE__*/function () {
65
62
  cmd: 'trust_status',
66
63
  udid: udid
67
64
  });
68
- devicePair = (0, _utils3.callHunterInspectionKit)('TheForceKit', JSON.stringify(paramsObj));
65
+ devicePair = (0, _utils2.callHunterInspectionKit)('TheForceKit', JSON.stringify(paramsObj));
69
66
  if (!devicePair) {
70
67
  _context.next = 15;
71
68
  break;
@@ -117,7 +114,7 @@ var writeDllVersion = function writeDllVersion(version) {
117
114
  }
118
115
  console.log('========写入version成功');
119
116
  // 写入成功后 重新初始化dll
120
- (0, _utils2.HunterInspectionKit)();
117
+ HunterInspectionKit();
121
118
  saasCallBack({
122
119
  data: {
123
120
  eventName: 'type_update_result',
@@ -168,7 +165,7 @@ var updateDllFileCheck = function updateDllFileCheck() {
168
165
  label: (0, _utils.isWin)() ? 'Windows' : 'Mac',
169
166
  params: {}
170
167
  };
171
- var updateRes = (0, _utils3.callHunterInspectionKit)('TheForceKit', JSON.stringify(updateParams));
168
+ var updateRes = (0, _utils2.callHunterInspectionKit)('TheForceKit', JSON.stringify(updateParams));
172
169
  if (updateRes) {
173
170
  var updateResObj = JSON.parse(updateRes);
174
171
  var Code = updateResObj.Code,
@@ -238,6 +235,7 @@ var checkAndInstallDriver = function checkAndInstallDriver() {
238
235
  }).catch(function (err) {
239
236
  // 失败
240
237
  console.error('驱动下载或安装失败', err);
238
+ Sentry.captureException('驱动下载或安装失败:' + JSON.stringify(err));
241
239
  isDriverInstalling = false;
242
240
  saasCallBack({
243
241
  data: {
@@ -248,6 +246,7 @@ var checkAndInstallDriver = function checkAndInstallDriver() {
248
246
  });
249
247
  }).catch(function (err) {
250
248
  console.error('驱动检测失败', err);
249
+ Sentry.captureException('驱动检测失败:' + JSON.stringify(err));
251
250
  });
252
251
  };
253
252
  var RegisterEvent = function RegisterEvent(params, callBack) {
@@ -269,6 +268,7 @@ var RegisterEvent = function RegisterEvent(params, callBack) {
269
268
  }
270
269
  return _context2.abrupt("return");
271
270
  case 2:
271
+ Sentry.captureException("\u51FA\u9519\u5566\u6D4B\u8BD5");
272
272
  // 插入设备通知
273
273
  saasCallBack({
274
274
  data: {
@@ -315,7 +315,7 @@ var RegisterEvent = function RegisterEvent(params, callBack) {
315
315
  // 有驱动,直接运行脚本
316
316
  DevicePair(udid, params);
317
317
  }
318
- case 4:
318
+ case 5:
319
319
  case "end":
320
320
  return _context2.stop();
321
321
  }
@@ -335,6 +335,7 @@ var RegisterEvent = function RegisterEvent(params, callBack) {
335
335
  });
336
336
  }).on('error', function (err) {
337
337
  console.log('usb连接错误:', err);
338
+ Sentry.captureException('usb连接错误:' + JSON.stringify(err));
338
339
  var errMsg = "usb\u8FDE\u63A5\u9519\u8BEF\uFF1A".concat(err);
339
340
  throw new Error(errMsg);
340
341
  });
@@ -3,12 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setGlobalProperty = exports.hasGlobalProperty = exports.getHunterInspectionKit = exports.getGlobalProperty = exports.getGlobalObject = exports.deleteGlobalProperty = exports.callHunterInspectionKit = void 0;
6
+ exports.setGlobalProperty = exports.hasGlobalProperty = exports.getHunterInspectionKit = exports.getGlobalProperty = exports.getGlobalObject = exports.getGeneralReportCallKit = exports.deleteGlobalProperty = exports.callHunterInspectionKit = void 0;
7
+ var _utils = require("../utils/utils.initDll");
7
8
  /**
8
9
  * 全局对象兼容性处理工具
9
10
  * 兼容Electron主进程(global)和渲染进程(window)环境
10
11
  */
11
-
12
+ var Sentry = require("@sentry/browser");
12
13
  /**
13
14
  * 获取全局对象
14
15
  * @returns {Object} 全局对象
@@ -86,17 +87,64 @@ var getHunterInspectionKit = exports.getHunterInspectionKit = function getHunter
86
87
  */
87
88
  var callHunterInspectionKit = exports.callHunterInspectionKit = function callHunterInspectionKit(methodName) {
88
89
  var kit = getHunterInspectionKit();
90
+ if (!kit) {
91
+ (0, _utils.HunterInspectionKit)();
92
+ kit = getHunterInspectionKit();
93
+ }
89
94
  if (!kit || typeof kit[methodName] !== 'function') {
90
95
  console.error("HunterInspectionKit.".concat(methodName, "\u65B9\u6CD5\u4E0D\u5B58\u5728\u6216\u672A\u521D\u59CB\u5316"));
96
+ Sentry.captureException("HunterInspectionKit.".concat(methodName, "\u65B9\u6CD5\u4E0D\u5B58\u5728\u6216\u672A\u521D\u59CB\u5316"));
91
97
  return null;
92
98
  }
93
99
  try {
100
+ var _kit;
94
101
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
95
102
  args[_key - 1] = arguments[_key];
96
103
  }
97
- return kit[methodName].apply(kit, args);
104
+ return (_kit = kit)[methodName].apply(_kit, args);
98
105
  } catch (error) {
99
106
  console.error("\u8C03\u7528HunterInspectionKit.".concat(methodName, "\u5931\u8D25:"), error);
107
+ Sentry.captureException("\u8C03\u7528HunterInspectionKit.".concat(methodName, "\u5931\u8D25:"), error);
100
108
  return null;
101
109
  }
110
+ };
111
+
112
+ /**
113
+ * 获取报告
114
+ * @param {Object} params 参数
115
+ * @returns {Object} 报告结果
116
+ */
117
+ var getGeneralReportCallKit = exports.getGeneralReportCallKit = function getGeneralReportCallKit(params) {
118
+ var reportRes = callHunterInspectionKit('InspectionKit', params, 'saas_report', params);
119
+ if (reportRes) {
120
+ var reportResObj = JSON.parse(reportRes);
121
+ var Code = reportResObj.Code,
122
+ Data = reportResObj.Data;
123
+ if (Code == 0 && Data) {
124
+ return {
125
+ type: 'getGeneralReportSuccess',
126
+ data: {
127
+ code: 0,
128
+ data: Data,
129
+ message: '获取报告成功'
130
+ }
131
+ };
132
+ }
133
+ return {
134
+ type: 'getGeneralReportFail',
135
+ data: {
136
+ code: -1,
137
+ data: {},
138
+ message: '获取报告结果为空'
139
+ }
140
+ };
141
+ }
142
+ return {
143
+ type: 'getGeneralReportFail',
144
+ data: {
145
+ code: -1,
146
+ data: {},
147
+ message: '获取报告失败'
148
+ }
149
+ };
102
150
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hunter-open-sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",
@@ -26,6 +26,7 @@
26
26
  "author": "xiexing <xiexing@zhuanzhuan.com>",
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
+ "@sentry/browser": "^10.10.0",
29
30
  "compressing": "2.0.0",
30
31
  "core-js": "3.6.5",
31
32
  "ffi-napi": "^4.0.3",
@@ -1,27 +0,0 @@
1
- var exec = require('child_process').exec;
2
- export function command(cmd) {
3
- var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : './';
4
- // 任何你期望执行的cmd命令,ls都可以
5
- var cmdStr1 = cmd;
6
- var cmdPath = path;
7
- // 子进程名称
8
- var workerProcess;
9
- runExec(cmdStr1);
10
- function runExec(cmdStr) {
11
- workerProcess = exec(cmdStr, {
12
- cwd: cmdPath
13
- });
14
- // 打印正常的后台可执行程序输出
15
- workerProcess.stdout.on('data', function (data) {
16
- console.log('stdout: ' + data);
17
- });
18
- // 打印错误的后台可执行程序输出
19
- workerProcess.stderr.on('data', function (data) {
20
- console.log('stderr: ' + data);
21
- });
22
- // 退出之后的输出
23
- workerProcess.on('close', function (code) {
24
- console.log('out code:' + code);
25
- });
26
- }
27
- }
@@ -1,40 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import { isMac, isWin, isDev, isProd } from "../../utils/utils";
4
- import { command } from "./command";
5
- import { checkHasDriver, downloadDriver } from "./winDriver";
6
- var path = require('path');
7
- var Service = /*#__PURE__*/function () {
8
- function Service() {
9
- _classCallCheck(this, Service);
10
- }
11
- _createClass(Service, [{
12
- key: "setup",
13
- value:
14
- // constructor () {}
15
- function setup(mainWindow) {
16
- console.log('Service setup');
17
- if (isMac()) {
18
- if (isDev()) {
19
- command(path.join(process.cwd(), './extraResources/ightools'));
20
- }
21
- if (isProd()) {
22
- command('nohup ' + path.join(process.resourcesPath, './extraResources/ightools') + ' > /dev/null 2>&1 & > ' + path.join(process.resourcesPath, './log/ightools.log'));
23
- }
24
- }
25
- if (isWin()) {
26
- checkHasDriver().then(function (res) {
27
- console.log('------------checkHasDriver', res);
28
- if (res) {
29
- mainWindow.webContents.send("checkDriver", true);
30
- } else {
31
- mainWindow.webContents.send("checkDriver", false);
32
- downloadDriver(mainWindow);
33
- }
34
- });
35
- }
36
- }
37
- }]);
38
- return Service;
39
- }();
40
- export default Service;
@@ -1,222 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { isDev } from "../../utils/utils";
4
- // import { app } from 'electron'
5
- import { command } from "../../utils/utils.command";
6
- var sudo = require('sudo-prompt');
7
- var path = require('path');
8
- var fs = require('fs');
9
- var childProcess = require('child_process');
10
- var compressing = require('compressing');
11
- var exec = childProcess.exec;
12
- var options = {
13
- name: 'Electron'
14
- };
15
- var msiStr = 'AppleMobileDeviceService';
16
- var reddirPath = 'C:/Program Files (x86)/Common Files/Apple/Apple Application Support';
17
- var cmdStr = process.platform === 'win32' ? 'tasklist' : 'ps aux';
18
- var CACHE_PATH = isDev() ? path.join(process.cwd(), './cache') : path.join(process.resourcesPath, './cache');
19
- var filePath = path.join(CACHE_PATH, './iTunesOL_Lite_64_12.10.0.7.zip');
20
- var mainWindowObj;
21
- var checkProcess = function checkProcess() {
22
- return new Promise(function (resolve, reject) {
23
- exec(cmdStr, function (err, stdout, stderr) {
24
- // console.log('stdout>>>', stdout)
25
- // console.log('stderr>>>', stderr)
26
- if (err) {
27
- return reject(err);
28
- }
29
- if (stdout) {
30
- var hasRroess = false;
31
- stdout.split('\n').filter(function (line) {
32
- var processMessage = line.trim().split(/\s+/);
33
- var processName = processMessage[0];
34
- // console.log('names.....', processName)
35
- if (processName.indexOf(msiStr) > -1) {
36
- hasRroess = true;
37
- }
38
- });
39
- resolve(hasRroess);
40
- }
41
- });
42
- });
43
- };
44
- var checkFs = function checkFs(paths) {
45
- return new Promise(function (resolve) {
46
- fs.readdir(paths, function (err) {
47
- resolve(err ? false : true);
48
- });
49
- });
50
- };
51
- var checkCache = function checkCache() {
52
- return new Promise(function (resolve) {
53
- fs.readFile(filePath, function (err) {
54
- resolve(err ? false : true);
55
- });
56
- });
57
- };
58
-
59
- // 轮询检测是否存在进程
60
- var checkProcessTimer = function checkProcessTimer() {
61
- var timer = null;
62
- clearTimeout(timer);
63
- timer = setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
64
- var hasDriver;
65
- return _regeneratorRuntime.wrap(function _callee$(_context) {
66
- while (1) switch (_context.prev = _context.next) {
67
- case 0:
68
- _context.next = 2;
69
- return checkProcess();
70
- case 2:
71
- hasDriver = _context.sent;
72
- if (!hasDriver) {
73
- _context.next = 6;
74
- break;
75
- }
76
- mainWindowObj.webContents.send("driverDone");
77
- return _context.abrupt("return");
78
- case 6:
79
- checkProcessTimer();
80
- case 7:
81
- case "end":
82
- return _context.stop();
83
- }
84
- }, _callee);
85
- })), 1000);
86
- };
87
- var installDriver = function installDriver() {
88
- var AppleApplicationSupport = path.join(CACHE_PATH, './AppleApplicationSupport.msi');
89
- var AppleApplicationSupport64 = path.join(CACHE_PATH, './AppleApplicationSupport64.msi');
90
- var AppleMobileDeviceSupport64 = path.join(CACHE_PATH, './AppleMobileDeviceSupport64.msi');
91
- var Bonjour64 = path.join(CACHE_PATH, './Bonjour64.msi');
92
- var cmdStr = "start /i /wait ".concat(AppleApplicationSupport, " /qn && start /i /wait ").concat(AppleApplicationSupport64, " /qn && start /i /wait ").concat(AppleMobileDeviceSupport64, " /qn && start /i /wait ").concat(Bonjour64, " /qn");
93
- sudo.exec(cmdStr, options, function (error, stdout, stderr) {
94
- console.log('安装 error>>', error);
95
- console.log('安装 stdout>>>', stdout);
96
- console.log('安装 stderr>>>', stderr);
97
- if (isDev()) {
98
- command(path.join(process.cwd(), './extraResources/ightools.exe'));
99
- } else {
100
- command(path.join(process.resourcesPath, './extraResources/ightools.exe'));
101
- }
102
- checkProcessTimer();
103
- });
104
- };
105
- // 解压文件
106
- var uncopressingFile = function uncopressingFile(filePath) {
107
- return new Promise(function (resolve) {
108
- compressing.zip.uncompress(filePath, CACHE_PATH).then(function (res) {
109
- resolve(true);
110
- }).catch(function (err) {
111
- resolve(false);
112
- console.log('error', err);
113
- });
114
- });
115
- };
116
- export function downloadDriver(mainWindow) {
117
- mainWindowObj = mainWindow;
118
- mainWindow.webContents.downloadURL('http://ljtools.zhuanstatic.com/download/iTunesDriver/iTunesOL_Lite_64_12.10.0.7.zip');
119
- mainWindow.webContents.session.on('will-download', function (e, item) {
120
- // 文件总大小
121
- var totalBytes = item.getTotalBytes();
122
- // 设置保存路径
123
- var rootPath = path.join(CACHE_PATH, item.getFilename());
124
- item.setSavePath(rootPath);
125
- item.on('updated', function () {
126
- try {
127
- // 获取进度,设置进度条
128
- var _process = item.getReceivedBytes() / totalBytes;
129
- _process = Math.round(_process * 100);
130
- mainWindow.webContents.send('downloadProcess', _process);
131
- } catch (e) {
132
- console.log('驱动下载失败');
133
- }
134
- });
135
- // 下载完成
136
- item.on('done', /*#__PURE__*/function () {
137
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(e, start) {
138
- var uncopressing;
139
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
140
- while (1) switch (_context2.prev = _context2.next) {
141
- case 0:
142
- _context2.next = 2;
143
- return uncopressingFile(filePath);
144
- case 2:
145
- uncopressing = _context2.sent;
146
- if (uncopressing) installDriver();
147
- mainWindow.webContents.send('downloadDriverDone');
148
- case 5:
149
- case "end":
150
- return _context2.stop();
151
- }
152
- }, _callee2);
153
- }));
154
- return function (_x, _x2) {
155
- return _ref2.apply(this, arguments);
156
- };
157
- }());
158
- item.on('error', function () {
159
- console.log('驱动下载失败');
160
- });
161
- });
162
- }
163
- export function checkHasDriver() {
164
- return _checkHasDriver.apply(this, arguments);
165
- }
166
- function _checkHasDriver() {
167
- _checkHasDriver = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
168
- var hasDriver, hasCache, state, uncopressing;
169
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
170
- while (1) switch (_context3.prev = _context3.next) {
171
- case 0:
172
- _context3.next = 2;
173
- return checkProcess();
174
- case 2:
175
- if (!_context3.sent) {
176
- _context3.next = 6;
177
- break;
178
- }
179
- _context3.t0 = 1;
180
- _context3.next = 7;
181
- break;
182
- case 6:
183
- _context3.t0 = 0;
184
- case 7:
185
- hasDriver = _context3.t0;
186
- _context3.next = 10;
187
- return checkCache();
188
- case 10:
189
- if (!_context3.sent) {
190
- _context3.next = 14;
191
- break;
192
- }
193
- _context3.t1 = 2;
194
- _context3.next = 15;
195
- break;
196
- case 14:
197
- _context3.t1 = 0;
198
- case 15:
199
- hasCache = _context3.t1;
200
- state = hasDriver + hasCache;
201
- _context3.t2 = state;
202
- _context3.next = _context3.t2 === 3 ? 20 : _context3.t2 === 1 ? 20 : _context3.t2 === 2 ? 21 : 26;
203
- break;
204
- case 20:
205
- return _context3.abrupt("return", true);
206
- case 21:
207
- _context3.next = 23;
208
- return uncopressingFile(filePath);
209
- case 23:
210
- uncopressing = _context3.sent;
211
- if (uncopressing) installDriver();
212
- return _context3.abrupt("return", true);
213
- case 26:
214
- return _context3.abrupt("return", false);
215
- case 27:
216
- case "end":
217
- return _context3.stop();
218
- }
219
- }, _callee3);
220
- }));
221
- return _checkHasDriver.apply(this, arguments);
222
- }
@@ -1,9 +0,0 @@
1
- import { HunterInspectionKit } from "../utils/utils.initDll";
2
- var GetGeneralReport = function GetGeneralReport(params, callBack) {
3
- var reportRes = HunterInspectionKit.InspectionKit(biz, cmd, params);
4
- console.log('========reportRes', reportRes);
5
- callBack({
6
- data: reportRes
7
- });
8
- };
9
- export default GetGeneralReport;
package/es/index.js DELETED
@@ -1,8 +0,0 @@
1
- import registerEvent from "./registerEvent";
2
- import getGeneralReport from "./getGeneralReport";
3
-
4
- // 初始化
5
- export default {
6
- registerEvent: registerEvent,
7
- getGeneralReport: getGeneralReport
8
- };
@@ -1,138 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import { isWin, isDev } from "../utils/utils";
6
- import { HunterInspectionKit } from "../utils/utils.initDll";
7
- import { checkHasDriver, downloadDriver } from "../events/driver/winDriver";
8
- var usbmux = require('usbmux');
9
- var path = require('path');
10
-
11
- // usb 监听
12
- var usbListener;
13
-
14
- // saas回调
15
- var saasCallBack;
16
-
17
- /**
18
- * 配对
19
- * @param {String} udid 设备id
20
- * @returns
21
- */
22
- var DevicePair = function DevicePair() {
23
- var udid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
24
- var params = arguments.length > 1 ? arguments[1] : undefined;
25
- // 通过调用read_pair来判断是否已配对【信任】
26
- var paramsObj = JSON.parse(params);
27
- Object.assign(paramsObj, {
28
- udid: udid
29
- });
30
- var devicePair = HunterInspectionKit.TheForceKit(JSON.stringify(paramsObj));
31
- console.log('======devicePair', devicePair);
32
- if (devicePair) {
33
- // 配对成功
34
- saasCallBack({
35
- data: {
36
- eventName: 'type_trust_result',
37
- udid: udid,
38
- eventCode: 0
39
- }
40
- });
41
- }
42
- };
43
-
44
- /**
45
- * 更新下载dll文件 并重写本地版本号
46
- * @param {String} udid 设备id
47
- * @returns
48
- */
49
- var updateDllFile = function updateDllFile(versionData) {
50
- var upgradeInfo = versionData.upgradeInfo;
51
- // 若不需要更新,则直接声明dll函数
52
- if (!upgradeInfo) return declareDllFn();
53
- // 若需要更新 则下载完成后 覆盖本地dll文件并重写version文件内容
54
- var packageUrl = upgradeInfo.packageUrl,
55
- verCodeName = upgradeInfo.verCodeName;
56
- var dllOutPath = path.resolve(__dirname, "../resources/dll/x64.dll");
57
- var dllStream = fs.createWriteStream(dllOutPath);
58
- request(packageUrl).pipe(dllStream).on("close", function (err) {
59
- console.log("========下载sdk完毕");
60
- fs.writeFile(versionPath, verCodeName, function (err) {
61
- if (err) return console.log(err);
62
- console.log('========写入version成功');
63
- Object.assign(window.SDK_APP_INFO, {
64
- version: verCodeName
65
- });
66
- });
67
- declareDllFn();
68
- });
69
- };
70
- var RegisterEvent = /*#__PURE__*/function () {
71
- function RegisterEvent() {
72
- _classCallCheck(this, RegisterEvent);
73
- }
74
- _createClass(RegisterEvent, [{
75
- key: "init",
76
- value: function () {
77
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params, callBack) {
78
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
79
- while (1) switch (_context2.prev = _context2.next) {
80
- case 0:
81
- saasCallBack = callBack;
82
- usbListener = new usbmux.createListener().on('attached', /*#__PURE__*/function () {
83
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(udid) {
84
- return _regeneratorRuntime.wrap(function _callee$(_context) {
85
- while (1) switch (_context.prev = _context.next) {
86
- case 0:
87
- if (udid) {
88
- _context.next = 2;
89
- break;
90
- }
91
- return _context.abrupt("return");
92
- case 2:
93
- if (isWin()) {
94
- // windows检查驱动 mac不需要
95
- // 检查是否有驱动
96
- checkHasDriver().then(function (res) {
97
- if (res) {
98
- // 有驱动,直接运行脚本
99
- DevicePair(udid, params);
100
- } else {
101
- downloadDriver();
102
- }
103
- });
104
- } else {
105
- // 有驱动,直接运行脚本
106
- DevicePair(udid, params);
107
- }
108
- case 3:
109
- case "end":
110
- return _context.stop();
111
- }
112
- }, _callee);
113
- }));
114
- return function (_x3) {
115
- return _ref.apply(this, arguments);
116
- };
117
- }()).on('detached', function (udid) {
118
- // clearInterval(pairTimer)
119
- }).on('error', function (err) {
120
- console.log('usb连接错误:', err);
121
- var errMsg = "usb\u8FDE\u63A5\u9519\u8BEF\uFF1A".concat(err);
122
- throw new Error(errMsg);
123
- });
124
- case 2:
125
- case "end":
126
- return _context2.stop();
127
- }
128
- }, _callee2);
129
- }));
130
- function init(_x, _x2) {
131
- return _init.apply(this, arguments);
132
- }
133
- return init;
134
- }()
135
- }]);
136
- return RegisterEvent;
137
- }();
138
- export default RegisterEvent;
@@ -1 +0,0 @@
1
- 0.0.3
Binary file
@@ -1,58 +0,0 @@
1
- /**
2
- * 封装回调函数,放入全局中 state 代表状态 0:成功获取报告 -1:获取报告失败 1:usb插入成功 2:正在查询报告 3:usb拔出
3
- * @ignore
4
- */
5
- export var ActualCallback = function ActualCallback(callbackName, callback, del) {
6
- window[callbackName] = function (state, res, msg) {
7
- console.log('科洛桑sdk返回的state', state, '返回的数据', res);
8
- switch (state) {
9
- case 0:
10
- try {
11
- callback({
12
- code: 0,
13
- data: res
14
- }, '报告获取成功');
15
- } catch (e) {
16
- console.log('[ActualCallback.error]:', e);
17
- }
18
- break;
19
- case 1:
20
- // callback({ loading: true }, '正在获取报告')
21
- callback({
22
- code: 1,
23
- data: res
24
- }, 'usb连接成功');
25
- break;
26
- case 2:
27
- callback({
28
- code: 2,
29
- data: res
30
- }, '报告查询中,请稍后');
31
- break;
32
- case 3:
33
- callback({
34
- code: 3,
35
- data: null
36
- }, 'usb已断开');
37
- break;
38
- case -1:
39
- callback({
40
- code: -1,
41
- data: null,
42
- msg: msg
43
- }, '获取报告失败');
44
- break;
45
- default:
46
- callback(null, '科洛桑没有匹配到state');
47
- break;
48
- }
49
- if (del) delete window[callbackName];
50
- };
51
- };
52
- /**
53
- * 执行回调函数
54
- * @ignore
55
- */
56
- export var ExecuteCallBack = function ExecuteCallBack(callbackName, state, data, msg) {
57
- window[callbackName](state, data, msg);
58
- };
@@ -1,27 +0,0 @@
1
- var exec = require('child_process').exec;
2
- export function command(cmd) {
3
- var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : './';
4
- // 任何你期望执行的cmd命令,ls都可以
5
- var cmdStr1 = cmd;
6
- var cmdPath = path;
7
- // 子进程名称
8
- var workerProcess;
9
- runExec(cmdStr1);
10
- function runExec(cmdStr) {
11
- workerProcess = exec(cmdStr, {
12
- cwd: cmdPath
13
- });
14
- // 打印正常的后台可执行程序输出
15
- workerProcess.stdout.on('data', function (data) {
16
- console.log('stdout: ' + data);
17
- });
18
- // 打印错误的后台可执行程序输出
19
- workerProcess.stderr.on('data', function (data) {
20
- console.log('stderr: ' + data);
21
- });
22
- // 退出之后的输出
23
- workerProcess.on('close', function (code) {
24
- console.log('out code:' + code);
25
- });
26
- }
27
- }
@@ -1,23 +0,0 @@
1
- import { isWin, isDev } from "./utils";
2
- var ffi = require('ffi-napi');
3
-
4
- /**
5
- * 声明dll函数
6
- * @param {String} udid 设备id
7
- * @returns
8
- */
9
-
10
- export var HunterInspectionKit = function HunterInspectionKit() {
11
- var dllPath = path.resolve(__dirname, '../resources/dll/x64.dll');
12
- if (!isDev()) {
13
- // 如果是生产模式 则替换app.asar 路径 为了在生产调用dll
14
- dllPath = dllPath.replace('app.asar', 'app.asar.unpacked');
15
- }
16
- var HunterInspectionKit = new ffi.Library(dllPath, {
17
- 'InspectionKit': ['string', ['string', 'string', 'string']],
18
- 'TheForceKit': ['string', ['string']]
19
- });
20
- // 挂载全局window
21
- window.HunterInspectionKit = HunterInspectionKit;
22
- return HunterInspectionKit;
23
- };
package/es/utils/utils.js DELETED
@@ -1,21 +0,0 @@
1
- export var isMac = function isMac() {
2
- return process.platform === 'darwin';
3
- };
4
- export var isWin = function isWin() {
5
- return process.platform === 'win32';
6
- };
7
- export var isLinux = function isLinux() {
8
- return process.platform === 'linux';
9
- };
10
- export var isDev = function isDev() {
11
- return process.env.WEBPACK_DEV_SERVER === 'true';
12
- };
13
- export var isProd = function isProd() {
14
- return process.env.NODE_ENV === 'production';
15
- };
16
- export var isArm64 = function isArm64() {
17
- return process.arch === 'arm64';
18
- };
19
- export var isAmd64 = function isAmd64() {
20
- return process.arch === 'x64';
21
- };
@@ -1,87 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- // import request from './utils.request'
5
- import zzfetch from '@zz/fetch';
6
- import { url } from '@zz-yp/hunter-js-utils';
7
-
8
- // lego上报的接口
9
- var legoUrl = 'https://lego.zhuanzhuan.com/page/mark';
10
-
11
- // 获取本地ip的接口
12
- var getIpUrl = 'https://api.ipify.org?format=json';
13
-
14
- // 获取ip省市区的接口
15
- var getIpInfoUrl = 'https://hunterapi.zhuanspirit.com/api/ip/owner';
16
-
17
- // 获取普通验机报告
18
- export var lego = function lego(_ref) {
19
- var pagetype = _ref.pagetype,
20
- actiontype = _ref.actiontype,
21
- _ref$backup = _ref.backup,
22
- backup = _ref$backup === void 0 ? {} : _ref$backup;
23
- var legoParams = {
24
- pagetype: pagetype,
25
- actiontype: actiontype,
26
- backup: JSON.stringify(_objectSpread({}, backup)),
27
- timestamp: new Date().getTime(),
28
- clienttime: new Date().getTime(),
29
- appid: 'ZHUANZHUAN',
30
- cookieid: backup.uid
31
- };
32
- var apiUrl = url.setParams(legoParams, legoUrl);
33
- zzfetch({
34
- url: apiUrl,
35
- method: "post"
36
- });
37
- };
38
- var fetchIpInfo = function fetchIpInfo(type) {
39
- return zzfetch({
40
- url: getIpUrl,
41
- method: 'get'
42
- }).then(function (response) {
43
- var ip = response.ip;
44
- if (ip) {
45
- zzfetch({
46
- url: "".concat(getIpInfoUrl, "?ip=").concat(ip),
47
- method: 'get'
48
- }).then(function (res) {
49
- var data = res.data,
50
- code = res.code;
51
- if (code == 0) {
52
- lego({
53
- pagetype: 'hunter_inspection_kit',
54
- actiontype: type,
55
- backup: _objectSpread(_objectSpread(_objectSpread({}, window.SDK_APP_INFO), data), {}, {
56
- system_type: 'windows',
57
- ip: ip
58
- })
59
- });
60
- } else {
61
- lego({
62
- pagetype: 'hunter_inspection_kit',
63
- actiontype: type,
64
- backup: _objectSpread(_objectSpread({}, window.SDK_APP_INFO), {}, {
65
- system_type: 'windows',
66
- ip: ip
67
- })
68
- });
69
- }
70
- });
71
- } else {
72
- lego({
73
- pagetype: 'hunter_inspection_kit',
74
- actiontype: type,
75
- backup: _objectSpread(_objectSpread({}, window.SDK_APP_INFO), {}, {
76
- system_type: 'windows',
77
- ip: '--'
78
- })
79
- });
80
- }
81
- });
82
- };
83
-
84
- // 上报lego 携带ip等信息
85
- export var ReportLegoData = function ReportLegoData(type) {
86
- fetchIpInfo(type);
87
- };
@@ -1,10 +0,0 @@
1
- var path = require('path');
2
-
3
- /**
4
- * 当前环境地址转换
5
- * @param {*} path
6
- * @returns
7
- */
8
- export var currentEnvPath = function currentEnvPath(filePath) {
9
- return path.resolve(__dirname, filePath);
10
- };
@@ -1,34 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import zzfetch from '@zz/fetch';
4
-
5
- // 获取authApp的下载路径
6
- export var getAuthAppUrlApi = /*#__PURE__*/function () {
7
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
8
- var params,
9
- res,
10
- respData,
11
- _args = arguments;
12
- return _regeneratorRuntime.wrap(function _callee$(_context) {
13
- while (1) switch (_context.prev = _context.next) {
14
- case 0:
15
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
16
- _context.next = 3;
17
- return zzfetch({
18
- url: "https://feconf.zhuanzhuan.com/feconf/hunter?keys=hunter_coruscant_sdk_config",
19
- method: "get"
20
- });
21
- case 3:
22
- res = _context.sent;
23
- respData = res.respData;
24
- return _context.abrupt("return", Promise.resolve(respData === null || respData === void 0 ? void 0 : respData.authAppZipUrl));
25
- case 6:
26
- case "end":
27
- return _context.stop();
28
- }
29
- }, _callee);
30
- }));
31
- return function getAuthAppUrlApi() {
32
- return _ref.apply(this, arguments);
33
- };
34
- }();
@@ -1,164 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import zzfetch from '@zz/fetch';
7
- var baseUrl = 'https://app.zhuanzhuan.com/';
8
-
9
- // 上报原力信息
10
- export var AppearAndGetBaseForIOS = /*#__PURE__*/function () {
11
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
12
- var params,
13
- res,
14
- _args = arguments;
15
- return _regeneratorRuntime.wrap(function _callee$(_context) {
16
- while (1) switch (_context.prev = _context.next) {
17
- case 0:
18
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
19
- res = zzfetch({
20
- url: "".concat(baseUrl, "zzopen/hunter_force_api/appearAndGetBaseForIOS"),
21
- method: "post",
22
- params: {
23
- param: JSON.stringify(_objectSpread(_objectSpread({}, params), window.SDK_APP_INFO))
24
- }
25
- });
26
- return _context.abrupt("return", res);
27
- case 3:
28
- case "end":
29
- return _context.stop();
30
- }
31
- }, _callee);
32
- }));
33
- return function AppearAndGetBaseForIOS() {
34
- return _ref.apply(this, arguments);
35
- };
36
- }();
37
-
38
- // 获取专业原始报告
39
- export var GetOriginalReport = /*#__PURE__*/function () {
40
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
41
- var params,
42
- opts,
43
- res,
44
- _args2 = arguments;
45
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
46
- while (1) switch (_context2.prev = _context2.next) {
47
- case 0:
48
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
49
- opts = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
50
- res = zzfetch({
51
- url: "".concat(baseUrl, "zzopen/hunter_force_api/getOriginalReport"),
52
- method: "post",
53
- params: {
54
- param: JSON.stringify(_objectSpread(_objectSpread({}, params), window.SDK_APP_INFO))
55
- }
56
- });
57
- return _context2.abrupt("return", res);
58
- case 4:
59
- case "end":
60
- return _context2.stop();
61
- }
62
- }, _callee2);
63
- }));
64
- return function GetOriginalReport() {
65
- return _ref2.apply(this, arguments);
66
- };
67
- }();
68
-
69
- // 获取安卓报告
70
- export var GetOriginalAndroidReport = /*#__PURE__*/function () {
71
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
72
- var params,
73
- opts,
74
- channel,
75
- url,
76
- res,
77
- _args3 = arguments;
78
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
79
- while (1) switch (_context3.prev = _context3.next) {
80
- case 0:
81
- params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
82
- opts = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
83
- channel = params.channel; // 请求接口区分抖音和其他渠道
84
- url = channel === 'hunter_dance' ? "".concat(baseUrl, "zzopen/hunter_force_api/getAndroidReportForDy") : "".concat(baseUrl, "zzopen/hunter_force_api/getAndroidReport");
85
- res = zzfetch({
86
- url: url,
87
- method: "post",
88
- params: {
89
- param: JSON.stringify(_objectSpread(_objectSpread({}, params), window.SDK_APP_INFO))
90
- }
91
- });
92
- return _context3.abrupt("return", res);
93
- case 6:
94
- case "end":
95
- return _context3.stop();
96
- }
97
- }, _callee3);
98
- }));
99
- return function GetOriginalAndroidReport() {
100
- return _ref3.apply(this, arguments);
101
- };
102
- }();
103
-
104
- // 获取快速报告
105
- export var AppearAndGetAllForIOS = /*#__PURE__*/function () {
106
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
107
- var params,
108
- res,
109
- _args4 = arguments;
110
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
111
- while (1) switch (_context4.prev = _context4.next) {
112
- case 0:
113
- params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
114
- res = zzfetch({
115
- url: "".concat(baseUrl, "zzopen/hunter_force_api/appearAndGetAllForIOS"),
116
- method: "post",
117
- params: {
118
- param: JSON.stringify(_objectSpread(_objectSpread({}, params), window.SDK_APP_INFO))
119
- }
120
- });
121
- return _context4.abrupt("return", res);
122
- case 3:
123
- case "end":
124
- return _context4.stop();
125
- }
126
- }, _callee4);
127
- }));
128
- return function AppearAndGetAllForIOS() {
129
- return _ref4.apply(this, arguments);
130
- };
131
- }();
132
-
133
- // 存储当前原力报告数据
134
- export var SaveForceInfo = function SaveForceInfo(data) {
135
- window.FORCE_REPORT_INFO = data.info;
136
- // window.DEVICE_ID = data.deviceId
137
- };
138
-
139
- // 上报智能质检各阶段时长
140
- export var AppearStatisticalInfo = function AppearStatisticalInfo(_ref5, phoneReportId) {
141
- var forceStartTime = _ref5.forceStartTime,
142
- forceEndTime = _ref5.forceEndTime,
143
- getReportStartTime = _ref5.getReportStartTime,
144
- getReportEndTime = _ref5.getReportEndTime;
145
- // 原力耗时
146
- var forceTime = forceEndTime - forceStartTime;
147
- // 获取报告耗时
148
- var getReportTime = getReportEndTime - getReportStartTime;
149
- // 总时长
150
- var allTestTime = forceTime + getReportTime;
151
- var res = zzfetch({
152
- url: "".concat(baseUrl, "zzopen/hunter_force_api/appearStatisticalInfo"),
153
- method: "post",
154
- params: {
155
- param: JSON.stringify(_objectSpread(_objectSpread({}, window.SDK_APP_INFO), {}, {
156
- reportId: phoneReportId,
157
- forceTime: forceTime,
158
- getReportTime: getReportTime,
159
- allTestTime: allTestTime
160
- }))
161
- }
162
- });
163
- return res;
164
- };
@@ -1,21 +0,0 @@
1
- import axios from 'axios';
2
- axios.defaults.withCredentials = true;
3
-
4
- // 请求拦截 设置统一header
5
- axios.interceptors.request.use(function (config) {
6
- return config;
7
- }, function (error) {
8
- console.log(error);
9
- return Promise.reject(error);
10
- });
11
-
12
- // 响应拦截
13
- axios.interceptors.response.use(function (response) {
14
- var data = response.data;
15
- return data;
16
- }, function (error) {
17
- // 错误提醒
18
- console.log(error);
19
- return Promise.reject(error);
20
- });
21
- export default axios;