wgt-node-utils 1.2.13 → 1.2.15
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 +15 -0
- package/package.json +1 -1
- package/src/index.js +34 -0
package/README.md
CHANGED
|
@@ -247,6 +247,21 @@
|
|
|
247
247
|
| pageName | string | 静态页面文件名称 | 是 | -- |
|
|
248
248
|
| isMobile | boolean | 是否为手机设备 | 是 | -- |
|
|
249
249
|
|
|
250
|
+
#### getSdkF2eFiles // 获取sdk静态资源
|
|
251
|
+
#### 使用
|
|
252
|
+
```javascript
|
|
253
|
+
await wgtNodeUtils.getModelF2eFiles(API_PATH, adsTagHref, ENV)
|
|
254
|
+
```
|
|
255
|
+
##### 参数说明:
|
|
256
|
+
|参数 | 类型 | 说明 | 是否必传 | 默认值 |
|
|
257
|
+
|---------|--------------|-----------------------------------------------------------------------------|------|-----|
|
|
258
|
+
| API_PATH | string | 项目API路径 | 是 | -- |
|
|
259
|
+
| adsTagHref | string | SDK静态资源桶路径 | 是 | -- |
|
|
260
|
+
| ENV | string | 项目环境变量 | 是 | -- |
|
|
261
|
+
| option | object | 项目环境变量 | 否 | -- |
|
|
262
|
+
| option.components | string | 项目模版容器名称 | 否 | 容器名称 |
|
|
263
|
+
| option.receive_id | string | 发送飞书ID | 否 | oc_aba13955509035daa7a799f30b1b3341 |
|
|
264
|
+
| option.useSendFeiShu | boolean | 项目环境变量 | 否 | false |
|
|
250
265
|
|
|
251
266
|
|
|
252
267
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -762,5 +762,39 @@ class wgtNodeUtils {
|
|
|
762
762
|
hasSpecialChar.test(path) // 检测特殊字符
|
|
763
763
|
);
|
|
764
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* 获取SDK静态资源
|
|
767
|
+
* @param {string} API_PATH - 项目API路径
|
|
768
|
+
* @param {string} adsTagHref - SDK静态资源桶路径
|
|
769
|
+
* @param {string} ENV - 环境变量
|
|
770
|
+
* @param {object} option - 参数
|
|
771
|
+
* @param {string} option.components - 容器名称
|
|
772
|
+
* @param {string} option.receive_id - 飞书群ID
|
|
773
|
+
* @param {boolean} option.useSendFeiShu - 是否需要发送飞书
|
|
774
|
+
* @returns {string} - SDK JS字符串
|
|
775
|
+
*/
|
|
776
|
+
getSdkF2eFiles = async(API_PATH, adsTagHref, ENV, option) => {
|
|
777
|
+
const {
|
|
778
|
+
components = '容器名称',
|
|
779
|
+
receive_id = 'oc_aba13955509035daa7a799f30b1b3341',
|
|
780
|
+
useSendFeiShu = false,
|
|
781
|
+
} = option;
|
|
782
|
+
|
|
783
|
+
// 生产环境使用API_PATH,其他环境使用adsTagHref
|
|
784
|
+
const sdkFilesPath = ENV === 'prod' ? `${API_PATH}/sdk?kaimen=08E28C7EEED6A1B3F9A80154D75A150B` : adsTagHref;
|
|
785
|
+
// 飞书内容
|
|
786
|
+
const feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\nmesssage: SDK获取失败"}`;
|
|
787
|
+
|
|
788
|
+
try {
|
|
789
|
+
const res = await axios.get(sdkFilesPath);
|
|
790
|
+
return res.data;
|
|
791
|
+
} catch (primaryError) {
|
|
792
|
+
this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu)
|
|
793
|
+
console.log(`从主路径获取 SDK 失败: ${sdkFilesPath}`, primaryError);
|
|
794
|
+
const fallbackRes = await axios.get(adsTagHref);
|
|
795
|
+
return fallbackRes.data;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
765
799
|
}
|
|
766
800
|
module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');
|