wgt-node-utils 1.2.52 → 1.2.54
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 +21 -2
- package/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +29 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -108,13 +108,12 @@ class wgtNodeUtils {
|
|
|
108
108
|
}
|
|
109
109
|
return system;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
// 获取cloud front传回的设备信息
|
|
111
|
+
// 获取search site传回的设备信息
|
|
113
112
|
getSearchSiteSystem = (device) => {
|
|
114
113
|
const system = {
|
|
115
|
-
isAndroid: device,
|
|
116
|
-
isPhone: device,
|
|
117
|
-
isTablet: device
|
|
114
|
+
isAndroid: device === 'true',
|
|
115
|
+
isPhone: device === 'true',
|
|
116
|
+
isTablet: device === 'true'
|
|
118
117
|
};
|
|
119
118
|
|
|
120
119
|
// 其它设备均为空的情况下,默认当前设置为pc
|
|
@@ -124,6 +123,22 @@ class wgtNodeUtils {
|
|
|
124
123
|
return system;
|
|
125
124
|
}
|
|
126
125
|
|
|
126
|
+
// 获取template配置
|
|
127
|
+
// 判断当前是否是search模版
|
|
128
|
+
// @req 请求体
|
|
129
|
+
getGetTemplateConfiguration = (req) => {
|
|
130
|
+
const isSearchSite = req.headers['x-from-search'] === 'true' || false;
|
|
131
|
+
const hostname = isSearchSite ? req.headers['x-forwarded-host'] : req.hostname;
|
|
132
|
+
const device = this.getCloudFrontDevice(req.headers);
|
|
133
|
+
const system = isSearchSite ? this.getSearchSiteSystem(req.headers['x-is-mobile']) : this.getCloudFrontSystem(device);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
isSearchSite,
|
|
137
|
+
hostname,
|
|
138
|
+
system
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
/***
|
|
128
143
|
* 通用头信息添加
|
|
129
144
|
* @res node端 返回头
|
|
@@ -184,9 +199,9 @@ class wgtNodeUtils {
|
|
|
184
199
|
* @buildName 打包名称
|
|
185
200
|
* @version 打包版本号
|
|
186
201
|
* @dirname 项目的绝对地址
|
|
187
|
-
* @
|
|
202
|
+
* @useGlobal 是否需要 global.css
|
|
188
203
|
*/
|
|
189
|
-
readF2eFiles = (buildName, version, dirname) => {
|
|
204
|
+
readF2eFiles = (buildName, version, dirname, useGlobal = false) => {
|
|
190
205
|
console.log('静态资源:开始读取');
|
|
191
206
|
return new Promise((resolve, reject) => {
|
|
192
207
|
try {
|
|
@@ -209,8 +224,13 @@ class wgtNodeUtils {
|
|
|
209
224
|
|
|
210
225
|
// 增加preact依赖
|
|
211
226
|
this.fileContents['preact.min.js'] = fs.readFileSync(path.join(dirname, `../${buildName}/dist/preact.min.js`), 'utf8');
|
|
212
|
-
|
|
213
|
-
|
|
227
|
+
|
|
228
|
+
// 增加wgt-web-ui的css文件
|
|
229
|
+
if (useGlobal) {
|
|
230
|
+
// 获取wgt-web-ui的css文件
|
|
231
|
+
this.fileContents['global.css'] = fs.readFileSync(path.join(dirname, `../${buildName}/assets/global.css`), 'utf8');
|
|
232
|
+
}
|
|
233
|
+
|
|
214
234
|
|
|
215
235
|
console.log('静态资源列表:');
|
|
216
236
|
|