wgt-node-utils 1.2.8 → 1.2.9
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 +2 -4
- package/package.json +1 -1
- package/src/index.js +7 -16
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
#### readF2eFiles // node启动时将静态资源读取到内存中
|
|
77
77
|
#### 使用方法
|
|
78
78
|
```javascript
|
|
79
|
-
await wgtNodeUtils.readF2eFiles(buildName, version, dirname
|
|
79
|
+
await wgtNodeUtils.readF2eFiles(buildName, version, dirname)
|
|
80
80
|
```
|
|
81
81
|
##### 参数说明:
|
|
82
82
|
|参数 | 类型 | 说明 | 是否必传 | 默认值 |
|
|
@@ -84,8 +84,6 @@
|
|
|
84
84
|
| buildName | string | 项目打包名称 | 是 | -- |
|
|
85
85
|
| version | string | 项目版本号 | 是 | -- |
|
|
86
86
|
| dirname | string | 项目绝对地址 | 是 | -- |
|
|
87
|
-
| useReactRouterDom | boolean | 是否需要今天文件ReactRouterDom | 是 | false |
|
|
88
|
-
|
|
89
87
|
|
|
90
88
|
#### getMainDomainByHostname // 获取主域名
|
|
91
89
|
#### 使用
|
|
@@ -248,7 +246,7 @@
|
|
|
248
246
|
|---------|--------------|-----------------------------------------------------------------------------|------|-----|
|
|
249
247
|
| pageName | string | 静态页面文件名称 | 是 | -- |
|
|
250
248
|
| isMobile | boolean | 是否为手机设备 | 是 | -- |
|
|
251
|
-
|
|
249
|
+
|
|
252
250
|
|
|
253
251
|
|
|
254
252
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -252,7 +252,7 @@ class wgtNodeUtils {
|
|
|
252
252
|
* @dirname 项目的绝对地址
|
|
253
253
|
* @useReactRouterDom 是否需要reactRouterDom
|
|
254
254
|
*/
|
|
255
|
-
readF2eFiles = (buildName, version, dirname
|
|
255
|
+
readF2eFiles = (buildName, version, dirname) => {
|
|
256
256
|
console.log('静态资源:开始读取');
|
|
257
257
|
return new Promise((resolve, reject) => {
|
|
258
258
|
try {
|
|
@@ -273,14 +273,9 @@ class wgtNodeUtils {
|
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
// 增加react依赖
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (useReactRouterDom) {
|
|
280
|
-
this.fileContents['react-router-dom.min.js'] = fs.readFileSync(path.join(dirname, `../${buildName}/dist/react-router-dom.min.js`),'utf8');
|
|
281
|
-
}
|
|
276
|
+
fileContents['preact.min.js'] = fs.readFileSync(path.join(__dirname, `../${name}/dist/preact.min.js`),'utf8');
|
|
277
|
+
console.log('静态资源列表:');
|
|
282
278
|
|
|
283
|
-
console.log('静态资源列表:');
|
|
284
279
|
const f2eFileLoadStatus = Object.keys(this.fileContents).every((item) => {
|
|
285
280
|
const file = this.fileContents[item];
|
|
286
281
|
console.log(item, ':', file ? file.length : 'null');
|
|
@@ -646,7 +641,7 @@ class wgtNodeUtils {
|
|
|
646
641
|
* @pageName 页面名称
|
|
647
642
|
* @isMobile 是否为移动端
|
|
648
643
|
*/
|
|
649
|
-
getModelF2eFiles = (pageName, isMobile
|
|
644
|
+
getModelF2eFiles = (pageName, isMobile) => {
|
|
650
645
|
let jsName = `${pageName}.entry.js`;
|
|
651
646
|
let cssName = `${pageName}.entry.css`;
|
|
652
647
|
// 带设备信息的静态资源
|
|
@@ -658,13 +653,9 @@ class wgtNodeUtils {
|
|
|
658
653
|
let f2eFiles = {
|
|
659
654
|
jsStr: this.fileContents[jsName],
|
|
660
655
|
cssStr: this.fileContents[cssName],
|
|
661
|
-
|
|
662
|
-
reactDomStr: this.fileContents['react-dom.production.min.js']
|
|
656
|
+
preactStr: fileContents['preact.min.js']
|
|
663
657
|
};
|
|
664
|
-
|
|
665
|
-
if (useReactRouterDom) {
|
|
666
|
-
f2eFiles.reactRouterStr = this.fileContents['react-router-dom.min.js']
|
|
667
|
-
}
|
|
658
|
+
|
|
668
659
|
// 每次启动服务后仅对第一次失败进行验证
|
|
669
660
|
if (!this.filesErrorSendStatus) {
|
|
670
661
|
const fileStatus = Object.keys(f2eFiles).every(item => {
|
|
@@ -672,7 +663,7 @@ class wgtNodeUtils {
|
|
|
672
663
|
if (file && file.length > 0) {
|
|
673
664
|
return true;
|
|
674
665
|
}
|
|
675
|
-
this.appendLog(`文件加载失败:${pageName}[${item}]
|
|
666
|
+
this.appendLog(`文件加载失败:${pageName}[${item}]`);
|
|
676
667
|
return false;
|
|
677
668
|
});
|
|
678
669
|
this.filesErrorSendStatus = !fileStatus;
|