wgt-node-utils 0.0.28 → 0.0.30
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +71 -14
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -21,7 +21,6 @@ class wgtNodeUtils {
|
|
|
21
21
|
} else {
|
|
22
22
|
console.error('Lark客户端初始化失败:未提供appId或appSecret');
|
|
23
23
|
}
|
|
24
|
-
this.testAxios()
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// 获取系统信息
|
|
@@ -45,16 +44,6 @@ class wgtNodeUtils {
|
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
testAxios = () => {
|
|
49
|
-
axios.get('https://jsonplaceholder.typicode.com/posts')
|
|
50
|
-
.then(response => {
|
|
51
|
-
console.log('Node.js response:', response.data);
|
|
52
|
-
})
|
|
53
|
-
.catch(error => {
|
|
54
|
-
console.error('Node.js error:', error);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
47
|
/***
|
|
59
48
|
* @headers 设备header 信息
|
|
60
49
|
*
|
|
@@ -180,9 +169,11 @@ class wgtNodeUtils {
|
|
|
180
169
|
* @hostname 网站 hostname
|
|
181
170
|
* @imgDomain 图片地址
|
|
182
171
|
* @creativeId widget creative Id
|
|
172
|
+
* @mobileZoneKeyList 手机端使用zoneKeyList
|
|
173
|
+
* @pcZoneKeyList PC端使用zoneKEyList
|
|
183
174
|
*/
|
|
184
175
|
// TODO 还未开发完成
|
|
185
|
-
async getSiteConfigByHostname(isMobile, url, hostname, imgDomain, creativeId, buildName) {
|
|
176
|
+
async getSiteConfigByHostname(isMobile, url, hostname, imgDomain, creativeId, buildName, mobileZoneKeyList = [], pcZoneKeyList = []) {
|
|
186
177
|
const params = {
|
|
187
178
|
domain: hostname,
|
|
188
179
|
creative_id: creativeId
|
|
@@ -345,6 +336,17 @@ class wgtNodeUtils {
|
|
|
345
336
|
console.error('消息发送失败:', err);
|
|
346
337
|
});
|
|
347
338
|
}
|
|
339
|
+
// 获取主域名
|
|
340
|
+
getMainDomainByHostname = (hostname) => {
|
|
341
|
+
// 使用正则表达式匹配主域名
|
|
342
|
+
const match = hostname.match(/(?:.*\.)?([^.]+\.[^.]+)$/);
|
|
343
|
+
// 如果没有匹配到主域名,返回默认的主域名
|
|
344
|
+
if (!match || match.length < 2) {
|
|
345
|
+
return 'enjoy4fun.com';
|
|
346
|
+
}
|
|
347
|
+
// 返回匹配到的主域名
|
|
348
|
+
return match[1];
|
|
349
|
+
}
|
|
348
350
|
/***
|
|
349
351
|
* node 端发送日志
|
|
350
352
|
* @text 发送文本
|
|
@@ -362,11 +364,11 @@ class wgtNodeUtils {
|
|
|
362
364
|
console.error(`${title} [${err.config.method}]: ${err.config.url}`);
|
|
363
365
|
console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${JSON.stringify(err.config.data)}}`);
|
|
364
366
|
console.error(`response: ${JSON.stringify(err.response)}`);
|
|
365
|
-
|
|
367
|
+
this.sendFeiShu(`${title} [${err.config.method}]: ${err.config.url}`, ENV, components);
|
|
366
368
|
} else {
|
|
367
369
|
console.error(`============${new Date().toLocaleString()}===========`);
|
|
368
370
|
console.error(`${title} ${err}`);
|
|
369
|
-
|
|
371
|
+
this.sendFeiShu(`${title} ${err}`, ENV, components);
|
|
370
372
|
}
|
|
371
373
|
} catch (e) {
|
|
372
374
|
|
|
@@ -402,6 +404,61 @@ class wgtNodeUtils {
|
|
|
402
404
|
}
|
|
403
405
|
});
|
|
404
406
|
}
|
|
407
|
+
|
|
408
|
+
// 用于渲染游戏详情的数据,清理无用字段
|
|
409
|
+
clearGameData = (game, imgDomain) => {
|
|
410
|
+
// 清除分类中的无用字段
|
|
411
|
+
/**
|
|
412
|
+
* todo 分类背景相关的逻辑需要放到后端接口中处理,待处理后清除这块逻辑
|
|
413
|
+
* 游戏背景图
|
|
414
|
+
* 如果游戏自身设置背景图用自身的
|
|
415
|
+
* 如果没有用类目第一个设置的
|
|
416
|
+
*/
|
|
417
|
+
let categoryBg = {
|
|
418
|
+
bg_left: '',
|
|
419
|
+
bg_right: '',
|
|
420
|
+
bg_bottom: ''
|
|
421
|
+
};
|
|
422
|
+
let categoryBgColor = '';
|
|
423
|
+
const categorys = game.categorys.map((item = {}) => {
|
|
424
|
+
// 抽取第一个存在背景配置的分类
|
|
425
|
+
if (!categoryBg.bg_left && !categoryBg.bg_right && !categoryBg.bg_bottom && item.bg_img) {
|
|
426
|
+
const bgImg = item.bg_img || {};
|
|
427
|
+
categoryBg = {
|
|
428
|
+
bg_left: bgImg.bg_left ? `${imgDomain}/${bgImg.bg_left}` : '',
|
|
429
|
+
bg_right: bgImg.bg_right ? `${imgDomain}/${bgImg.bg_right}` : '',
|
|
430
|
+
bg_bottom: bgImg.bg_bottom ? `${imgDomain}/${bgImg.bg_bottom}` : ''
|
|
431
|
+
}
|
|
432
|
+
categoryBgColor = bgImg.bg_left ? item.theme_color : '';
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
name: item.name,
|
|
436
|
+
path: item.path
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
return {
|
|
440
|
+
game_id: game.game_id,
|
|
441
|
+
game_link: game.game_link,
|
|
442
|
+
game_path: game.game_path,
|
|
443
|
+
game_name: game.game_name,
|
|
444
|
+
description: game.description,
|
|
445
|
+
game_play: game.game_play,
|
|
446
|
+
base_icon: game.base_icon,
|
|
447
|
+
developer: game.developer,
|
|
448
|
+
device_support: game.device_support,
|
|
449
|
+
browser_support: game.browser_support,
|
|
450
|
+
game_type: game.game_type,
|
|
451
|
+
players: game.players,
|
|
452
|
+
loading_video: game.loading_video || game.icon_video,
|
|
453
|
+
loading_video_thumbnail: game.loading_video_thumbnail,
|
|
454
|
+
categorys,
|
|
455
|
+
remind_delay: game.remind_delay || 180,
|
|
456
|
+
// 背景色 如果游戏有设置背景图,则用游戏设置的背景色, 如果没有设置背景图只设置了背景色用自身的背景色,没有背景色则取分类里的背景色
|
|
457
|
+
bg_color: (game.bg_img && game.bg_img.bg_left) ? game.bg_color : game.bg_color ? game.bg_color : categoryBgColor,
|
|
458
|
+
bg_img: (game.bg_img && game.bg_img.bg_left) ? game.bg_img : categoryBg,
|
|
459
|
+
disable_full_screen: !!game.disable_full_screen
|
|
460
|
+
}
|
|
461
|
+
}
|
|
405
462
|
/**
|
|
406
463
|
* 用于渲染类型卡片列表,清理无用字段
|
|
407
464
|
* @param list 清理数组
|