wgt-node-utils 1.2.49 → 1.2.51
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/README.md +13 -0
- package/dist/bundle.js +1 -1
- package/eslint.config.mjs +12 -12
- package/package.json +1 -1
- package/src/index.js +15 -81
package/eslint.config.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import globals from "globals";
|
|
2
|
-
import pluginJs from "@eslint/js";
|
|
3
|
-
import tseslint from "typescript-eslint";
|
|
4
|
-
import pluginReact from "eslint-plugin-react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
|
|
9
|
-
{languageOptions: { globals: globals.browser }},
|
|
10
|
-
pluginJs.configs.recommended,
|
|
11
|
-
...tseslint.configs.recommended,
|
|
12
|
-
pluginReact.configs.flat.recommended,
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import pluginReact from "eslint-plugin-react";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
|
|
9
|
+
{languageOptions: { globals: globals.browser }},
|
|
10
|
+
pluginJs.configs.recommended,
|
|
11
|
+
...tseslint.configs.recommended,
|
|
12
|
+
pluginReact.configs.flat.recommended,
|
|
13
13
|
];
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -109,6 +109,21 @@ class wgtNodeUtils {
|
|
|
109
109
|
return system;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
// 获取cloud front传回的设备信息
|
|
113
|
+
getSearchSiteSystem = (device) => {
|
|
114
|
+
const system = {
|
|
115
|
+
isAndroid: device,
|
|
116
|
+
isPhone: device,
|
|
117
|
+
isTablet: device
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// 其它设备均为空的情况下,默认当前设置为pc
|
|
121
|
+
if (!system.isAndroid && !system.isPhone && !system.isTablet) {
|
|
122
|
+
system.isPC = true;
|
|
123
|
+
}
|
|
124
|
+
return system;
|
|
125
|
+
}
|
|
126
|
+
|
|
112
127
|
/***
|
|
113
128
|
* 通用头信息添加
|
|
114
129
|
* @res node端 返回头
|
|
@@ -164,87 +179,6 @@ class wgtNodeUtils {
|
|
|
164
179
|
});
|
|
165
180
|
});
|
|
166
181
|
}
|
|
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
182
|
/***
|
|
249
183
|
* node启动时将静态资源读取到内存中
|
|
250
184
|
* @buildName 打包名称
|