wgt-node-utils 1.2.12 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "1.2.12",
3
+ "version": "1.2.15",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -433,6 +433,7 @@ class wgtNodeUtils {
433
433
  return list.map((item = {}) => {
434
434
  return {
435
435
  id: item.game_id,
436
+ game_category: item.game_category,
436
437
  icon: item.base_icon,
437
438
  path: item.game_path,
438
439
  name: item.game_name,
@@ -761,5 +762,39 @@ class wgtNodeUtils {
761
762
  hasSpecialChar.test(path) // 检测特殊字符
762
763
  );
763
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
+
764
799
  }
765
800
  module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');