@flatbiz/pro-layout 5.0.27 → 5.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.
package/dist/index.d.ts CHANGED
@@ -587,6 +587,8 @@ export type BootstrapOptions = {
587
587
  };
588
588
  /** 浏览器title */
589
589
  browserTitle?: string;
590
+ /** 获取全局数据,默认值使用window.GLOBAL */
591
+ getGlobalData?: () => Promise<TGlobalData>;
590
592
  };
591
593
  export type LayoutCtxProps = {
592
594
  menus: TMenuItem[];
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ import { isUndefined } from '@dimjs/lang/is-undefined';
21
21
  import { isFragment } from 'react-is';
22
22
  import { createCtx as createCtx$1 } from '@wove/react/create-ctx';
23
23
  import { createRoot } from 'react-dom/client';
24
+ import { useAsyncEffect } from 'ahooks';
24
25
  import { getQueryString } from '@dimjs/utils/uri/get-query-string';
25
26
  import { extend } from '@dimjs/utils/extend/extend';
26
27
  import { get } from '@dimjs/utils/get/get';
@@ -4533,7 +4534,7 @@ var proLayoutModels = Model({
4533
4534
  ProLayoutModel: ProLayoutModel
4534
4535
  });
4535
4536
 
4536
- var Bootstrap = function Bootstrap(options) {
4537
+ var BootstrapContent = function BootstrapContent(options) {
4537
4538
  var _options$headerThemeC, _options$headerThemeC2, _options$headerThemeC3, _options$sidebarTheme, _options$sidebarTheme2, _options$sidebarTheme3;
4538
4539
  var _proLayoutModels$useS = proLayoutModels.useStore('ProLayoutModel'),
4539
4540
  _proLayoutModels$useS2 = _slicedToArray(_proLayoutModels$useS, 1),
@@ -4762,6 +4763,71 @@ var Bootstrap = function Bootstrap(options) {
4762
4763
  }));
4763
4764
  };
4764
4765
 
4766
+ var Bootstrap = function Bootstrap(options) {
4767
+ var _useState = useState(false),
4768
+ _useState2 = _slicedToArray(_useState, 2),
4769
+ renderFlag = _useState2[0],
4770
+ setRenderFlag = _useState2[1];
4771
+ var _useState3 = useState(''),
4772
+ _useState4 = _slicedToArray(_useState3, 2),
4773
+ errorMessage = _useState4[0],
4774
+ setErrorMessage = _useState4[1];
4775
+ useAsyncEffect(function () {
4776
+ return new Promise(function ($return, $error) {
4777
+ var globalData;
4778
+ var $Try_1_Post = function () {
4779
+ try {
4780
+ return $return();
4781
+ } catch ($boundEx) {
4782
+ return $error($boundEx);
4783
+ }
4784
+ };
4785
+ var $Try_1_Catch = function (error) {
4786
+ try {
4787
+ setErrorMessage((error === null || error === void 0 ? void 0 : error['message']) || '获取初始加载数据失败');
4788
+ return $Try_1_Post();
4789
+ } catch ($boundEx) {
4790
+ return $error($boundEx);
4791
+ }
4792
+ };
4793
+ try {
4794
+ if (options.getGlobalData) {
4795
+ return Promise.resolve(options.getGlobalData()).then(function ($await_3) {
4796
+ try {
4797
+ globalData = $await_3;
4798
+ if (globalData) {
4799
+ window['GLOBAL'] = globalData;
4800
+ }
4801
+ return $If_2.call(this);
4802
+ } catch ($boundEx) {
4803
+ return $Try_1_Catch($boundEx);
4804
+ }
4805
+ }.bind(this), $Try_1_Catch);
4806
+ }
4807
+ function $If_2() {
4808
+ setRenderFlag(true);
4809
+ return $Try_1_Post();
4810
+ }
4811
+ return $If_2.call(this);
4812
+ } catch (error) {
4813
+ $Try_1_Catch(error);
4814
+ }
4815
+ });
4816
+ }, []);
4817
+ if (errorMessage) {
4818
+ return /*#__PURE__*/jsx(Result, {
4819
+ status: "error",
4820
+ title: errorMessage
4821
+ });
4822
+ }
4823
+ if (!renderFlag) {
4824
+ return /*#__PURE__*/jsx(Loader, {
4825
+ spinning: true
4826
+ });
4827
+ }
4828
+ return /*#__PURE__*/jsx(BootstrapContent, _objectSpread2({}, options));
4829
+ };
4830
+
4765
4831
  /**
4766
4832
  * ```
4767
4833
  * 1. 外部针对出现 iframe tab标题为未知页面的配置、或者想修改二级页面tab标题的,在main模块中设置