@flatbiz/pro-layout 5.0.26 → 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 +4 -0
- package/dist/index.js +90 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -585,6 +585,10 @@ export type BootstrapOptions = {
|
|
|
585
585
|
rc: string;
|
|
586
586
|
prod: string;
|
|
587
587
|
};
|
|
588
|
+
/** 浏览器title */
|
|
589
|
+
browserTitle?: string;
|
|
590
|
+
/** 获取全局数据,默认值使用window.GLOBAL */
|
|
591
|
+
getGlobalData?: () => Promise<TGlobalData>;
|
|
588
592
|
};
|
|
589
593
|
export type LayoutCtxProps = {
|
|
590
594
|
menus: TMenuItem[];
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { App as App$1, Breadcrumb, FloatButton, Result, Button, message as messa
|
|
|
6
6
|
import { classNames } from '@dimjs/utils/class-names/class-names';
|
|
7
7
|
import { createContext, useContext, useEffect, useMemo, Fragment, Children, cloneElement, forwardRef, useState, useImperativeHandle, isValidElement, Suspense, useRef, memo, Component } from 'react';
|
|
8
8
|
import { useParams, useLocation, useSearchParams, matchPath, Link, useNavigate, Routes, Route, Navigate, BrowserRouter } from 'react-router-dom';
|
|
9
|
-
import { getGlobalData, sessionStorageCache, ensureSlash as ensureSlash$1, removeSlash, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, isWindowsEnv, valueIsEqual, toLinkPathWithQuery, openNewWindow, treeToArray, cloneObject, getUuid, EventEmitter, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull } from '@flatbiz/utils';
|
|
9
|
+
import { getGlobalData, sessionStorageCache, ensureSlash as ensureSlash$1, removeSlash, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, isWindowsEnv, valueIsEqual, toLinkPathWithQuery, openNewWindow, treeToArray, cloneObject, getUuid, EventEmitter, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull, localStorageCache } from '@flatbiz/utils';
|
|
10
10
|
import { hooks } from '@wove/react/hooks';
|
|
11
11
|
import { parse } from '@dimjs/utils/json/parse';
|
|
12
12
|
import { isArray } from '@dimjs/lang/is-array';
|
|
@@ -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';
|
|
@@ -3005,7 +3006,7 @@ var SiderBar = function SiderBar() {
|
|
|
3005
3006
|
}
|
|
3006
3007
|
if (targetItem.path) {
|
|
3007
3008
|
navigate(toLinkPath(targetItem.path));
|
|
3008
|
-
document.title = targetItem.metaTitle || targetItem.name;
|
|
3009
|
+
document.title = targetItem.metaTitle || layoutCtx.browserTitle || targetItem.name;
|
|
3009
3010
|
}
|
|
3010
3011
|
});
|
|
3011
3012
|
var onOpenChange = hooks.useCallbackRef(function (openKeys) {
|
|
@@ -3847,7 +3848,7 @@ var AppProvider = function AppProvider(props) {
|
|
|
3847
3848
|
opendKeysTempRef.current = chainMenuIdList;
|
|
3848
3849
|
setSiderBarMenuActiveItem(siderbarTargetMenu);
|
|
3849
3850
|
// initSiderBarMenuActiveItemRef.current = siderbarTargetMenu;
|
|
3850
|
-
document.title = siderbarTargetMenu.metaTitle || siderbarTargetMenu.name;
|
|
3851
|
+
document.title = siderbarTargetMenu.metaTitle || options.browserTitle || siderbarTargetMenu.name;
|
|
3851
3852
|
} else {
|
|
3852
3853
|
if (options.disableTopbarMenu) {
|
|
3853
3854
|
siderBarMenus = menus;
|
|
@@ -3898,7 +3899,7 @@ var AppProvider = function AppProvider(props) {
|
|
|
3898
3899
|
fbaHooks.useEffectCustom(function () {
|
|
3899
3900
|
if (iframeTabActiveItem !== null && iframeTabActiveItem !== void 0 && iframeTabActiveItem.id) {
|
|
3900
3901
|
saveCacheIframeActiveItem(iframeTabActiveItem);
|
|
3901
|
-
document.title = iframeTabActiveItem.metaTitle || iframeTabActiveItem.name;
|
|
3902
|
+
document.title = iframeTabActiveItem.metaTitle || options.browserTitle || iframeTabActiveItem.name;
|
|
3902
3903
|
navigate(iframeTabActiveItem.pathSearch);
|
|
3903
3904
|
onIframeTabActiveEvent === null || onIframeTabActiveEvent === void 0 || onIframeTabActiveEvent(iframeTabActiveItem);
|
|
3904
3905
|
iframeApi.broadcastMessages({
|
|
@@ -4208,7 +4209,7 @@ var AppProvider = function AppProvider(props) {
|
|
|
4208
4209
|
setSelectedKeys(chainMenuIdList);
|
|
4209
4210
|
setOpendKeys(chainMenuIdList);
|
|
4210
4211
|
setSiderBarMenuActiveItem(siderbarTargetMenu);
|
|
4211
|
-
document.title = siderbarTargetMenu.metaTitle || siderbarTargetMenu.name;
|
|
4212
|
+
document.title = siderbarTargetMenu.metaTitle || options.browserTitle || siderbarTargetMenu.name;
|
|
4212
4213
|
} else {
|
|
4213
4214
|
if (options.disableTopbarMenu) {
|
|
4214
4215
|
setSelectedKeys([]);
|
|
@@ -4533,7 +4534,7 @@ var proLayoutModels = Model({
|
|
|
4533
4534
|
ProLayoutModel: ProLayoutModel
|
|
4534
4535
|
});
|
|
4535
4536
|
|
|
4536
|
-
var
|
|
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),
|
|
@@ -4679,13 +4680,28 @@ var Bootstrap = function Bootstrap(options) {
|
|
|
4679
4680
|
var isNoLayout = ['no-layout', 'iframe-tab'].includes(layoutMode);
|
|
4680
4681
|
var ContainerWrapper = options.containerWrapper || Fragment;
|
|
4681
4682
|
var configProviderProps = useMemo(function () {
|
|
4682
|
-
var _options$configProvid, _options$configProvid2;
|
|
4683
|
+
var _options$configProvid, _options$configProvid2, _options$configProvid3;
|
|
4683
4684
|
var algorithm = (_options$configProvid = options.configProviderProps) === null || _options$configProvid === void 0 || (_options$configProvid = _options$configProvid.theme) === null || _options$configProvid === void 0 ? void 0 : _options$configProvid.algorithm;
|
|
4684
4685
|
var algorithmArray = toArray(algorithm);
|
|
4685
4686
|
algorithmArray = [].concat(_toConsumableArray(algorithmArray), [isDark ? theme.darkAlgorithm : null, options.compact ? theme.compactAlgorithm : null]).filter(Boolean);
|
|
4687
|
+
var configTheme = (_options$configProvid2 = options.configProviderProps) === null || _options$configProvid2 === void 0 ? void 0 : _options$configProvid2.theme;
|
|
4688
|
+
var token = configTheme === null || configTheme === void 0 ? void 0 : configTheme.token;
|
|
4689
|
+
var components = configTheme === null || configTheme === void 0 ? void 0 : configTheme.components;
|
|
4690
|
+
var cacheName = "custom-antd-theme-".concat(globalData.appName);
|
|
4691
|
+
var customAntdTheme = localStorageCache.get(cacheName);
|
|
4692
|
+
var tokenNew = token || (customAntdTheme === null || customAntdTheme === void 0 ? void 0 : customAntdTheme.token);
|
|
4693
|
+
var componentsNew = components || (customAntdTheme === null || customAntdTheme === void 0 ? void 0 : customAntdTheme.components);
|
|
4694
|
+
if (tokenNew || componentsNew) {
|
|
4695
|
+
localStorageCache.set(cacheName, {
|
|
4696
|
+
token: tokenNew,
|
|
4697
|
+
components: componentsNew
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4686
4700
|
return _objectSpread2(_objectSpread2({}, options.configProviderProps), {}, {
|
|
4687
|
-
theme: _objectSpread2(_objectSpread2({}, (_options$
|
|
4688
|
-
algorithm: algorithmArray
|
|
4701
|
+
theme: _objectSpread2(_objectSpread2({}, (_options$configProvid3 = options.configProviderProps) === null || _options$configProvid3 === void 0 ? void 0 : _options$configProvid3.theme), {}, {
|
|
4702
|
+
algorithm: algorithmArray,
|
|
4703
|
+
token: tokenNew,
|
|
4704
|
+
components: componentsNew
|
|
4689
4705
|
})
|
|
4690
4706
|
});
|
|
4691
4707
|
}, [isDark, options.compact, options.configProviderProps]);
|
|
@@ -4747,6 +4763,71 @@ var Bootstrap = function Bootstrap(options) {
|
|
|
4747
4763
|
}));
|
|
4748
4764
|
};
|
|
4749
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
|
+
|
|
4750
4831
|
/**
|
|
4751
4832
|
* ```
|
|
4752
4833
|
* 1. 外部针对出现 iframe tab标题为未知页面的配置、或者想修改二级页面tab标题的,在main模块中设置
|