wgt-node-utils 1.2.43 → 1.2.45
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 +23 -87
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -164,87 +164,6 @@ class wgtNodeUtils {
|
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
/***
|
|
168
|
-
* 获取 site相关配置
|
|
169
|
-
* @isMobile 是否为移动端
|
|
170
|
-
* @url 请求后端接口
|
|
171
|
-
* @hostname 网站 hostname
|
|
172
|
-
* @imgDomain 图片地址
|
|
173
|
-
* @creativeId widget creative Id
|
|
174
|
-
* @mobileZoneKeyList 手机端使用zoneKeyList
|
|
175
|
-
* @pcZoneKeyList PC端使用zoneKEyList
|
|
176
|
-
*/
|
|
177
|
-
// TODO 还未开发完成
|
|
178
|
-
async getSiteConfigByHostname(isMobile, url, hostname, imgDomain, creativeId, buildName, mobileZoneKeyList = [], pcZoneKeyList = []) {
|
|
179
|
-
const params = {
|
|
180
|
-
domain: hostname,
|
|
181
|
-
creative_id: creativeId
|
|
182
|
-
}
|
|
183
|
-
return new Promise((resolve) => {
|
|
184
|
-
axios.get(url, { params }).then(res => {
|
|
185
|
-
let siteData = res.data.data;
|
|
186
|
-
// 如果未获取到数据,使用做为默认数据
|
|
187
|
-
if (!siteData) {
|
|
188
|
-
siteData = {
|
|
189
|
-
siteId: "site_12",
|
|
190
|
-
zoneMap: {
|
|
191
|
-
'pad_bottom_300_250': "45330",
|
|
192
|
-
'pad_bottom_336_280': "45326",
|
|
193
|
-
'pc_bottom_728_90': "45320",
|
|
194
|
-
'pc_right_300_250': "45321",
|
|
195
|
-
'pc_right_300_600': "45322",
|
|
196
|
-
'pc_right_300_250_2': "45324",
|
|
197
|
-
'pc_left_160_600': "45323",
|
|
198
|
-
'mobile_300_250_top': "45327",
|
|
199
|
-
'mobile_300_250_mid': "45328",
|
|
200
|
-
'mobile_300_600_bottom': "45329",
|
|
201
|
-
'interstitial_pc': "45334",
|
|
202
|
-
'interstitial_mobile': "45335",
|
|
203
|
-
'pc_bottom_160_90': "45325",
|
|
204
|
-
'pc_pad_walkthrough_336_280': "45319",
|
|
205
|
-
'mobile_game': "45331",
|
|
206
|
-
'pc_game': "45333",
|
|
207
|
-
'pad_game': "45332",
|
|
208
|
-
'sidewall': "47185"
|
|
209
|
-
},
|
|
210
|
-
theme: {
|
|
211
|
-
icon: '',
|
|
212
|
-
logo: '',
|
|
213
|
-
title: '',
|
|
214
|
-
bgLeftImg: '',
|
|
215
|
-
bgRightImg: '',
|
|
216
|
-
bgBottomImg: '',
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// 通过设备清洗zoneKeyMap
|
|
222
|
-
const zoneKeyList = isMobile ? mobileZoneKeyList : pcZoneKeyList;
|
|
223
|
-
let zoneMapForDevice = {};
|
|
224
|
-
const zoneMap = siteData.zoneMap || {};
|
|
225
|
-
zoneKeyList.forEach(zoneKey => {
|
|
226
|
-
if (zoneMap[zoneKey]) {
|
|
227
|
-
zoneMapForDevice[zoneKey] = zoneMap[zoneKey];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
siteData.zoneMap = zoneMapForDevice;
|
|
231
|
-
|
|
232
|
-
// 处理皮肤字段
|
|
233
|
-
const { icon, logo, title, bgLeftImg, bgRightImg, bgBottomImg, ...otherTheme } = siteData.theme || {};
|
|
234
|
-
siteData.theme = {
|
|
235
|
-
icon: icon ? `${imgDomain}/site_icon/${icon}` : `/${buildName}/favicon.ico`,
|
|
236
|
-
logo: logo ? `${imgDomain}/site_logo/${logo}` : `/${buildName}/assets/logo-small.svg`,
|
|
237
|
-
title: title || 'Enjoy4fun',
|
|
238
|
-
bgLeftImg: bgLeftImg ? `${imgDomain}/theme/${bgLeftImg}` : '/gamebridge-web/assets/bg-left-winter.png',
|
|
239
|
-
bgRightImg: bgRightImg ? `${imgDomain}/theme/${bgRightImg}` : '/gamebridge-web/assets/bg-right-winter.png',
|
|
240
|
-
bgBottomImg: bgBottomImg ? `${imgDomain}/theme/${bgBottomImg}` : '/gamebridge-web/assets/bg-bottom-winter.png',
|
|
241
|
-
...otherTheme
|
|
242
|
-
}
|
|
243
|
-
resolve(siteData);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
167
|
/***
|
|
249
168
|
* node启动时将静态资源读取到内存中
|
|
250
169
|
* @buildName 打包名称
|
|
@@ -384,8 +303,8 @@ class wgtNodeUtils {
|
|
|
384
303
|
else if (err.config) {
|
|
385
304
|
console.error(`============${new Date().toLocaleString()}===========`);
|
|
386
305
|
console.error(`${message} [${err.config.method}]: ${err.config.url}`);
|
|
387
|
-
console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${ err.config.data ? JSON.stringify(err.config.data) : ''}}`);
|
|
388
|
-
console.error(`response: ${JSON.stringify( this.safeStringify(err.response.data))}`);
|
|
306
|
+
// console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${ err.config.data ? JSON.stringify(err.config.data) : ''}}`);
|
|
307
|
+
// console.error(`response: ${JSON.stringify( this.safeStringify(err.response.data))}`);
|
|
389
308
|
|
|
390
309
|
this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu);
|
|
391
310
|
|
|
@@ -428,18 +347,33 @@ class wgtNodeUtils {
|
|
|
428
347
|
* 用于渲染游戏卡列表,清理无用字段
|
|
429
348
|
* @param list 清理数组
|
|
430
349
|
*/
|
|
431
|
-
clearGameCardListData = (list) => {
|
|
432
|
-
//
|
|
350
|
+
clearGameCardListData = (list, options = {}) => {
|
|
351
|
+
// 支持传入 option 参数,按需求进行字段过滤
|
|
352
|
+
// options.fields: 指定需要输出的字段数组,如 ['id', 'name', 'icon']
|
|
353
|
+
const defaultFields = [
|
|
354
|
+
'id', 'game_category', 'icon', 'path', 'name', 'icon_video', 'new', 'developer'
|
|
355
|
+
];
|
|
356
|
+
const fields = Array.isArray(options.fields) && options.fields.length > 0 ? options.fields : defaultFields;
|
|
433
357
|
return list.map((item = {}) => {
|
|
434
|
-
|
|
358
|
+
// 统一字段映射
|
|
359
|
+
const mapping = {
|
|
435
360
|
id: item.game_id,
|
|
436
361
|
game_category: item.game_category,
|
|
437
362
|
icon: item.base_icon,
|
|
438
363
|
path: item.game_path,
|
|
439
364
|
name: item.game_name,
|
|
440
365
|
icon_video: item.icon_video,
|
|
366
|
+
developer: item.developer,
|
|
441
367
|
new: item.new ? true : undefined // 将false转换为undefined, 用于节省ssr生成的文本长度
|
|
442
|
-
}
|
|
368
|
+
};
|
|
369
|
+
// 只输出指定字段
|
|
370
|
+
const result = {};
|
|
371
|
+
fields.forEach(key => {
|
|
372
|
+
if (Object.prototype.hasOwnProperty.call(mapping, key)) {
|
|
373
|
+
result[key] = mapping[key];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
return result;
|
|
443
377
|
});
|
|
444
378
|
}
|
|
445
379
|
|
|
@@ -826,6 +760,8 @@ class wgtNodeUtils {
|
|
|
826
760
|
siteData = res.data && res.data.data && res.data.data;
|
|
827
761
|
} else if (type === 'novel') {
|
|
828
762
|
siteData = res.data && res.data.data && res.data.data.split(',').map(item => item.trim()).filter(item => item !== '');
|
|
763
|
+
} else if (type === 'game') {
|
|
764
|
+
siteData = res.data && res.data.data && res.data.data.split(',').map(item => item.trim()).filter(item => item !== '');
|
|
829
765
|
}
|
|
830
766
|
// 如果未获取到数据,使用en做为默认数据
|
|
831
767
|
if (!siteData) {
|