@smart100/spu-web-plugin 0.0.28 → 0.0.29

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.
@@ -708,7 +708,7 @@ function _toPropertyKey$1(arg) {
708
708
  return typeof key === "symbol" ? key : String(key);
709
709
  }
710
710
 
711
- var version = "0.0.28";
711
+ var version = "0.0.29";
712
712
 
713
713
  /** Detect free variable `global` from Node.js. */
714
714
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -11574,11 +11574,37 @@ var Jssdk = /*#__PURE__*/function () {
11574
11574
  var whichWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
11575
11575
  return new Promise( /*#__PURE__*/function () {
11576
11576
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
11577
- var script, x;
11577
+ var whichDocument, allscript, isload, script, x;
11578
11578
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11579
11579
  while (1) switch (_context.prev = _context.next) {
11580
11580
  case 0:
11581
- script = whichWindow.document.createElement('script');
11581
+ whichDocument = whichWindow.document; // 判断顶部是否已经加载过js
11582
+ allscript = whichDocument.head.getElementsByTagName('script');
11583
+ isload = Array.from(allscript).some(function (item) {
11584
+ // 不判断相等是因为 //open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js 插入前不带 http | https 插入后会自动基于当前地址补全 https
11585
+ if (item.src.includes(url)) {
11586
+ var issameproperty = true;
11587
+ if (property) {
11588
+ for (var x in property) {
11589
+ if (item.getAttribute(x) !== property[x]) {
11590
+ issameproperty = false;
11591
+ }
11592
+ }
11593
+ }
11594
+ return issameproperty;
11595
+ } else {
11596
+ return false;
11597
+ }
11598
+ });
11599
+ if (!isload) {
11600
+ _context.next = 7;
11601
+ break;
11602
+ }
11603
+ console.warn("".concat(url, " \u6587\u4EF6\u5DF2\u52A0\u8F7D\u8FC7\uFF0C\u65E0\u9700\u91CD\u590D\u52A0\u8F7D\u3002"));
11604
+ resolve('success');
11605
+ return _context.abrupt("return");
11606
+ case 7:
11607
+ script = whichDocument.createElement('script');
11582
11608
  script.setAttribute('type', 'text/javascript');
11583
11609
  script.setAttribute('src', url);
11584
11610
  if (property) {
@@ -11586,14 +11612,14 @@ var Jssdk = /*#__PURE__*/function () {
11586
11612
  script.setAttribute(x, property[x]);
11587
11613
  }
11588
11614
  }
11589
- whichWindow.document.getElementsByTagName('head')[0].appendChild(script);
11615
+ whichDocument.getElementsByTagName('head')[0].appendChild(script);
11590
11616
  script.onload = script.onreadystatechange = function () {
11591
11617
  var st = script.readyState;
11592
11618
  if (st && st !== 'loaded' && st !== 'complete') return;
11593
11619
  script.onload = script.onreadystatechange = null;
11594
11620
  resolve('success');
11595
11621
  };
11596
- case 6:
11622
+ case 13:
11597
11623
  case "end":
11598
11624
  return _context.stop();
11599
11625
  }
@@ -11652,20 +11678,21 @@ var Jssdk = /*#__PURE__*/function () {
11652
11678
  console.error('wx.config fail', err);
11653
11679
  reject(err);
11654
11680
  });
11655
- setTimeout(function () {
11656
- reject(new Error('wx.config fail timeout 3000'));
11657
- }, 3000);
11681
+ // setTimeout(() => {
11682
+ // reject(new Error('wx.config fail timeout 3000'))
11683
+ // }, 3000)
11658
11684
  _context2.next = 16;
11659
11685
  break;
11660
- case 13:
11661
- _context2.prev = 13;
11686
+ case 12:
11687
+ _context2.prev = 12;
11662
11688
  _context2.t0 = _context2["catch"](0);
11689
+ console.error('wx.config fail', _context2.t0);
11663
11690
  reject(_context2.t0);
11664
11691
  case 16:
11665
11692
  case "end":
11666
11693
  return _context2.stop();
11667
11694
  }
11668
- }, _callee2, null, [[0, 13]]);
11695
+ }, _callee2, null, [[0, 12]]);
11669
11696
  }));
11670
11697
  return function (_x3, _x4) {
11671
11698
  return _ref2.apply(this, arguments);
@@ -11715,13 +11742,14 @@ var Jssdk = /*#__PURE__*/function () {
11715
11742
  reject(error);
11716
11743
  }
11717
11744
  });
11718
- _context3.next = 13;
11745
+ _context3.next = 14;
11719
11746
  break;
11720
11747
  case 10:
11721
11748
  _context3.prev = 10;
11722
11749
  _context3.t0 = _context3["catch"](0);
11750
+ console.error('wx.agentConfig fail', _context3.t0);
11723
11751
  reject(_context3.t0);
11724
- case 13:
11752
+ case 14:
11725
11753
  case "end":
11726
11754
  return _context3.stop();
11727
11755
  }
@@ -11796,11 +11824,11 @@ var Jssdk = /*#__PURE__*/function () {
11796
11824
  _this4.isHack = true;
11797
11825
  }
11798
11826
  if (_this4.isLoadJs) {
11799
- _context5.next = 24;
11827
+ _context5.next = 26;
11800
11828
  break;
11801
11829
  }
11802
11830
  if (!(window.top && window.top !== window)) {
11803
- _context5.next = 14;
11831
+ _context5.next = 16;
11804
11832
  break;
11805
11833
  }
11806
11834
  if (!isWxworkApp()) {
@@ -11823,64 +11851,68 @@ var Jssdk = /*#__PURE__*/function () {
11823
11851
  _context5.next = 12;
11824
11852
  return _this4.loadJsUrl('//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js', {
11825
11853
  referrerpolicy: 'origin'
11826
- });
11854
+ }, window.top);
11827
11855
  case 12:
11828
- _context5.next = 23;
11829
- break;
11856
+ _context5.next = 14;
11857
+ return _this4.loadJsUrl('//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js', {
11858
+ referrerpolicy: 'origin'
11859
+ });
11830
11860
  case 14:
11861
+ _context5.next = 25;
11862
+ break;
11863
+ case 16:
11831
11864
  if (!isWxworkApp()) {
11832
- _context5.next = 19;
11865
+ _context5.next = 21;
11833
11866
  break;
11834
11867
  }
11835
- _context5.next = 17;
11868
+ _context5.next = 19;
11836
11869
  return _this4.loadJsUrl('//res.wx.qq.com/wwopen/js/jsapi/jweixin-1.0.0.js', {
11837
11870
  referrerpolicy: 'origin'
11838
11871
  });
11839
- case 17:
11840
- _context5.next = 21;
11841
- break;
11842
11872
  case 19:
11843
- _context5.next = 21;
11873
+ _context5.next = 23;
11874
+ break;
11875
+ case 21:
11876
+ _context5.next = 23;
11844
11877
  return _this4.loadJsUrl('//res.wx.qq.com/open/js/jweixin-1.2.0.js', {
11845
11878
  referrerpolicy: 'origin'
11846
11879
  });
11847
- case 21:
11848
- _context5.next = 23;
11880
+ case 23:
11881
+ _context5.next = 25;
11849
11882
  return _this4.loadJsUrl('//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js', {
11850
11883
  referrerpolicy: 'origin'
11851
11884
  });
11852
- case 23:
11885
+ case 25:
11853
11886
  _this4.isLoadJs = true;
11854
- case 24:
11855
- _context5.prev = 24;
11887
+ case 26:
11888
+ _context5.prev = 26;
11856
11889
  if (!/MicroMessenger/i.test(navigator.userAgent)) {
11857
- _context5.next = 28;
11890
+ _context5.next = 30;
11858
11891
  break;
11859
11892
  }
11860
- _context5.next = 28;
11861
- return _this4.config(jsApiList, url);
11862
- case 28:
11863
11893
  _context5.next = 30;
11864
- return _this4.agentConfig(jsApiList, url);
11894
+ return _this4.config(jsApiList, url);
11865
11895
  case 30:
11866
11896
  _context5.next = 32;
11867
- return _this4.checkSession();
11897
+ return _this4.agentConfig(jsApiList, url);
11868
11898
  case 32:
11899
+ _context5.next = 34;
11900
+ return _this4.checkSession();
11901
+ case 34:
11869
11902
  res = _context5.sent;
11870
11903
  resolve(res);
11871
- _context5.next = 40;
11904
+ _context5.next = 42;
11872
11905
  break;
11873
- case 36:
11874
- _context5.prev = 36;
11875
- _context5.t0 = _context5["catch"](24);
11876
- // this.isFail = true
11906
+ case 38:
11907
+ _context5.prev = 38;
11908
+ _context5.t0 = _context5["catch"](26);
11877
11909
  _this4.reset();
11878
11910
  reject(_context5.t0);
11879
- case 40:
11911
+ case 42:
11880
11912
  case "end":
11881
11913
  return _context5.stop();
11882
11914
  }
11883
- }, _callee5, null, [[24, 36]]);
11915
+ }, _callee5, null, [[26, 38]]);
11884
11916
  }));
11885
11917
  return function (_x9, _x10) {
11886
11918
  return _ref5.apply(this, arguments);
@@ -11919,7 +11951,8 @@ var Jssdk = /*#__PURE__*/function () {
11919
11951
  throw new Error('The current tenant is not a wxworksuite tenant.');
11920
11952
  case 3:
11921
11953
  jsApiList = _toConsumableArray(new Set([].concat(_toConsumableArray(this.lastAgentConfigJsApiList), _toConsumableArray(jsApiList))));
11922
- url = location.origin + location.pathname + location.search;
11954
+ // const url = location.origin + location.pathname + location.search
11955
+ url = this.getTopUrl();
11923
11956
  isin = jsApiList.every(function (item) {
11924
11957
  return _this5.lastAgentConfigJsApiList.some(function (item2) {
11925
11958
  return item2 === item;
@@ -11939,31 +11972,35 @@ var Jssdk = /*#__PURE__*/function () {
11939
11972
  case 14:
11940
11973
  _context7.prev = 14;
11941
11974
  _context7.t0 = _context7["catch"](7);
11942
- // this.isFail = true
11943
11975
  this.reset();
11944
11976
  throw _context7.t0;
11945
11977
  case 18:
11946
- _context7.next = 28;
11978
+ _context7.next = 34;
11947
11979
  break;
11948
11980
  case 20:
11981
+ _context7.prev = 20;
11949
11982
  if (!this.initPro) {
11950
- _context7.next = 22;
11983
+ _context7.next = 23;
11951
11984
  break;
11952
11985
  }
11953
11986
  return _context7.abrupt("return", this.initPro);
11954
- case 22:
11987
+ case 23:
11955
11988
  this.initPro = this.initFun(jsApiList, url);
11956
- _context7.next = 25;
11989
+ _context7.next = 26;
11957
11990
  return this.initPro;
11958
- case 25:
11991
+ case 26:
11959
11992
  _res = _context7.sent;
11960
11993
  this.initPro = null;
11961
11994
  return _context7.abrupt("return", _res);
11962
- case 28:
11995
+ case 31:
11996
+ _context7.prev = 31;
11997
+ _context7.t1 = _context7["catch"](20);
11998
+ throw _context7.t1;
11999
+ case 34:
11963
12000
  case "end":
11964
12001
  return _context7.stop();
11965
12002
  }
11966
- }, _callee7, this, [[7, 14]]);
12003
+ }, _callee7, this, [[7, 14], [20, 31]]);
11967
12004
  }));
11968
12005
  function init() {
11969
12006
  return _init.apply(this, arguments);
@@ -11981,6 +12018,12 @@ var Jssdk = /*#__PURE__*/function () {
11981
12018
  value: function getTopWindow() {
11982
12019
  return window.top || window;
11983
12020
  }
12021
+ }, {
12022
+ key: "getTopUrl",
12023
+ value: function getTopUrl() {
12024
+ var win = this.getTopWindow();
12025
+ return win.location.origin + win.location.pathname + win.location.search;
12026
+ }
11984
12027
  }, {
11985
12028
  key: "reset",
11986
12029
  value: function reset() {
@@ -12073,7 +12116,6 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12073
12116
  }
12074
12117
  }
12075
12118
  })["catch"](function (err) {
12076
- // console.error(err)
12077
12119
  // console.error('jssdk.init() fail', err)
12078
12120
  _this2._isCanUseWxworkSuite = false;
12079
12121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@amap/amap-jsapi-loader": "^1.0.1",
41
- "@smart100/wxworksuite-plugin": "^0.0.7",
41
+ "@smart100/wxworksuite-plugin": "^0.0.8",
42
42
  "axios": "^1.6.0",
43
43
  "co": "^4.6.0",
44
44
  "dayjs": "^1.11.10",