wgt-node-utils 1.1.6 → 1.2.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "1.1.6",
3
+ "version": "1.2.1",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -13,6 +13,8 @@ class wgtNodeUtils {
13
13
  this.client = null;
14
14
  // 存储游戏原始链接对象
15
15
  this.gameResourcesMap = {};
16
+ // 存储发送飞书告警对象
17
+ this.sendFeiShuMessageMap = {};
16
18
  // 是否發送错误信息开关
17
19
  this.filesErrorSendStatus = false;
18
20
  // 初始化Lark客户端
@@ -316,11 +318,11 @@ class wgtNodeUtils {
316
318
  * 飞书发送消息
317
319
  * @content 发送信息 json
318
320
  * @receive_id 飞书发送群ID
319
- * @useTest 开启测试
321
+ * @useSend 开启测试
320
322
  */
321
- sendFeiShu = (feiShuContent, ENV, receive_id = 'oc_aba13955509035daa7a799f30b1b3341', useTest = false) => {
323
+ sendFeiShu = (feiShuContent, receive_id, useSendFeiShu = false) => {
322
324
 
323
- if ((ENV.includes('qa') || ENV.includes('development') || ENV.includes('pro')) && !useTest) {
325
+ if (!useSendFeiShu) {
324
326
  return;
325
327
  }
326
328
  // 发送消息
@@ -370,7 +372,7 @@ class wgtNodeUtils {
370
372
  usePageUrl = false,
371
373
  req = null,
372
374
  receive_id = 'oc_aba13955509035daa7a799f30b1b3341',
373
- useFeiShuTest = false
375
+ useSendFeiShu = false
374
376
  } = options;
375
377
  try {
376
378
  let feiShuContent = ''
@@ -384,18 +386,17 @@ class wgtNodeUtils {
384
386
  console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${ err.config.data ? JSON.stringify(err.config.data) : ''}}`);
385
387
  console.error(`response: ${JSON.stringify( this.safeStringify(err.response))}`);
386
388
  feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\nmesssage: ${message}"}`
387
-
388
- if (usePageUrl && req) {
389
+ if (usePageUrl) {
389
390
  const pageUrl = new URL(req.originalUrl, `${req.protocol}://${req.get('host')}`).href;
390
391
  feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\npageUrl: ${decodeURIComponent(pageUrl)}\\nmesssage: ${message}"}`
391
392
  }
392
- this.sendFeiShu(feiShuContent, ENV, receive_id, useFeiShuTest);
393
+ this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu);
393
394
 
394
395
  } else {
395
396
  console.error(`============${new Date().toLocaleString()}===========`);
396
397
  console.error(message);
397
398
  feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\nmesssage: ${message}"}`
398
- this.sendFeiShu(feiShuContent, ENV, receive_id, useFeiShuTest);
399
+ this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu);
399
400
  }
400
401
  } catch (e) {
401
402
  console.log(e, '=============catch==============')
@@ -413,7 +414,7 @@ class wgtNodeUtils {
413
414
  }
414
415
  return value;
415
416
  });
416
- }
417
+ }
417
418
  /**
418
419
  * 验证是否为空对像
419
420
  * @param v 对象
@@ -608,11 +609,10 @@ class wgtNodeUtils {
608
609
  let domainArr = hostName.split('.');
609
610
  let domain = domainArr.slice(-2).join('.');
610
611
  let gameDomain = this.gameResourcesMap[domain];
611
-
612
612
  // 当前没有map 中没有存储新的 domain,创建新的map
613
613
  if (!gameDomain) {
614
614
  gameDomain = `https://game.${domain}`;
615
- const isAvailable = await checkDomainAvailability(gameDomain);
615
+ const isAvailable = await this.checkDomainAvailability(`https://game.${domain}`);
616
616
  if (isAvailable) {
617
617
  console.log('gameDomain可用,使用新的域名')
618
618
  this.gameResourcesMap[domain] = gameDomain;
@@ -636,6 +636,7 @@ class wgtNodeUtils {
636
636
  console.log(new Date(), 'gameResourcesMap:存在使用替换新的域名', this.gameResourcesMap, 'gameDomain', gameDomain, 'gameLink', gameLink);
637
637
  return gameLink;
638
638
  } catch (error) {
639
+ console.log(error, 'ReplaceGameResourcesError')
639
640
  gameLink = link;
640
641
  }
641
642
 
@@ -672,7 +673,7 @@ class wgtNodeUtils {
672
673
  if (file && file.length > 0) {
673
674
  return true;
674
675
  }
675
- this.appendLog(`${pageName}[${item}]`, '文件加载失败', 'test', components = '');
676
+ this.appendLog(`文件加载失败:${pageName}[${item}]`, 'test', 'test');
676
677
  return false;
677
678
  });
678
679
  this.filesErrorSendStatus = !fileStatus;