@flatbiz/pro-layout 5.0.15 → 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 +15 -4
- package/dist/index.js +52 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface PageWrapperProps extends Omit<PageProps, "children"> {
|
|
|
82
82
|
}
|
|
83
83
|
export type PageWrapperRefApi = {
|
|
84
84
|
onRefresh: () => void;
|
|
85
|
+
onReload: () => void;
|
|
85
86
|
};
|
|
86
87
|
/**
|
|
87
88
|
* 为Page内置接口处理流程组件,如果无全局初始化接口请求场景,请使用Page组件
|
|
@@ -96,6 +97,7 @@ export type PageWrapperRefApi = {
|
|
|
96
97
|
*/
|
|
97
98
|
export declare const PageWrapper: import("react").ForwardRefExoticComponent<PageWrapperProps & import("react").RefAttributes<PageWrapperRefApi>>;
|
|
98
99
|
export declare const usePageWrapper: () => {
|
|
100
|
+
onReload: () => void;
|
|
99
101
|
onRefresh: () => void;
|
|
100
102
|
};
|
|
101
103
|
export interface FallbackProps {
|
|
@@ -653,11 +655,16 @@ export declare const useRegisterRefreshCurrentIframeTab: (refreshKey: string, on
|
|
|
653
655
|
* @returns
|
|
654
656
|
*/
|
|
655
657
|
export declare const useRefreshRegisterIframeTab: () => (refreshKey: string, params?: TPlainObject) => void;
|
|
656
|
-
/**
|
|
657
|
-
|
|
658
|
+
/**
|
|
659
|
+
* iframe tab 激活回调
|
|
660
|
+
* ```
|
|
661
|
+
* 1. 首次激活执行 callback,isFirst 为 true
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
export declare const useIframeTabActive: (callback: (isFirst: boolean) => void) => void;
|
|
658
665
|
export type IframeHandler<T = unknown> = (data: T) => void;
|
|
659
666
|
/**
|
|
660
|
-
* iframe通信Demo:https://
|
|
667
|
+
* iframe通信Demo:https://fex.qa.tcshuke.com/docs/admin/main/exchange
|
|
661
668
|
*/
|
|
662
669
|
export type IframeApiProps = {
|
|
663
670
|
/** 广播消息到所有的iframes子页面 */
|
|
@@ -669,7 +676,9 @@ export type IframeApiProps = {
|
|
|
669
676
|
link: string;
|
|
670
677
|
name: string;
|
|
671
678
|
metaTitle?: string;
|
|
672
|
-
}
|
|
679
|
+
},
|
|
680
|
+
/** 是否关闭当前iframe tab */
|
|
681
|
+
isClosed?: boolean) => IframeApiProps;
|
|
673
682
|
/**
|
|
674
683
|
* 通过新iframe tab打开第三方页面
|
|
675
684
|
*
|
|
@@ -727,6 +736,8 @@ export type IframeApiProps = {
|
|
|
727
736
|
* ```
|
|
728
737
|
*/
|
|
729
738
|
iframeTabOperation: (type: "removeOther" | "removeAll" | "removeMe" | "refreshMe") => void;
|
|
739
|
+
/** 判断是否在iframe中 */
|
|
740
|
+
isInIframe: () => boolean;
|
|
730
741
|
};
|
|
731
742
|
/**
|
|
732
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 ($
|
|
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
|
-
/**
|
|
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
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
-
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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);
|
|
@@ -1407,7 +1385,8 @@ var PageWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1407
1385
|
});
|
|
1408
1386
|
useImperativeHandle(ref, function () {
|
|
1409
1387
|
return {
|
|
1410
|
-
onRefresh: onRefresh
|
|
1388
|
+
onRefresh: onRefresh,
|
|
1389
|
+
onReload: onReload
|
|
1411
1390
|
};
|
|
1412
1391
|
});
|
|
1413
1392
|
if (result.status === 'error') {
|
|
@@ -1441,6 +1420,7 @@ var PageWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1441
1420
|
}
|
|
1442
1421
|
return /*#__PURE__*/jsxs(PageWrapperCtxProvider, {
|
|
1443
1422
|
value: {
|
|
1423
|
+
onReload: onReload,
|
|
1444
1424
|
onRefresh: onRefresh
|
|
1445
1425
|
},
|
|
1446
1426
|
children: [againRefresh ? /*#__PURE__*/jsx(Loader, {
|
|
@@ -2155,7 +2135,7 @@ var initSyncIframeTabCacheByLocation = function initSyncIframeTabCacheByLocation
|
|
|
2155
2135
|
id: getUuid(),
|
|
2156
2136
|
iframeKey: "".concat(Date.now()),
|
|
2157
2137
|
link: siblingProjectTarget ? siblingProjectTarget.moduleUrl : locationLink,
|
|
2158
|
-
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),
|
|
2159
2139
|
menuId: undefined,
|
|
2160
2140
|
metaTitle: undefined,
|
|
2161
2141
|
pathSearch: locationLinkPathSearch
|
|
@@ -2227,8 +2207,8 @@ var getIframeTabClientConfig = function getIframeTabClientConfig(pathOrUrl) {
|
|
|
2227
2207
|
});
|
|
2228
2208
|
return target && isPlainObject(config[target]) ? config[target] : {};
|
|
2229
2209
|
};
|
|
2230
|
-
var getIframeTabName = function getIframeTabName(pathOrUrl,
|
|
2231
|
-
return getIframeTabClientConfig(pathOrUrl).name ||
|
|
2210
|
+
var getIframeTabName = function getIframeTabName(pathOrUrl, initName) {
|
|
2211
|
+
return initName || getIframeTabClientConfig(pathOrUrl).name || '未知页面';
|
|
2232
2212
|
};
|
|
2233
2213
|
|
|
2234
2214
|
var Shrink = function Shrink(props) {
|
|
@@ -2800,6 +2780,7 @@ var SiderBar = function SiderBar() {
|
|
|
2800
2780
|
});
|
|
2801
2781
|
};
|
|
2802
2782
|
|
|
2783
|
+
var _excluded$1 = ["_isClosed"];
|
|
2803
2784
|
var EventHandling = function EventHandling() {
|
|
2804
2785
|
var navigate = useNavigate();
|
|
2805
2786
|
var layoutCtx = useLayoutCtx();
|
|
@@ -2808,11 +2789,23 @@ var EventHandling = function EventHandling() {
|
|
|
2808
2789
|
hostUrl = _hooks$useGlobal.hostUrl;
|
|
2809
2790
|
useIframe(function (result) {
|
|
2810
2791
|
if (result.type === 'redirect_to_frame_layout_menu_item') {
|
|
2811
|
-
var
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
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
|
+
}
|
|
2816
2809
|
} else if (result.type === 'redirect_to_frame_layout_menu_third_item') {
|
|
2817
2810
|
var menuId = result.data.menuId;
|
|
2818
2811
|
var target = layoutCtx.siderBarTileMenus.find(function (item) {
|
|
@@ -3809,7 +3802,7 @@ var AppProvider = function AppProvider(props) {
|
|
|
3809
3802
|
} else {
|
|
3810
3803
|
var _addIframeTabListByMe = addIframeTabListByMenuItem(cahceTabList, {
|
|
3811
3804
|
link: iframeTablink,
|
|
3812
|
-
name: getIframeTabName(iframeTablink,
|
|
3805
|
+
name: getIframeTabName(iframeTablink, data === null || data === void 0 ? void 0 : data.name),
|
|
3813
3806
|
metaTitle: options === null || options === void 0 ? void 0 : options.metaTitle}),
|
|
3814
3807
|
_iframeTabListNew2 = _addIframeTabListByMe.iframeTabListNew,
|
|
3815
3808
|
_iframeTabActiveItem3 = _addIframeTabListByMe.iframeTabActiveItem;
|