@flatbiz/pro-layout 5.0.16 → 5.0.17

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/dist/index.d.ts CHANGED
@@ -655,11 +655,16 @@ export declare const useRegisterRefreshCurrentIframeTab: (refreshKey: string, on
655
655
  * @returns
656
656
  */
657
657
  export declare const useRefreshRegisterIframeTab: () => (refreshKey: string, params?: TPlainObject) => void;
658
- /** iframe tab 激活回调 */
659
- export declare const useIframeTabActive: (callback: () => void) => void;
658
+ /**
659
+ * iframe tab 激活回调
660
+ * ```
661
+ * 1. 首次激活执行 callback,isFirst 为 true
662
+ * ```
663
+ */
664
+ export declare const useIframeTabActive: (callback: (isFirst: boolean) => void) => void;
660
665
  export type IframeHandler<T = unknown> = (data: T) => void;
661
666
  /**
662
- * iframe通信Demo:https://xx.xx.com/docs/admin/main/exchange
667
+ * iframe通信Demo:https://fex.qa.tcshuke.com/docs/admin/main/exchange
663
668
  */
664
669
  export type IframeApiProps = {
665
670
  /** 广播消息到所有的iframes子页面 */
@@ -671,7 +676,9 @@ export type IframeApiProps = {
671
676
  link: string;
672
677
  name: string;
673
678
  metaTitle?: string;
674
- }) => IframeApiProps;
679
+ },
680
+ /** 是否关闭当前iframe tab */
681
+ isClosed?: boolean) => IframeApiProps;
675
682
  /**
676
683
  * 通过新iframe tab打开第三方页面
677
684
  *
@@ -729,6 +736,8 @@ export type IframeApiProps = {
729
736
  * ```
730
737
  */
731
738
  iframeTabOperation: (type: "removeOther" | "removeAll" | "removeMe" | "refreshMe") => void;
739
+ /** 判断是否在iframe中 */
740
+ isInIframe: () => boolean;
732
741
  };
733
742
  /**
734
743
  * 使用Iframe通讯的API
package/dist/index.js CHANGED
@@ -340,12 +340,14 @@ var iframeApi = {
340
340
  }), '*');
341
341
  return iframeApi;
342
342
  },
343
- openNewTabItem: function openNewTabItem(data) {
343
+ openNewTabItem: function openNewTabItem(data, isClosed) {
344
344
  window.parent.postMessage(JSON.stringify({
345
345
  type: IFRAME_EVENT_FLAG,
346
346
  data: {
347
347
  type: 'redirect_to_frame_layout_menu_item',
348
- data: data
348
+ data: _objectSpread2(_objectSpread2({}, data), {}, {
349
+ _isClosed: isClosed
350
+ })
349
351
  }
350
352
  }), '*');
351
353
  return iframeApi;
@@ -446,6 +448,9 @@ var iframeApi = {
446
448
  }
447
449
  }), '*');
448
450
  return iframeApi;
451
+ },
452
+ isInIframe: function isInIframe() {
453
+ return window.self !== window.top;
449
454
  }
450
455
  };
451
456
 
@@ -632,7 +637,7 @@ var useRegisterRefreshCurrentIframeTab = function useRegisterRefreshCurrentIfram
632
637
  }
633
638
  };
634
639
  try {
635
- return Promise.resolve(onRefresh(data.data.params)).then(function ($await_9) {
640
+ return Promise.resolve(onRefresh(data.data.params)).then(function ($await_7) {
636
641
  try {
637
642
  return $Try_2_Finally($Try_2_Post)();
638
643
  } catch ($boundEx) {
@@ -680,54 +685,27 @@ var useRefreshRegisterIframeTab = function useRefreshRegisterIframeTab() {
680
685
  };
681
686
  };
682
687
 
683
- /** iframe tab 激活回调 */
688
+ /**
689
+ * iframe tab 激活回调
690
+ * ```
691
+ * 1. 首次激活执行 callback,isFirst 为 true
692
+ * ```
693
+ */
684
694
  var useIframeTabActive = function useIframeTabActive(callback) {
685
695
  useEffect(function () {
686
- callback();
696
+ callback(true);
687
697
  }, []);
688
698
  useIframe(function (data) {
689
- return new Promise(function ($return, $error) {
690
- var iframeNodeKey;
691
- if (data.type === '__iframe-tab-active') {
692
- var $Try_4_Post = function () {
693
- try {
694
- return $If_7.call(this);
695
- } catch ($boundEx) {
696
- return $error($boundEx);
697
- }
698
- }.bind(this);
699
- var $Try_4_Catch = function (error) {
700
- try {
701
- console.error(error);
702
- return $Try_4_Post();
703
- } catch ($boundEx) {
704
- return $error($boundEx);
705
- }
706
- };
707
- try {
708
- iframeNodeKey = window['__iframe_node_key'];
709
- if (data.data.activeKey === iframeNodeKey) {
710
- return Promise.resolve(callback()).then(function ($await_10) {
711
- try {
712
- return $If_8.call(this);
713
- } catch ($boundEx) {
714
- return $Try_4_Catch($boundEx);
715
- }
716
- }.bind(this), $Try_4_Catch);
717
- }
718
- function $If_8() {
719
- return $Try_4_Post();
720
- }
721
- return $If_8.call(this);
722
- } catch (error) {
723
- $Try_4_Catch(error);
699
+ if (data.type === '__iframe-tab-active') {
700
+ try {
701
+ var iframeNodeKey = window['__iframe_node_key'];
702
+ if (data.data.activeKey === iframeNodeKey) {
703
+ callback(false);
724
704
  }
705
+ } catch (error) {
706
+ console.error(error);
725
707
  }
726
- function $If_7() {
727
- return $return();
728
- }
729
- return $If_7.call(this);
730
- });
708
+ }
731
709
  });
732
710
  };
733
711
 
@@ -1141,7 +1119,7 @@ var getHostUrlAndRouteBaseName = function getHostUrlAndRouteBaseName(pathOrUrl)
1141
1119
  };
1142
1120
  };
1143
1121
 
1144
- var _excluded$2 = ["level"];
1122
+ var _excluded$3 = ["level"];
1145
1123
  /**
1146
1124
  * 通过面包屑路径返回
1147
1125
  * @param props
@@ -1160,7 +1138,7 @@ var _excluded$2 = ["level"];
1160
1138
  var HistoryBackButton = function HistoryBackButton(props) {
1161
1139
  var ctx = bootstrapCtx();
1162
1140
  var level = props.level,
1163
- otherProps = _objectWithoutProperties(props, _excluded$2);
1141
+ otherProps = _objectWithoutProperties(props, _excluded$3);
1164
1142
  var _getHostUrlAndRouteBa = getHostUrlAndRouteBaseName(location.href),
1165
1143
  routeBaseName = _getHostUrlAndRouteBa.routeBaseName;
1166
1144
  var routerList = useBread(ctx.breads, routeBaseName);
@@ -1308,12 +1286,12 @@ var _createCtx = createCtx$1(),
1308
1286
  usePageWrapperCtx = _createCtx2[0],
1309
1287
  PageWrapperCtxProvider = _createCtx2[1];
1310
1288
 
1311
- var _excluded$1 = ["respData"],
1289
+ var _excluded$2 = ["respData"],
1312
1290
  _excluded2 = ["serviceConfig", "isAsync", "errorRender"];
1313
1291
  var PageContent$1 = function PageContent(props) {
1314
1292
  var _props$children;
1315
1293
  var respData = props.respData,
1316
- otherProps = _objectWithoutProperties(props, _excluded$1);
1294
+ otherProps = _objectWithoutProperties(props, _excluded$2);
1317
1295
  var children = typeof props.children === 'function' ? (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.call(props, respData) : props.children;
1318
1296
  if (isFragment(children)) {
1319
1297
  var childrenList = Children.toArray(children.props.children);
@@ -2157,7 +2135,7 @@ var initSyncIframeTabCacheByLocation = function initSyncIframeTabCacheByLocation
2157
2135
  id: getUuid(),
2158
2136
  iframeKey: "".concat(Date.now()),
2159
2137
  link: siblingProjectTarget ? siblingProjectTarget.moduleUrl : locationLink,
2160
- name: (siblingProjectTarget === null || siblingProjectTarget === void 0 ? void 0 : siblingProjectTarget.name) || getIframeTabName(location.pathname, '未知页面'),
2138
+ name: (siblingProjectTarget === null || siblingProjectTarget === void 0 ? void 0 : siblingProjectTarget.name) || getIframeTabName(location.pathname),
2161
2139
  menuId: undefined,
2162
2140
  metaTitle: undefined,
2163
2141
  pathSearch: locationLinkPathSearch
@@ -2229,8 +2207,8 @@ var getIframeTabClientConfig = function getIframeTabClientConfig(pathOrUrl) {
2229
2207
  });
2230
2208
  return target && isPlainObject(config[target]) ? config[target] : {};
2231
2209
  };
2232
- var getIframeTabName = function getIframeTabName(pathOrUrl, defaultName) {
2233
- return getIframeTabClientConfig(pathOrUrl).name || defaultName;
2210
+ var getIframeTabName = function getIframeTabName(pathOrUrl, initName) {
2211
+ return initName || getIframeTabClientConfig(pathOrUrl).name || '未知页面';
2234
2212
  };
2235
2213
 
2236
2214
  var Shrink = function Shrink(props) {
@@ -2802,6 +2780,7 @@ var SiderBar = function SiderBar() {
2802
2780
  });
2803
2781
  };
2804
2782
 
2783
+ var _excluded$1 = ["_isClosed"];
2805
2784
  var EventHandling = function EventHandling() {
2806
2785
  var navigate = useNavigate();
2807
2786
  var layoutCtx = useLayoutCtx();
@@ -2810,11 +2789,23 @@ var EventHandling = function EventHandling() {
2810
2789
  hostUrl = _hooks$useGlobal.hostUrl;
2811
2790
  useIframe(function (result) {
2812
2791
  if (result.type === 'redirect_to_frame_layout_menu_item') {
2813
- var iframeTabItem = result.data;
2814
- layoutCtx.onIframeChangeByHttpUrl(guessIframeMainLink(iframeTabItem.link), {
2815
- name: iframeTabItem.name,
2816
- metaTitle: iframeTabItem.metaTitle
2817
- });
2792
+ var _ref = result.data,
2793
+ _isClosed = _ref._isClosed,
2794
+ iframeTabItem = _objectWithoutProperties(_ref, _excluded$1);
2795
+ if (_isClosed) {
2796
+ layoutCtx.onDeleteIframeTabItem('me', layoutCtx.iframeTabActiveItem.id);
2797
+ setTimeout(function () {
2798
+ layoutCtx.onIframeChangeByHttpUrl(guessIframeMainLink(iframeTabItem.link), {
2799
+ name: iframeTabItem.name,
2800
+ metaTitle: iframeTabItem.metaTitle
2801
+ });
2802
+ }, 80);
2803
+ } else {
2804
+ layoutCtx.onIframeChangeByHttpUrl(guessIframeMainLink(iframeTabItem.link), {
2805
+ name: iframeTabItem.name,
2806
+ metaTitle: iframeTabItem.metaTitle
2807
+ });
2808
+ }
2818
2809
  } else if (result.type === 'redirect_to_frame_layout_menu_third_item') {
2819
2810
  var menuId = result.data.menuId;
2820
2811
  var target = layoutCtx.siderBarTileMenus.find(function (item) {
@@ -3811,7 +3802,7 @@ var AppProvider = function AppProvider(props) {
3811
3802
  } else {
3812
3803
  var _addIframeTabListByMe = addIframeTabListByMenuItem(cahceTabList, {
3813
3804
  link: iframeTablink,
3814
- name: getIframeTabName(iframeTablink, (data === null || data === void 0 ? void 0 : data.name) || '未知页面'),
3805
+ name: getIframeTabName(iframeTablink, data === null || data === void 0 ? void 0 : data.name),
3815
3806
  metaTitle: options === null || options === void 0 ? void 0 : options.metaTitle}),
3816
3807
  _iframeTabListNew2 = _addIframeTabListByMe.iframeTabListNew,
3817
3808
  _iframeTabActiveItem3 = _addIframeTabListByMe.iframeTabActiveItem;