@flatbiz/pro-layout 5.0.9 → 5.0.11

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
@@ -565,6 +565,8 @@ export type BootstrapOptions = {
565
565
  * ```
566
566
  */
567
567
  hideBreadsPathList?: string[];
568
+ /** iframeTab 激活事件 */
569
+ onIframeTabActiveEvent?: (item: TPlainObject) => void;
568
570
  };
569
571
  export type LayoutCtxProps = {
570
572
  menus: TMenuItem[];
@@ -707,6 +709,16 @@ export type IframeApiProps = {
707
709
  closedIframeTabToPrevlink: () => IframeApiProps;
708
710
  /** 当前tabItem小红点实现切换 */
709
711
  tabItemRedDotToggle: (visible: boolean) => void;
712
+ /**
713
+ * iframeTab操作
714
+ * ```
715
+ * 1. removeOther - 移除其他iframe-tab
716
+ * 2. removeAll - 移除所有iframe-tab
717
+ * 3. removeMe - 移除当前iframe-tab
718
+ * 4. refreshMe - 刷新当前iframe-tab
719
+ * ```
720
+ */
721
+ iframeTabOperation: (type: "removeOther" | "removeAll" | "removeMe" | "refreshMe") => void;
710
722
  };
711
723
  /**
712
724
  * 使用Iframe通讯的API
package/dist/index.js CHANGED
@@ -431,6 +431,18 @@ var iframeApi = {
431
431
  }
432
432
  }), '*');
433
433
  return iframeApi;
434
+ },
435
+ iframeTabOperation: function iframeTabOperation(type) {
436
+ window.parent.postMessage(JSON.stringify({
437
+ type: IFRAME_EVENT_FLAG,
438
+ data: {
439
+ type: 'iframe-tab-operation',
440
+ data: {
441
+ type: type
442
+ }
443
+ }
444
+ }), '*');
445
+ return iframeApi;
434
446
  }
435
447
  };
436
448
 
@@ -2821,6 +2833,18 @@ var EventHandling = function EventHandling() {
2821
2833
  var _result$data5;
2822
2834
  var visible = (_result$data5 = result.data) === null || _result$data5 === void 0 ? void 0 : _result$data5['visible'];
2823
2835
  layoutCtx.onChangeActiveTabItemRedDot(visible);
2836
+ } else if (result.type === 'iframe-tab-operation') {
2837
+ var _result$data6;
2838
+ var type = (_result$data6 = result.data) === null || _result$data6 === void 0 ? void 0 : _result$data6['type'];
2839
+ if (type === 'removeMe') {
2840
+ layoutCtx.onDeleteIframeTabItem('me', "".concat(layoutCtx.iframeTabActiveItem.id));
2841
+ } else if (type === 'removeOther') {
2842
+ layoutCtx.onDeleteIframeTabItem('otherAll');
2843
+ } else if (type === 'removeAll') {
2844
+ layoutCtx.onDeleteIframeTabItem('all');
2845
+ } else if (type === 'refreshMe') {
2846
+ layoutCtx.onIframeChange(layoutCtx.iframeTabActiveItem.id, 'iframeRefresh');
2847
+ }
2824
2848
  }
2825
2849
  });
2826
2850
  useIframe(function (result) {
@@ -3185,7 +3209,7 @@ var NormalRoutesTiming = function NormalRoutesTiming() {
3185
3209
  return /*#__PURE__*/jsx(Fragment, {});
3186
3210
  };
3187
3211
 
3188
- var _excluded = ["sidebarWidth", "componentSize", "locale", "logoPath", "headerThemeConfig", "sidebarThemeConfig", "completeMenus"];
3212
+ var _excluded = ["sidebarWidth", "componentSize", "locale", "logoPath", "headerThemeConfig", "sidebarThemeConfig", "completeMenus", "onIframeTabActiveEvent"];
3189
3213
  var AppProvider = function AppProvider(props) {
3190
3214
  var navigate = useNavigate();
3191
3215
  var sidebarWidth = props.sidebarWidth,
@@ -3195,13 +3219,10 @@ var AppProvider = function AppProvider(props) {
3195
3219
  headerThemeConfig = props.headerThemeConfig,
3196
3220
  sidebarThemeConfig = props.sidebarThemeConfig,
3197
3221
  completeMenus = props.completeMenus,
3222
+ onIframeTabActiveEvent = props.onIframeTabActiveEvent,
3198
3223
  options = _objectWithoutProperties(props, _excluded);
3199
3224
  var isIframeMain = options.layoutMode === 'iframe-main';
3200
3225
  var unMatchHiddenSiderBar = isUndefined(options.unMatchHiddenSiderBar) ? true : options.unMatchHiddenSiderBar;
3201
- var hideSidebarMenu = function () {
3202
- if (options.disableTopbarMenu) return false;
3203
- return typeof options.hideSidebarMenu === 'function' ? options.hideSidebarMenu() : options.hideSidebarMenu;
3204
- }();
3205
3226
  var isMobile = useMediaQuery({
3206
3227
  query: '(max-width: 767px)'
3207
3228
  });
@@ -3209,16 +3230,6 @@ var AppProvider = function AppProvider(props) {
3209
3230
  _useState2 = _slicedToArray(_useState, 2),
3210
3231
  collapsed = _useState2[0],
3211
3232
  setCollapsed = _useState2[1];
3212
- hooks.useUpdateEffect(function () {
3213
- setCollapsed(isMobile);
3214
- }, [isMobile]);
3215
- hooks.useEffectOnce(function () {
3216
- if (props.initSidebarShrinkClosed) {
3217
- setCollapsed(true);
3218
- } else {
3219
- setCollapsed(isMobile);
3220
- }
3221
- }, []);
3222
3233
  var _useState3 = useState([]),
3223
3234
  _useState4 = _slicedToArray(_useState3, 2),
3224
3235
  opendKeys = _useState4[0],
@@ -3245,6 +3256,21 @@ var AppProvider = function AppProvider(props) {
3245
3256
  setSiderBarMenus = _useState14[1];
3246
3257
  // const initSiderBarMenuActiveItemRef = useRef<TMenuItem>();
3247
3258
 
3259
+ hooks.useUpdateEffect(function () {
3260
+ setCollapsed(isMobile);
3261
+ }, [isMobile]);
3262
+ hooks.useEffectOnce(function () {
3263
+ if (props.initSidebarShrinkClosed) {
3264
+ setCollapsed(true);
3265
+ } else {
3266
+ setCollapsed(isMobile);
3267
+ }
3268
+ }, []);
3269
+ var hideSidebarMenu = fbaHooks.useMemoCustom(function () {
3270
+ if (options.disableTopbarMenu) return false;
3271
+ if (siderBarMenus.length === 0) return true;
3272
+ return typeof options.hideSidebarMenu === 'function' ? options.hideSidebarMenu(location.pathname) : options.hideSidebarMenu;
3273
+ }, [options.disableTopbarMenu, options.hideSidebarMenu, siderBarMenus, location.pathname]);
3248
3274
  var opendKeysTempRef = useRef();
3249
3275
  var ErrorHandlingRender = options.ErrorHandling || ErrorHandling;
3250
3276
  var siderBarTileMenus = useMemo(function () {
@@ -3352,8 +3378,9 @@ var AppProvider = function AppProvider(props) {
3352
3378
  saveCacheIframeActiveItem(iframeTabActiveItem);
3353
3379
  document.title = iframeTabActiveItem.metaTitle || iframeTabActiveItem.name;
3354
3380
  navigate(iframeTabActiveItem.pathSearch);
3381
+ onIframeTabActiveEvent === null || onIframeTabActiveEvent === void 0 || onIframeTabActiveEvent(iframeTabActiveItem);
3355
3382
  }
3356
- }, [iframeTabActiveItem]);
3383
+ }, [iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id]);
3357
3384
  var onChangeCollapsed = function onChangeCollapsed(boo) {
3358
3385
  if (boo) {
3359
3386
  opendKeysTempRef.current = opendKeys;