wgt-node-utils 0.0.19 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -15,7 +15,6 @@ class wgtNodeUtils {
15
15
  this.gameResourcesMap = {};
16
16
  // 是否發送错误信息开关
17
17
  this.filesErrorSendStatus = false;
18
-
19
18
  // 初始化Lark客户端
20
19
  if (appId && appSecret) {
21
20
  this.initClient(appId, appSecret);
@@ -259,7 +258,6 @@ class wgtNodeUtils {
259
258
  console.log(directoryPath, 'directoryPath')
260
259
  // 读取目录下的所有文件
261
260
  const files = fs.readdirSync(directoryPath);
262
- console.log(files, 'files')
263
261
  files.forEach(file => {
264
262
  // 构建文件的完整路径
265
263
  const filePath = path.join(directoryPath, file);
@@ -313,21 +311,12 @@ class wgtNodeUtils {
313
311
  }
314
312
  }
315
313
  /***
316
- * node启动时将静态资源读取到内存中
317
- * @appId 打包名称
318
- * @appSecret 打包版本号
319
- * @message 发送信息值
320
- * @receive_id client 所使用的receive_id
314
+ * 飞书发送消息
315
+ * @message 打包名称
316
+ * @ENV 当前启用环境
321
317
  * @components 项目名称
322
318
  */
323
- sendFeiShu = (message, appId, appSecret, components = '') => {
324
- if (!this.client) {
325
- if (!appId || !appSecret) {
326
- console.error('Lark客户端未初始化,且未提供appId和appSecret,无法发送消息');
327
- return;
328
- }
329
- this.initClient(appId, appSecret);
330
- }
319
+ sendFeiShu = (message, ENV, components = '') => {
331
320
  // 发送消息
332
321
  this.client.im.message.create({
333
322
  params: {
@@ -336,7 +325,7 @@ class wgtNodeUtils {
336
325
  data: {
337
326
  receive_id: 'oc_aba13955509035daa7a799f30b1b3341',
338
327
  msg_type: 'text',
339
- content: `{"text":"<b>前端容器node报错</b>\\ncomponents: ${components}\\nenv: ${process.env.ENV}\\nmesssage: ${message}"}`,
328
+ content: `{"text":"<b>前端容器node报错</b>\\ncomponents: ${components}\\nenv: ${ENV}\\message: ${message}"}`,
340
329
  uuid: ''
341
330
  }
342
331
  }).then(res => {
@@ -349,8 +338,9 @@ class wgtNodeUtils {
349
338
  * node 端发送日志
350
339
  * @text 发送文本
351
340
  * @err 发送信息类型
341
+ * @components 项目名称
352
342
  */
353
- appendLog = (title, err) => {
343
+ appendLog = (title, err, ENV, components = '') => {
354
344
  try {
355
345
  if (!err) {
356
346
  console.warn(`============${new Date().toLocaleString()}===========`);
@@ -361,11 +351,11 @@ class wgtNodeUtils {
361
351
  console.error(`${title} [${err.config.method}]: ${err.config.url}`);
362
352
  console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${JSON.stringify(err.config.data)}}`);
363
353
  console.error(`response: ${JSON.stringify(err.response)}`);
364
- this.sendFeiShu(`${title} [${err.config.method}]: ${err.config.url}`);
354
+ this.sendFeiShu(`${title} [${err.config.method}]: ${err.config.url}`, ENV, components);
365
355
  } else {
366
356
  console.error(`============${new Date().toLocaleString()}===========`);
367
357
  console.error(`${title} ${err}`);
368
- this.sendFeiShu(`${title} ${err}`);
358
+ this.sendFeiShu(`${title} ${err}`, ENV, components);
369
359
  }
370
360
  } catch (e) {
371
361
 
@@ -455,7 +445,7 @@ class wgtNodeUtils {
455
445
  });
456
446
  resolve(list || defaultLanList);
457
447
  }).catch(() => {
458
- this.appendLog('语言读取', '语言接口调用失败');
448
+ this.appendLog('语言读取', '语言接口调用失败', 'test', components = '');
459
449
  // 调用失败时,返回en
460
450
  resolve(defaultLanList);
461
451
  });
@@ -568,7 +558,7 @@ class wgtNodeUtils {
568
558
  if (file && file.length > 0) {
569
559
  return true;
570
560
  }
571
- this.appendLog(`${pageName}[${item}]`, '文件加载失败');
561
+ this.appendLog(`${pageName}[${item}]`, '文件加载失败', 'test', components = '');
572
562
  return false;
573
563
  });
574
564
  this.filesErrorSendStatus = !fileStatus;