@flatbiz/pro-layout 5.2.8 → 5.2.9

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.js CHANGED
@@ -2,33 +2,29 @@
2
2
  import './index.css';
3
3
  /*! @flatjs/forge MIT @flatbiz/pro-layout */
4
4
 
5
- import { App as App$1, Breadcrumb, FloatButton, Result, Button, Dropdown, Space, Menu, Badge, Layout, message as message$1, Tabs, Typography, theme } from 'antd';
6
- import { classNames } from '@dimjs/utils/class-names/class-names';
7
- import { useEffect, useMemo, Fragment, Children, cloneElement, forwardRef, useState, useImperativeHandle, isValidElement, Suspense, useRef, memo, Component } from 'react';
8
- import { useParams, useLocation, useSearchParams, matchPath, Link, useNavigate, Routes, Route, Navigate, BrowserRouter } from 'react-router-dom';
9
- import { sessionStorageCache, getRunningEnv, ensureSlash as ensureSlash$1, removeSlash, getGlobalData, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, isWindows, valueIsEqual, toLinkPathWithQuery, openNewWindow, treeToArray, cloneObject, getUuid, EventEmitter, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull, localStorageCache } from '@flatbiz/utils';
10
- import { fbaHooks } from '@flatbiz/antd/fba-hooks';
11
- import { parse } from '@dimjs/utils/json/parse';
5
+ import { useEffect, useMemo, Fragment, isValidElement, Suspense, useState, useRef, memo, Component, Children, cloneElement, forwardRef, useImperativeHandle } from 'react';
12
6
  import { useMemoizedFn, useUpdateEffect, useDebounceFn, useAsyncEffect } from 'ahooks';
13
- import { isArray } from '@dimjs/lang/is-array';
14
- import { pick } from '@dimjs/utils/pick/pick';
15
- import { paramStrToJson } from '@dimjs/utils/uri/param-str-to-json';
16
- import { jsx, jsxs } from 'react/jsx-runtime';
17
- import { ButtonWrapper } from '@flatbiz/antd/button-wrapper';
18
- import { isPromise } from '@dimjs/lang/is-promise';
19
- import { isHttpUrl } from '@dimjs/utils/uri/is-http-url';
20
- import { modifyQueryString } from '@dimjs/utils/uri/modify-query-string';
21
- import { uriParse } from '@dimjs/utils/uri/uri-parse';
22
- import { isUndefined } from '@dimjs/lang/is-undefined';
23
- import { isFragment } from 'react-is';
24
- import { createRoot } from 'react-dom/client';
7
+ import { App as App$1, Result, Breadcrumb, FloatButton, Dropdown, Space, Button, Menu, Badge, Layout, message as message$1, Tabs, Typography, theme } from 'antd';
25
8
  import { ConfigProviderWrapper } from '@flatbiz/antd/config-provider-wrapper';
26
9
  import { FbaApp } from '@flatbiz/antd/fba-app';
27
10
  import { getQueryString } from '@dimjs/utils/uri/get-query-string';
11
+ import { isArray } from '@dimjs/lang/is-array';
28
12
  import { extend } from '@dimjs/utils/extend/extend';
13
+ import { useParams, useLocation, useSearchParams, matchPath, Link, Routes, Route, Navigate, useNavigate, BrowserRouter } from 'react-router-dom';
14
+ import { getRunningEnv, sessionStorageCache, ensureSlash as ensureSlash$1, removeSlash, getGlobalData, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, valueIsEqual, toLinkPathWithQuery, openNewWindow, isWindows, treeToArray, cloneObject, getUuid, EventEmitter, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull, localStorageCache } from '@flatbiz/utils';
29
15
  import { get } from '@dimjs/utils/get/get';
16
+ import { fbaHooks } from '@flatbiz/antd/fba-hooks';
17
+ import { jsx, jsxs } from 'react/jsx-runtime';
30
18
  import { isString } from '@dimjs/lang/is-string';
19
+ import { classNames } from '@dimjs/utils/class-names/class-names';
20
+ import { parse } from '@dimjs/utils/json/parse';
21
+ import { pick } from '@dimjs/utils/pick/pick';
22
+ import { paramStrToJson } from '@dimjs/utils/uri/param-str-to-json';
23
+ import { isHttpUrl } from '@dimjs/utils/uri/is-http-url';
24
+ import { modifyQueryString } from '@dimjs/utils/uri/modify-query-string';
25
+ import { uriParse } from '@dimjs/utils/uri/uri-parse';
31
26
  import _CloseOutlined from '@ant-design/icons/es/icons/CloseOutlined.js';
27
+ import { isUndefined } from '@dimjs/lang/is-undefined';
32
28
  import { useMediaQuery } from 'react-responsive';
33
29
  import { SvgHttpView } from '@flatbiz/antd/svg-http-view';
34
30
  import { findAncestors } from '@dimjs/utils/tree/find-ancestors';
@@ -45,17 +41,10 @@ import _CaretDownOutlined from '@ant-design/icons/es/icons/CaretDownOutlined.js'
45
41
  import _LoadingOutlined from '@ant-design/icons/es/icons/LoadingOutlined.js';
46
42
  import _RedoOutlined from '@ant-design/icons/es/icons/RedoOutlined.js';
47
43
  import { arrayRemove } from '@dimjs/utils/array/array-remove';
48
-
49
- var message;
50
- var notification;
51
- var modal;
52
- var useAntdApp = (function () {
53
- var staticFunction = App$1.useApp();
54
- message = staticFunction.message;
55
- modal = staticFunction.modal;
56
- notification = staticFunction.notification;
57
- return null;
58
- });
44
+ import { ButtonWrapper } from '@flatbiz/antd/button-wrapper';
45
+ import { isPromise } from '@dimjs/lang/is-promise';
46
+ import { isFragment } from 'react-is';
47
+ import { createRoot } from 'react-dom/client';
59
48
 
60
49
  function _arrayLikeToArray(r, a) {
61
50
  (null == a || a > r.length) && (a = r.length);
@@ -237,6 +226,91 @@ function _unsupportedIterableToArray(r, a) {
237
226
  }
238
227
  }
239
228
 
229
+ var AntdAppWrapper = function AntdAppWrapper(props) {
230
+ var theme = fbaHooks.useThemeToken();
231
+ var appProviderValue = props.appProviderValue;
232
+ var headerThemeConfig = appProviderValue.headerThemeConfig;
233
+ var sidebarThemeConfig = appProviderValue.sidebarThemeConfig;
234
+ var varStyleList = [{
235
+ '--header-bgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.bgColor
236
+ }, {
237
+ '--header-textColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.textColor
238
+ }, {
239
+ '--header-menuColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuColor
240
+ }, {
241
+ '--header-menuActiveTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveTextColor
242
+ }, {
243
+ '--header-menuActiveBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveBgColor
244
+ }, {
245
+ '--header-menuSelectedBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedBgColor
246
+ }, {
247
+ '--header-menuSelectedTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedTextColor
248
+ }, {
249
+ '--sidebar-bgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.bgColor
250
+ }, {
251
+ '--sidebar-menuActiveBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveBgColor
252
+ }, {
253
+ '--sidebar-menuActiveTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveTextColor
254
+ }, {
255
+ '--sidebar-menuSelectedBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedBgColor
256
+ }, {
257
+ '--sidebar-menuSelectedTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedTextColor
258
+ }, {
259
+ '--sidebar-menuSubMenuBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSubMenuBgColor
260
+ }, {
261
+ '--sidebar-menuColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuColor
262
+ }, {
263
+ '--color-primary': theme.colorPrimary
264
+ }];
265
+ if (appProviderValue.dark) {
266
+ varStyleList.push({
267
+ '--block-bg-color': get(appProviderValue, 'bgColorConfig.dark.blockBgColor', '#000')
268
+ });
269
+ varStyleList.push({
270
+ '--bg-color': get(appProviderValue, 'bgColorConfig.dark.bgColor', '#1b1a1a')
271
+ });
272
+ } else {
273
+ varStyleList.push({
274
+ '--block-bg-color': get(appProviderValue, 'bgColorConfig.light.blockBgColor', '#FFF')
275
+ });
276
+ varStyleList.push({
277
+ '--bg-color': get(appProviderValue, 'bgColorConfig.light.bgColor', '#F2F2F2')
278
+ });
279
+ }
280
+ var varStyleText = '';
281
+ varStyleList.forEach(function (item) {
282
+ var key = Object.keys(item)[0];
283
+ if (item[key]) {
284
+ varStyleText = varStyleText + "".concat(key, ":").concat(item[key], ";");
285
+ }
286
+ });
287
+ document.body.style.cssText = "".concat(document.body.style.cssText, ";").concat(varStyleText);
288
+ if (appProviderValue.dark) {
289
+ document.body.classList.remove('light-theme');
290
+ document.body.classList.add('dark-theme');
291
+ } else {
292
+ document.body.classList.remove('dark-theme');
293
+ document.body.classList.add('light-theme');
294
+ }
295
+ if (appProviderValue.compact) {
296
+ document.body.classList.add('compact-theme');
297
+ } else {
298
+ document.body.classList.remove('compact-theme');
299
+ }
300
+ return /*#__PURE__*/jsx(App$1, {
301
+ className: appProviderValue.className,
302
+ children: props.children
303
+ });
304
+ };
305
+
306
+ var NotFound = function NotFound() {
307
+ return /*#__PURE__*/jsx(Result, {
308
+ status: "404",
309
+ title: "404",
310
+ subTitle: "Sorry, \u60A8\u8BBF\u95EE\u7684\u5730\u5740\u4E0D\u5B58\u5728"
311
+ });
312
+ };
313
+
240
314
  var _fbaHooks$createCtx$1 = fbaHooks.createCtx(),
241
315
  _fbaHooks$createCtx2$1 = _slicedToArray(_fbaHooks$createCtx$1, 2),
242
316
  useLayoutCtx = _fbaHooks$createCtx2$1[0],
@@ -839,6 +913,31 @@ var Bread = function Bread(props) {
839
913
  });
840
914
  };
841
915
 
916
+ var Loader = function Loader(_ref) {
917
+ var _ref$spinning = _ref.spinning,
918
+ spinning = _ref$spinning === void 0 ? false : _ref$spinning,
919
+ _ref$fullScreen = _ref.fullScreen,
920
+ fullScreen = _ref$fullScreen === void 0 ? false : _ref$fullScreen,
921
+ _ref$style = _ref.style,
922
+ style = _ref$style === void 0 ? {} : _ref$style;
923
+ return /*#__PURE__*/jsx("div", {
924
+ style: style,
925
+ className: classNames('loader', {
926
+ hidden: !spinning,
927
+ fullScreen: fullScreen
928
+ }),
929
+ children: /*#__PURE__*/jsxs("div", {
930
+ className: "loader-wrapper",
931
+ children: [/*#__PURE__*/jsx("div", {
932
+ className: "loader-inner"
933
+ }), /*#__PURE__*/jsx("div", {
934
+ className: "loader-text",
935
+ children: "LOADING"
936
+ })]
937
+ })
938
+ });
939
+ };
940
+
842
941
  // export const urlJoin = (first: string, second: string) => {
843
942
  // return (first || '').replace(/\/$/, '') + '/' + (second || '').replace(/^\//, '');
844
943
  // };
@@ -1217,485 +1316,91 @@ var getSameProtocolUrl = function getSameProtocolUrl(url) {
1217
1316
  return "".concat(protocol, "//").concat(newUrl);
1218
1317
  };
1219
1318
 
1220
- var _excluded$3 = ["level"];
1319
+ var AppRoutes = function AppRoutes(props) {
1320
+ var getHideBreadsFlag = function getHideBreadsFlag() {
1321
+ var _props$hideBreadsPath;
1322
+ var target = (_props$hideBreadsPath = props.hideBreadsPathList) === null || _props$hideBreadsPath === void 0 ? void 0 : _props$hideBreadsPath.find(function (item) {
1323
+ if (props.layoutMode === 'iframe-tab') {
1324
+ return getIframeMainPurePath(item) == getIframeMainPurePath(location.pathname);
1325
+ }
1326
+ return getPurePath(item) == getPurePath(location.pathname);
1327
+ });
1328
+ if (target) return true;
1329
+ return !!getQueryString('hideBreads');
1330
+ };
1331
+ var hideBreads = getHideBreadsFlag();
1332
+ var routeList = props.routeList;
1333
+ var globbingRouteList = routeList.filter(function (item) {
1334
+ return valueIsEqual(item.path, ['*', '/*', '/*/']);
1335
+ });
1336
+ return /*#__PURE__*/jsx(Fragment, {
1337
+ children: /*#__PURE__*/jsxs(Routes, {
1338
+ children: [routeList.map(function (route, index) {
1339
+ var path = route.path,
1340
+ caseSensitive = route.caseSensitive,
1341
+ Element = route.element,
1342
+ redirect = route.redirect;
1343
+ var isGlobbing = valueIsEqual(path, ['*', '/*', '/*/']);
1344
+ if (isString(redirect)) {
1345
+ return /*#__PURE__*/jsx(Route, {
1346
+ path: path,
1347
+ element: /*#__PURE__*/jsx(Navigate, {
1348
+ to: toLinkPathWithQuery(redirect)
1349
+ })
1350
+ }, index);
1351
+ }
1352
+ if (Element) {
1353
+ var elementRender = null;
1354
+ if (/*#__PURE__*/isValidElement(Element)) {
1355
+ elementRender = Element;
1356
+ } else {
1357
+ var CElement = Element;
1358
+ elementRender = /*#__PURE__*/jsx(Suspense, {
1359
+ fallback: /*#__PURE__*/jsx(Loader, {
1360
+ spinning: true
1361
+ }),
1362
+ children: /*#__PURE__*/jsx(CElement, {})
1363
+ });
1364
+ }
1365
+ var tempPath = isGlobbing ? '*' : path.endsWith('/*') ? path : urlJoinMulti(path, '*');
1366
+ return /*#__PURE__*/jsx(Route, {
1367
+ path: tempPath,
1368
+ caseSensitive: caseSensitive,
1369
+ element: /*#__PURE__*/jsxs(Fragment, {
1370
+ children: [props.breads && props.hideDefaultBread !== true && !hideBreads ? /*#__PURE__*/jsx(Bread, {
1371
+ children: props.breadExtendRender
1372
+ }) : null, elementRender]
1373
+ })
1374
+ }, index);
1375
+ }
1376
+ return null;
1377
+ }), globbingRouteList.length === 0 ? /*#__PURE__*/jsx(Route, {
1378
+ path: "*",
1379
+ element: /*#__PURE__*/jsx(NotFound, {})
1380
+ }) : null]
1381
+ })
1382
+ });
1383
+ };
1384
+
1385
+ var message;
1386
+ var notification;
1387
+ var modal;
1388
+ var useAntdApp = (function () {
1389
+ var staticFunction = App$1.useApp();
1390
+ message = staticFunction.message;
1391
+ modal = staticFunction.modal;
1392
+ notification = staticFunction.notification;
1393
+ return null;
1394
+ });
1395
+
1396
+ var currentIsIframe = function currentIsIframe() {
1397
+ return self != top;
1398
+ };
1399
+
1221
1400
  /**
1222
- * 通过面包屑路径返回
1223
- * @param props
1224
- * @returns
1401
+ * Iframe Tab 模块使用
1225
1402
  * ```
1226
- * 1. breads 模块面包屑配置
1227
- * 2. level回退级别,如果传递数据未获取到路由配置,则取上一级
1228
- * 例如:-1,-2,-3
1229
- * 3. 为什么不能使用useNavigate(-1)
1230
- * 因为内部iframe和外部浏览器共用history历史记录,导致里外浏览器栈混乱
1231
- * 4. 什么场景使用
1232
- * 使用iframe tab的项目,在执行路由回退时使用
1233
- * 5. onClick返回 promise reject,则不会进行回退处理(V4.2.4)
1234
- * ```
1235
- */
1236
- var HistoryBackButton = function HistoryBackButton(props) {
1237
- var ctx = bootstrapCtx();
1238
- var level = props.level,
1239
- otherProps = _objectWithoutProperties(props, _excluded$3);
1240
- var _getHostUrlAndRouteBa = getHostUrlAndRouteBaseName(location.href),
1241
- routeBaseName = _getHostUrlAndRouteBa.routeBaseName;
1242
- var routerList = useBread(ctx.breads, routeBaseName);
1243
- var navigate = useNavigate();
1244
- var path = useMemo(function () {
1245
- var newLevel = level || -1;
1246
- if (routerList.length >= 2) {
1247
- var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
1248
- if (routerItem) {
1249
- return toLinkPath(routerItem.path, routerItem.query);
1250
- } else {
1251
- console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
1252
- return '';
1253
- }
1254
- }
1255
- console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
1256
- return '';
1257
- }, []);
1258
- var onBack = function onBack() {
1259
- if (path) {
1260
- navigate(toLinkPath(path));
1261
- } else {
1262
- console.warn("\u672A\u83B7\u53D6\u5230\u9762\u5305\u5C51\u6570\u636E\uFF0C\u65E0\u8FD4\u56DE\u94FE\u63A5");
1263
- }
1264
- };
1265
- var onClick = useMemoizedFn(function (event) {
1266
- var _props$onClick;
1267
- var result = props === null || props === void 0 || (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, event);
1268
- if (result && isPromise(result)) {
1269
- return result.then(function () {
1270
- onBack();
1271
- });
1272
- }
1273
- onBack();
1274
- return;
1275
- });
1276
- return /*#__PURE__*/jsx(ButtonWrapper, _objectSpread2(_objectSpread2({}, otherProps), {}, {
1277
- onClick: onClick,
1278
- children: props.children || '返回'
1279
- }));
1280
- };
1281
- var useHistoryBack = function useHistoryBack(props) {
1282
- var ctx = bootstrapCtx();
1283
- var level = (props === null || props === void 0 ? void 0 : props.level) || -1;
1284
- var _getHostUrlAndRouteBa2 = getHostUrlAndRouteBaseName(location.href),
1285
- routeBaseName = _getHostUrlAndRouteBa2.routeBaseName;
1286
- var routerList = useBread(ctx.breads, routeBaseName);
1287
- var path = useMemo(function () {
1288
- var newLevel = level;
1289
- if (routerList.length >= 2) {
1290
- var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
1291
- if (routerItem) {
1292
- return toLinkPath(routerItem.path, routerItem.query);
1293
- } else {
1294
- console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
1295
- return '';
1296
- }
1297
- }
1298
- console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
1299
- return '';
1300
- }, []);
1301
- return {
1302
- path: path
1303
- };
1304
- };
1305
-
1306
- var Loader = function Loader(_ref) {
1307
- var _ref$spinning = _ref.spinning,
1308
- spinning = _ref$spinning === void 0 ? false : _ref$spinning,
1309
- _ref$fullScreen = _ref.fullScreen,
1310
- fullScreen = _ref$fullScreen === void 0 ? false : _ref$fullScreen,
1311
- _ref$style = _ref.style,
1312
- style = _ref$style === void 0 ? {} : _ref$style;
1313
- return /*#__PURE__*/jsx("div", {
1314
- style: style,
1315
- className: classNames('loader', {
1316
- hidden: !spinning,
1317
- fullScreen: fullScreen
1318
- }),
1319
- children: /*#__PURE__*/jsxs("div", {
1320
- className: "loader-wrapper",
1321
- children: [/*#__PURE__*/jsx("div", {
1322
- className: "loader-inner"
1323
- }), /*#__PURE__*/jsx("div", {
1324
- className: "loader-text",
1325
- children: "LOADING"
1326
- })]
1327
- })
1328
- });
1329
- };
1330
-
1331
- /**
1332
- * 页面包装组件
1333
- * ```
1334
- * 1. 如果初始化面包屑被隐藏,在特殊页面级可以独立设置显示面包屑
1335
- * <Page bread={<Bread />}/>
1336
- * 2. 如果需要在 面包屑上添加按钮,初始化设置 bootstrap.hideDefaultBread = true,在需要按钮的页面上配置
1337
- * <Page bread={<Bread><Button>我是按钮</Button></Bread>}/>
1338
- * ```
1339
- * @param props
1340
- * @returns
1341
- */
1342
- var Page = function Page(props) {
1343
- var loading = props.loading;
1344
- var isWin = isWindows();
1345
- var className = classNames('page', {
1346
- 'page-loading': loading,
1347
- 'page-flex': !isUndefined(props.fullIndex),
1348
- 'page-windows': isWin
1349
- }, props.className);
1350
- var backTopTarget = useMemoizedFn(function () {
1351
- if (!isUndefined(props.fullIndex)) {
1352
- return document.querySelector('.page-full');
1353
- }
1354
- return document.querySelector('.page');
1355
- });
1356
- return /*#__PURE__*/jsxs(Fragment, {
1357
- children: [props.bread, /*#__PURE__*/jsxs("div", {
1358
- style: props.style,
1359
- className: className,
1360
- id: props.elementId,
1361
- children: [Children.map(props.children, function (item, index) {
1362
- if (index === props.fullIndex) {
1363
- var _item$props;
1364
- return /*#__PURE__*/jsx(Fragment, {
1365
- children: /*#__PURE__*/cloneElement(item, {
1366
- className: classNames('page-full', item === null || item === void 0 || (_item$props = item['props']) === null || _item$props === void 0 ? void 0 : _item$props.className)
1367
- })
1368
- }, index);
1369
- }
1370
- return /*#__PURE__*/jsx(Fragment, {
1371
- children: item
1372
- }, index);
1373
- }), /*#__PURE__*/jsx(FloatButton.BackTop, {
1374
- target: backTopTarget
1375
- }), loading && /*#__PURE__*/jsx(Loader, {
1376
- spinning: true
1377
- })]
1378
- })]
1379
- });
1380
- };
1381
-
1382
- var _fbaHooks$createCtx = fbaHooks.createCtx(),
1383
- _fbaHooks$createCtx2 = _slicedToArray(_fbaHooks$createCtx, 2),
1384
- usePageWrapperCtx = _fbaHooks$createCtx2[0],
1385
- PageWrapperCtxProvider = _fbaHooks$createCtx2[1];
1386
-
1387
- var _excluded$2 = ["respData"],
1388
- _excluded2 = ["serviceConfig", "isAsync", "errorRender"];
1389
- var PageContent$1 = function PageContent(props) {
1390
- var _props$children;
1391
- var respData = props.respData,
1392
- otherProps = _objectWithoutProperties(props, _excluded$2);
1393
- var children = typeof props.children === 'function' ? (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.call(props, respData) : props.children;
1394
- if (isFragment(children)) {
1395
- var childrenList = Children.toArray(children.props.children);
1396
- return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
1397
- children: childrenList
1398
- }));
1399
- }
1400
- return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
1401
- children: children
1402
- }));
1403
- };
1404
-
1405
- /**
1406
- * 为Page内置接口处理流程组件,如果无全局初始化接口请求场景,请使用Page组件
1407
- * ```
1408
- * 包括
1409
- * 1. loading显示效果
1410
- * 2. error显示效果
1411
- * 3. 正常接口数据渲染
1412
- * ```
1413
- * @param props
1414
- * @returns
1415
- */
1416
- var PageWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
1417
- var serviceConfig = props.serviceConfig,
1418
- isAsync = props.isAsync,
1419
- errorRender = props.errorRender,
1420
- otherProps = _objectWithoutProperties(props, _excluded2);
1421
- var _useState = useState({
1422
- status: 'loading'
1423
- }),
1424
- _useState2 = _slicedToArray(_useState, 2),
1425
- result = _useState2[0],
1426
- setResult = _useState2[1];
1427
- var _useState3 = useState(false),
1428
- _useState4 = _slicedToArray(_useState3, 2),
1429
- againRefresh = _useState4[0],
1430
- setAgainRefresh = _useState4[1];
1431
- var onRequest = function onRequest() {
1432
- return new Promise(function ($return, $error) {
1433
- var params, _result;
1434
- var $Try_1_Post = function () {
1435
- try {
1436
- return $return(Promise.resolve());
1437
- } catch ($boundEx) {
1438
- return $error($boundEx);
1439
- }
1440
- };
1441
- var $Try_1_Catch = function (error) {
1442
- try {
1443
- setResult({
1444
- status: 'error',
1445
- respData: error
1446
- });
1447
- return $Try_1_Post();
1448
- } catch ($boundEx) {
1449
- return $error($boundEx);
1450
- }
1451
- };
1452
- try {
1453
- params = typeof serviceConfig.params === 'function' ? serviceConfig.params() : serviceConfig.params;
1454
- return Promise.resolve(serviceConfig.onRequest(params)).then(function ($await_2) {
1455
- try {
1456
- _result = $await_2;
1457
- setResult({
1458
- status: 'success',
1459
- respData: _result
1460
- });
1461
- return $Try_1_Post();
1462
- } catch ($boundEx) {
1463
- return $Try_1_Catch($boundEx);
1464
- }
1465
- }, $Try_1_Catch);
1466
- } catch (error) {
1467
- $Try_1_Catch(error);
1468
- }
1469
- });
1470
- };
1471
- fbaHooks.useEffectCustomAsync(onRequest, []);
1472
- var onReload = useMemoizedFn(function () {
1473
- setResult({
1474
- status: 'loading'
1475
- });
1476
- void onRequest();
1477
- });
1478
- var onRefresh = useMemoizedFn(function () {
1479
- setAgainRefresh(true);
1480
- onRequest().finally(function () {
1481
- setAgainRefresh(false);
1482
- });
1483
- });
1484
- useImperativeHandle(ref, function () {
1485
- return {
1486
- onRefresh: onRefresh,
1487
- onReload: onReload
1488
- };
1489
- });
1490
- if (result.status === 'error') {
1491
- var _result$respData;
1492
- if (errorRender) {
1493
- return errorRender(result.respData);
1494
- }
1495
- return /*#__PURE__*/jsx(Page, {
1496
- fullIndex: 0,
1497
- style: {
1498
- backgroundColor: '#fff'
1499
- },
1500
- children: /*#__PURE__*/jsx(Result, {
1501
- status: "error",
1502
- title: '数据获取异常',
1503
- subTitle: ((_result$respData = result.respData) === null || _result$respData === void 0 ? void 0 : _result$respData.message) || '数据请求异常',
1504
- extra: [/*#__PURE__*/jsx(Button, {
1505
- type: "primary",
1506
- onClick: onReload,
1507
- children: "\u91CD\u65B0\u83B7\u53D6"
1508
- }, "console")]
1509
- })
1510
- });
1511
- }
1512
- if (result.status === 'loading' && !isAsync) {
1513
- return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({
1514
- loading: true
1515
- }, otherProps), {}, {
1516
- children: /*#__PURE__*/jsx(Fragment, {})
1517
- }));
1518
- }
1519
- return /*#__PURE__*/jsxs(PageWrapperCtxProvider, {
1520
- value: {
1521
- onReload: onReload,
1522
- onRefresh: onRefresh
1523
- },
1524
- children: [againRefresh ? /*#__PURE__*/jsx(Loader, {
1525
- spinning: true,
1526
- style: {
1527
- backgroundColor: 'transparent'
1528
- }
1529
- }) : null, /*#__PURE__*/jsx(PageContent$1, _objectSpread2({
1530
- loading: result.status === 'loading',
1531
- respData: result.respData
1532
- }, otherProps))]
1533
- });
1534
- });
1535
- var usePageWrapper = function usePageWrapper() {
1536
- var ctx = usePageWrapperCtx();
1537
- return ctx;
1538
- };
1539
-
1540
- var AntdAppWrapper = function AntdAppWrapper(props) {
1541
- var theme = fbaHooks.useThemeToken();
1542
- var appProviderValue = props.appProviderValue;
1543
- var headerThemeConfig = appProviderValue.headerThemeConfig;
1544
- var sidebarThemeConfig = appProviderValue.sidebarThemeConfig;
1545
- var varStyleList = [{
1546
- '--header-bgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.bgColor
1547
- }, {
1548
- '--header-textColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.textColor
1549
- }, {
1550
- '--header-menuColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuColor
1551
- }, {
1552
- '--header-menuActiveTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveTextColor
1553
- }, {
1554
- '--header-menuActiveBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveBgColor
1555
- }, {
1556
- '--header-menuSelectedBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedBgColor
1557
- }, {
1558
- '--header-menuSelectedTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedTextColor
1559
- }, {
1560
- '--sidebar-bgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.bgColor
1561
- }, {
1562
- '--sidebar-menuActiveBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveBgColor
1563
- }, {
1564
- '--sidebar-menuActiveTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveTextColor
1565
- }, {
1566
- '--sidebar-menuSelectedBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedBgColor
1567
- }, {
1568
- '--sidebar-menuSelectedTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedTextColor
1569
- }, {
1570
- '--sidebar-menuSubMenuBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSubMenuBgColor
1571
- }, {
1572
- '--sidebar-menuColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuColor
1573
- }, {
1574
- '--color-primary': theme.colorPrimary
1575
- }];
1576
- if (appProviderValue.dark) {
1577
- varStyleList.push({
1578
- '--block-bg-color': get(appProviderValue, 'bgColorConfig.dark.blockBgColor', '#000')
1579
- });
1580
- varStyleList.push({
1581
- '--bg-color': get(appProviderValue, 'bgColorConfig.dark.bgColor', '#1b1a1a')
1582
- });
1583
- } else {
1584
- varStyleList.push({
1585
- '--block-bg-color': get(appProviderValue, 'bgColorConfig.light.blockBgColor', '#FFF')
1586
- });
1587
- varStyleList.push({
1588
- '--bg-color': get(appProviderValue, 'bgColorConfig.light.bgColor', '#F2F2F2')
1589
- });
1590
- }
1591
- var varStyleText = '';
1592
- varStyleList.forEach(function (item) {
1593
- var key = Object.keys(item)[0];
1594
- if (item[key]) {
1595
- varStyleText = varStyleText + "".concat(key, ":").concat(item[key], ";");
1596
- }
1597
- });
1598
- document.body.style.cssText = "".concat(document.body.style.cssText, ";").concat(varStyleText);
1599
- if (appProviderValue.dark) {
1600
- document.body.classList.remove('light-theme');
1601
- document.body.classList.add('dark-theme');
1602
- } else {
1603
- document.body.classList.remove('dark-theme');
1604
- document.body.classList.add('light-theme');
1605
- }
1606
- if (appProviderValue.compact) {
1607
- document.body.classList.add('compact-theme');
1608
- } else {
1609
- document.body.classList.remove('compact-theme');
1610
- }
1611
- return /*#__PURE__*/jsx(App$1, {
1612
- className: appProviderValue.className,
1613
- children: props.children
1614
- });
1615
- };
1616
-
1617
- var NotFound = function NotFound() {
1618
- return /*#__PURE__*/jsx(Result, {
1619
- status: "404",
1620
- title: "404",
1621
- subTitle: "Sorry, \u60A8\u8BBF\u95EE\u7684\u5730\u5740\u4E0D\u5B58\u5728"
1622
- });
1623
- };
1624
-
1625
- var AppRoutes = function AppRoutes(props) {
1626
- var getHideBreadsFlag = function getHideBreadsFlag() {
1627
- var _props$hideBreadsPath;
1628
- var target = (_props$hideBreadsPath = props.hideBreadsPathList) === null || _props$hideBreadsPath === void 0 ? void 0 : _props$hideBreadsPath.find(function (item) {
1629
- if (props.layoutMode === 'iframe-tab') {
1630
- return getIframeMainPurePath(item) == getIframeMainPurePath(location.pathname);
1631
- }
1632
- return getPurePath(item) == getPurePath(location.pathname);
1633
- });
1634
- if (target) return true;
1635
- return !!getQueryString('hideBreads');
1636
- };
1637
- var hideBreads = getHideBreadsFlag();
1638
- var routeList = props.routeList;
1639
- var globbingRouteList = routeList.filter(function (item) {
1640
- return valueIsEqual(item.path, ['*', '/*', '/*/']);
1641
- });
1642
- return /*#__PURE__*/jsx(Fragment, {
1643
- children: /*#__PURE__*/jsxs(Routes, {
1644
- children: [routeList.map(function (route, index) {
1645
- var path = route.path,
1646
- caseSensitive = route.caseSensitive,
1647
- Element = route.element,
1648
- redirect = route.redirect;
1649
- var isGlobbing = valueIsEqual(path, ['*', '/*', '/*/']);
1650
- if (isString(redirect)) {
1651
- return /*#__PURE__*/jsx(Route, {
1652
- path: path,
1653
- element: /*#__PURE__*/jsx(Navigate, {
1654
- to: toLinkPathWithQuery(redirect)
1655
- })
1656
- }, index);
1657
- }
1658
- if (Element) {
1659
- var elementRender = null;
1660
- if (/*#__PURE__*/isValidElement(Element)) {
1661
- elementRender = Element;
1662
- } else {
1663
- var CElement = Element;
1664
- elementRender = /*#__PURE__*/jsx(Suspense, {
1665
- fallback: /*#__PURE__*/jsx(Loader, {
1666
- spinning: true
1667
- }),
1668
- children: /*#__PURE__*/jsx(CElement, {})
1669
- });
1670
- }
1671
- var tempPath = isGlobbing ? '*' : path.endsWith('/*') ? path : urlJoinMulti(path, '*');
1672
- return /*#__PURE__*/jsx(Route, {
1673
- path: tempPath,
1674
- caseSensitive: caseSensitive,
1675
- element: /*#__PURE__*/jsxs(Fragment, {
1676
- children: [props.breads && props.hideDefaultBread !== true && !hideBreads ? /*#__PURE__*/jsx(Bread, {
1677
- children: props.breadExtendRender
1678
- }) : null, elementRender]
1679
- })
1680
- }, index);
1681
- }
1682
- return null;
1683
- }), globbingRouteList.length === 0 ? /*#__PURE__*/jsx(Route, {
1684
- path: "*",
1685
- element: /*#__PURE__*/jsx(NotFound, {})
1686
- }) : null]
1687
- })
1688
- });
1689
- };
1690
-
1691
- var currentIsIframe = function currentIsIframe() {
1692
- return self != top;
1693
- };
1694
-
1695
- /**
1696
- * Iframe Tab 模块使用
1697
- * ```
1698
- * 当Iframe Tab独立访问时,触发逻辑跳转正常访问页面(包含菜单)
1403
+ * 当Iframe Tab独立访问时,触发逻辑跳转正常访问页面(包含菜单)
1699
1404
  * ```
1700
1405
  */
1701
1406
  var IframeTabMode = function IframeTabMode(props) {
@@ -3126,7 +2831,7 @@ var getIframeTabUid = function getIframeTabUid(prefix) {
3126
2831
  return "".concat(prefix, "_").concat(iframeId);
3127
2832
  };
3128
2833
 
3129
- var _excluded$1 = ["_isClosed"];
2834
+ var _excluded$3 = ["_isClosed"];
3130
2835
  var EventHandling = function EventHandling() {
3131
2836
  var navigate = useNavigate();
3132
2837
  var layoutCtx = useLayoutCtx();
@@ -3137,7 +2842,7 @@ var EventHandling = function EventHandling() {
3137
2842
  if (result.type === 'redirect_to_frame_layout_menu_item') {
3138
2843
  var _ref = result.data,
3139
2844
  _isClosed = _ref._isClosed,
3140
- iframeTabItem = _objectWithoutProperties(_ref, _excluded$1);
2845
+ iframeTabItem = _objectWithoutProperties(_ref, _excluded$3);
3141
2846
  var targetIndex = layoutCtx.iframeTabList.findIndex(function (item) {
3142
2847
  var _layoutCtx$iframeTabA;
3143
2848
  return valueIsEqual(item.id, (_layoutCtx$iframeTabA = layoutCtx.iframeTabActiveItem) === null || _layoutCtx$iframeTabA === void 0 ? void 0 : _layoutCtx$iframeTabA.id);
@@ -3272,7 +2977,7 @@ var IframePage = /*#__PURE__*/memo(IframePageInner, function (prevProps, nextPro
3272
2977
  return prevProps.iframeKey === nextProps.iframeKey;
3273
2978
  });
3274
2979
 
3275
- var PageContent = function PageContent() {
2980
+ var PageContent$1 = function PageContent() {
3276
2981
  var _useLayoutCtx = useLayoutCtx(),
3277
2982
  iframeTabList = _useLayoutCtx.iframeTabList,
3278
2983
  iframeTabBarExtra = _useLayoutCtx.iframeTabBarExtra,
@@ -3669,7 +3374,7 @@ var LayoutIFrame = function LayoutIFrame() {
3669
3374
  });
3670
3375
  }
3671
3376
  if (layoutCtx.multiFrameTabs) {
3672
- return /*#__PURE__*/jsx(PageContent, {});
3377
+ return /*#__PURE__*/jsx(PageContent$1, {});
3673
3378
  }
3674
3379
  if (layoutCtx.siderBarMaxMenuLevel) {
3675
3380
  return /*#__PURE__*/jsx(PageLevelContent, {});
@@ -3728,7 +3433,7 @@ var NormalRoutesTiming = function NormalRoutesTiming() {
3728
3433
  return /*#__PURE__*/jsx(Fragment, {});
3729
3434
  };
3730
3435
 
3731
- var _excluded = ["sidebarWidth", "componentSize", "locale", "logoPath", "headerThemeConfig", "sidebarThemeConfig", "completeMenus", "onIframeTabActiveEvent"];
3436
+ var _excluded$2 = ["sidebarWidth", "componentSize", "locale", "logoPath", "headerThemeConfig", "sidebarThemeConfig", "completeMenus", "onIframeTabActiveEvent"];
3732
3437
  var AppProvider = function AppProvider(props) {
3733
3438
  var navigate = useNavigate();
3734
3439
  var sidebarWidth = props.sidebarWidth,
@@ -3739,7 +3444,7 @@ var AppProvider = function AppProvider(props) {
3739
3444
  sidebarThemeConfig = props.sidebarThemeConfig,
3740
3445
  completeMenus = props.completeMenus,
3741
3446
  onIframeTabActiveEvent = props.onIframeTabActiveEvent,
3742
- options = _objectWithoutProperties(props, _excluded);
3447
+ options = _objectWithoutProperties(props, _excluded$2);
3743
3448
  var isIframeMain = options.layoutMode === 'iframe-main';
3744
3449
  var unMatchHiddenSiderBar = useMemo(function () {
3745
3450
  if (options.disableTopbarMenu) {
@@ -4716,129 +4421,424 @@ var BootstrapContent = function BootstrapContent(options) {
4716
4421
  space: {
4717
4422
  size: componentSize
4718
4423
  }
4719
- }, configProviderProps), {}, {
4720
- children: /*#__PURE__*/jsx(ContainerWrapper, {
4721
- children: /*#__PURE__*/jsx(BrowserRouter, {
4722
- basename: globalValue.routeBaseName,
4723
- children: /*#__PURE__*/jsx(BootstrapCtx, {
4724
- value: {
4725
- breads: breadList,
4726
- breadTitle: appProviderValue.breadTitle,
4727
- breadcrumbProps: appProviderValue.breadcrumbProps,
4728
- layoutMode: appProviderValue.layoutMode
4729
- },
4730
- children: /*#__PURE__*/jsx(AntdAppWrapper, {
4731
- appProviderValue: appProviderValue,
4732
- children: /*#__PURE__*/jsx(FbaApp, {
4733
- children: /*#__PURE__*/jsxs(ErrorBoundary, {
4734
- onError: options.onError,
4735
- onReset: options.onErrorReset,
4736
- FallbackComponent: options.ErrorFallback || ErrorFallback,
4737
- children: [layoutMode === 'iframe-main' ? /*#__PURE__*/jsx(IframeMainRegister, {}) : null, /*#__PURE__*/jsx(Container, {
4738
- layoutMode: appProviderValue.layoutMode,
4739
- MenuEmptyRender: appProviderValue.MenuEmptyRender,
4740
- menus: menus,
4741
- ignoreMenuEmptyJudge: appProviderValue.ignoreMenuEmptyJudge,
4742
- children: isNoLayout ? /*#__PURE__*/jsx(AppNoLayout, {
4743
- routeList: routeList,
4744
- layoutMode: layoutMode,
4745
- LayoutComponent: appProviderValue.LayoutComponent,
4746
- breadExtendRender: appProviderValue.breadExtendRender,
4747
- breads: appProviderValue.breads,
4748
- hideDefaultBread: appProviderValue.hideDefaultBread,
4749
- hideHeader: appProviderValue.hideHeader,
4750
- breadTitle: appProviderValue.breadTitle,
4751
- iframeTabAloneView: appProviderValue.iframeTabAloneView,
4752
- layoutPageClassName: appProviderValue.layoutPageClassName,
4753
- hideBreadsPathList: appProviderValue.hideBreadsPathList,
4754
- developmentEnvGuideConfigs: appProviderValue.developmentEnvGuideConfigs,
4755
- showProdEnvGuide: appProviderValue.showProdEnvGuide,
4756
- hidenEnvGuide: appProviderValue.hidenEnvGuide
4757
- }) : /*#__PURE__*/jsx(AppProvider, _objectSpread2({}, appProviderValue))
4758
- })]
4759
- })
4424
+ }, configProviderProps), {}, {
4425
+ children: /*#__PURE__*/jsx(ContainerWrapper, {
4426
+ children: /*#__PURE__*/jsx(BrowserRouter, {
4427
+ basename: globalValue.routeBaseName,
4428
+ children: /*#__PURE__*/jsx(BootstrapCtx, {
4429
+ value: {
4430
+ breads: breadList,
4431
+ breadTitle: appProviderValue.breadTitle,
4432
+ breadcrumbProps: appProviderValue.breadcrumbProps,
4433
+ layoutMode: appProviderValue.layoutMode
4434
+ },
4435
+ children: /*#__PURE__*/jsx(AntdAppWrapper, {
4436
+ appProviderValue: appProviderValue,
4437
+ children: /*#__PURE__*/jsx(FbaApp, {
4438
+ children: /*#__PURE__*/jsxs(ErrorBoundary, {
4439
+ onError: options.onError,
4440
+ onReset: options.onErrorReset,
4441
+ FallbackComponent: options.ErrorFallback || ErrorFallback,
4442
+ children: [layoutMode === 'iframe-main' ? /*#__PURE__*/jsx(IframeMainRegister, {}) : null, /*#__PURE__*/jsx(Container, {
4443
+ layoutMode: appProviderValue.layoutMode,
4444
+ MenuEmptyRender: appProviderValue.MenuEmptyRender,
4445
+ menus: menus,
4446
+ ignoreMenuEmptyJudge: appProviderValue.ignoreMenuEmptyJudge,
4447
+ children: isNoLayout ? /*#__PURE__*/jsx(AppNoLayout, {
4448
+ routeList: routeList,
4449
+ layoutMode: layoutMode,
4450
+ LayoutComponent: appProviderValue.LayoutComponent,
4451
+ breadExtendRender: appProviderValue.breadExtendRender,
4452
+ breads: appProviderValue.breads,
4453
+ hideDefaultBread: appProviderValue.hideDefaultBread,
4454
+ hideHeader: appProviderValue.hideHeader,
4455
+ breadTitle: appProviderValue.breadTitle,
4456
+ iframeTabAloneView: appProviderValue.iframeTabAloneView,
4457
+ layoutPageClassName: appProviderValue.layoutPageClassName,
4458
+ hideBreadsPathList: appProviderValue.hideBreadsPathList,
4459
+ developmentEnvGuideConfigs: appProviderValue.developmentEnvGuideConfigs,
4460
+ showProdEnvGuide: appProviderValue.showProdEnvGuide,
4461
+ hidenEnvGuide: appProviderValue.hidenEnvGuide
4462
+ }) : /*#__PURE__*/jsx(AppProvider, _objectSpread2({}, appProviderValue))
4463
+ })]
4464
+ })
4465
+ })
4466
+ })
4467
+ })
4468
+ })
4469
+ })
4470
+ }));
4471
+ };
4472
+
4473
+ var Bootstrap = function Bootstrap(options) {
4474
+ var _useState = useState(false),
4475
+ _useState2 = _slicedToArray(_useState, 2),
4476
+ renderFlag = _useState2[0],
4477
+ setRenderFlag = _useState2[1];
4478
+ var _useState3 = useState(''),
4479
+ _useState4 = _slicedToArray(_useState3, 2),
4480
+ errorMessage = _useState4[0],
4481
+ setErrorMessage = _useState4[1];
4482
+ useAsyncEffect(function () {
4483
+ return new Promise(function ($return, $error) {
4484
+ var globalData, apiBase, hostUrl;
4485
+ var $Try_1_Post = function () {
4486
+ try {
4487
+ return $return();
4488
+ } catch ($boundEx) {
4489
+ return $error($boundEx);
4490
+ }
4491
+ };
4492
+ var $Try_1_Catch = function (error) {
4493
+ try {
4494
+ setErrorMessage((error === null || error === void 0 ? void 0 : error['message']) || '获取初始加载数据失败');
4495
+ return $Try_1_Post();
4496
+ } catch ($boundEx) {
4497
+ return $error($boundEx);
4498
+ }
4499
+ };
4500
+ try {
4501
+ if (options.layoutMode === 'iframe-main') {
4502
+ window['__flat_iframe_parent_window'] = true;
4503
+ }
4504
+ if (options.getGlobalData) {
4505
+ return Promise.resolve(options.getGlobalData()).then(function ($await_3) {
4506
+ try {
4507
+ globalData = $await_3;
4508
+ if (globalData) {
4509
+ window['GLOBAL'] = globalData;
4510
+ }
4511
+ return $If_2.call(this);
4512
+ } catch ($boundEx) {
4513
+ return $Try_1_Catch($boundEx);
4514
+ }
4515
+ }.bind(this), $Try_1_Catch);
4516
+ }
4517
+ function $If_2() {
4518
+ apiBase = window['GLOBAL'].apiBase;
4519
+ if (apiBase) {
4520
+ window['GLOBAL'].apiBase = getSameProtocolUrl(apiBase);
4521
+ }
4522
+ hostUrl = window['GLOBAL'].hostUrl;
4523
+ if (hostUrl) {
4524
+ window['GLOBAL'].hostUrl = getSameProtocolUrl(hostUrl);
4525
+ }
4526
+ setRenderFlag(true);
4527
+ return $Try_1_Post();
4528
+ }
4529
+ return $If_2.call(this);
4530
+ } catch (error) {
4531
+ $Try_1_Catch(error);
4532
+ }
4533
+ });
4534
+ }, []);
4535
+ if (errorMessage) {
4536
+ return /*#__PURE__*/jsx(Result, {
4537
+ status: "error",
4538
+ title: errorMessage
4539
+ });
4540
+ }
4541
+ if (!renderFlag) {
4542
+ return /*#__PURE__*/jsx(Loader, {
4543
+ spinning: true
4544
+ });
4545
+ }
4546
+ return /*#__PURE__*/jsx(BootstrapContent, _objectSpread2({}, options));
4547
+ };
4548
+
4549
+ var _excluded$1 = ["level"];
4550
+ /**
4551
+ * 通过面包屑路径返回
4552
+ * @param props
4553
+ * @returns
4554
+ * ```
4555
+ * 1. breads 模块面包屑配置
4556
+ * 2. level回退级别,如果传递数据未获取到路由配置,则取上一级
4557
+ * 例如:-1,-2,-3
4558
+ * 3. 为什么不能使用useNavigate(-1)
4559
+ * 因为内部iframe和外部浏览器共用history历史记录,导致里外浏览器栈混乱
4560
+ * 4. 什么场景使用
4561
+ * 使用iframe tab的项目,在执行路由回退时使用
4562
+ * 5. onClick返回 promise reject,则不会进行回退处理(V4.2.4)
4563
+ * ```
4564
+ */
4565
+ var HistoryBackButton = function HistoryBackButton(props) {
4566
+ var ctx = bootstrapCtx();
4567
+ var level = props.level,
4568
+ otherProps = _objectWithoutProperties(props, _excluded$1);
4569
+ var _getHostUrlAndRouteBa = getHostUrlAndRouteBaseName(location.href),
4570
+ routeBaseName = _getHostUrlAndRouteBa.routeBaseName;
4571
+ var routerList = useBread(ctx.breads, routeBaseName);
4572
+ var navigate = useNavigate();
4573
+ var path = useMemo(function () {
4574
+ var newLevel = level || -1;
4575
+ if (routerList.length >= 2) {
4576
+ var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
4577
+ if (routerItem) {
4578
+ return toLinkPath(routerItem.path, routerItem.query);
4579
+ } else {
4580
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
4581
+ return '';
4582
+ }
4583
+ }
4584
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
4585
+ return '';
4586
+ }, []);
4587
+ var onBack = function onBack() {
4588
+ if (path) {
4589
+ navigate(toLinkPath(path));
4590
+ } else {
4591
+ console.warn("\u672A\u83B7\u53D6\u5230\u9762\u5305\u5C51\u6570\u636E\uFF0C\u65E0\u8FD4\u56DE\u94FE\u63A5");
4592
+ }
4593
+ };
4594
+ var onClick = useMemoizedFn(function (event) {
4595
+ var _props$onClick;
4596
+ var result = props === null || props === void 0 || (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, event);
4597
+ if (result && isPromise(result)) {
4598
+ return result.then(function () {
4599
+ onBack();
4600
+ });
4601
+ }
4602
+ onBack();
4603
+ return;
4604
+ });
4605
+ return /*#__PURE__*/jsx(ButtonWrapper, _objectSpread2(_objectSpread2({}, otherProps), {}, {
4606
+ onClick: onClick,
4607
+ children: props.children || '返回'
4608
+ }));
4609
+ };
4610
+ var useHistoryBack = function useHistoryBack(props) {
4611
+ var ctx = bootstrapCtx();
4612
+ var level = (props === null || props === void 0 ? void 0 : props.level) || -1;
4613
+ var _getHostUrlAndRouteBa2 = getHostUrlAndRouteBaseName(location.href),
4614
+ routeBaseName = _getHostUrlAndRouteBa2.routeBaseName;
4615
+ var routerList = useBread(ctx.breads, routeBaseName);
4616
+ var path = useMemo(function () {
4617
+ var newLevel = level;
4618
+ if (routerList.length >= 2) {
4619
+ var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
4620
+ if (routerItem) {
4621
+ return toLinkPath(routerItem.path, routerItem.query);
4622
+ } else {
4623
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
4624
+ return '';
4625
+ }
4626
+ }
4627
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
4628
+ return '';
4629
+ }, []);
4630
+ return {
4631
+ path: path
4632
+ };
4633
+ };
4634
+
4635
+ /**
4636
+ * 页面包装组件
4637
+ * ```
4638
+ * 1. 如果初始化面包屑被隐藏,在特殊页面级可以独立设置显示面包屑
4639
+ * <Page bread={<Bread />}/>
4640
+ * 2. 如果需要在 面包屑上添加按钮,初始化设置 bootstrap.hideDefaultBread = true,在需要按钮的页面上配置
4641
+ * <Page bread={<Bread><Button>我是按钮</Button></Bread>}/>
4642
+ * ```
4643
+ * @param props
4644
+ * @returns
4645
+ */
4646
+ var Page = function Page(props) {
4647
+ var loading = props.loading;
4648
+ var isWin = isWindows();
4649
+ var className = classNames('page', {
4650
+ 'page-loading': loading,
4651
+ 'page-flex': !isUndefined(props.fullIndex),
4652
+ 'page-windows': isWin
4653
+ }, props.className);
4654
+ var backTopTarget = useMemoizedFn(function () {
4655
+ if (!isUndefined(props.fullIndex)) {
4656
+ return document.querySelector('.page-full');
4657
+ }
4658
+ return document.querySelector('.page');
4659
+ });
4660
+ return /*#__PURE__*/jsxs(Fragment, {
4661
+ children: [props.bread, /*#__PURE__*/jsxs("div", {
4662
+ style: props.style,
4663
+ className: className,
4664
+ id: props.elementId,
4665
+ children: [Children.map(props.children, function (item, index) {
4666
+ if (index === props.fullIndex) {
4667
+ var _item$props;
4668
+ return /*#__PURE__*/jsx(Fragment, {
4669
+ children: /*#__PURE__*/cloneElement(item, {
4670
+ className: classNames('page-full', item === null || item === void 0 || (_item$props = item['props']) === null || _item$props === void 0 ? void 0 : _item$props.className)
4760
4671
  })
4761
- })
4762
- })
4763
- })
4764
- })
4672
+ }, index);
4673
+ }
4674
+ return /*#__PURE__*/jsx(Fragment, {
4675
+ children: item
4676
+ }, index);
4677
+ }), /*#__PURE__*/jsx(FloatButton.BackTop, {
4678
+ target: backTopTarget
4679
+ }), loading && /*#__PURE__*/jsx(Loader, {
4680
+ spinning: true
4681
+ })]
4682
+ })]
4683
+ });
4684
+ };
4685
+
4686
+ var _fbaHooks$createCtx = fbaHooks.createCtx(),
4687
+ _fbaHooks$createCtx2 = _slicedToArray(_fbaHooks$createCtx, 2),
4688
+ usePageWrapperCtx = _fbaHooks$createCtx2[0],
4689
+ PageWrapperCtxProvider = _fbaHooks$createCtx2[1];
4690
+
4691
+ var _excluded = ["respData"],
4692
+ _excluded2 = ["serviceConfig", "isAsync", "errorRender"];
4693
+ var PageContent = function PageContent(props) {
4694
+ var _props$children;
4695
+ var respData = props.respData,
4696
+ otherProps = _objectWithoutProperties(props, _excluded);
4697
+ var children = typeof props.children === 'function' ? (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.call(props, respData) : props.children;
4698
+ if (isFragment(children)) {
4699
+ var childrenList = Children.toArray(children.props.children);
4700
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
4701
+ children: childrenList
4702
+ }));
4703
+ }
4704
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
4705
+ children: children
4765
4706
  }));
4766
4707
  };
4767
4708
 
4768
- var Bootstrap = function Bootstrap(options) {
4769
- var _useState = useState(false),
4709
+ /**
4710
+ * 为Page内置接口处理流程组件,如果无全局初始化接口请求场景,请使用Page组件
4711
+ * ```
4712
+ * 包括
4713
+ * 1. loading显示效果
4714
+ * 2. error显示效果
4715
+ * 3. 正常接口数据渲染
4716
+ * ```
4717
+ * @param props
4718
+ * @returns
4719
+ */
4720
+ var PageWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
4721
+ var serviceConfig = props.serviceConfig,
4722
+ isAsync = props.isAsync,
4723
+ errorRender = props.errorRender,
4724
+ otherProps = _objectWithoutProperties(props, _excluded2);
4725
+ var _useState = useState({
4726
+ status: 'loading'
4727
+ }),
4770
4728
  _useState2 = _slicedToArray(_useState, 2),
4771
- renderFlag = _useState2[0],
4772
- setRenderFlag = _useState2[1];
4773
- var _useState3 = useState(''),
4729
+ result = _useState2[0],
4730
+ setResult = _useState2[1];
4731
+ var _useState3 = useState(false),
4774
4732
  _useState4 = _slicedToArray(_useState3, 2),
4775
- errorMessage = _useState4[0],
4776
- setErrorMessage = _useState4[1];
4777
- useAsyncEffect(function () {
4733
+ againRefresh = _useState4[0],
4734
+ setAgainRefresh = _useState4[1];
4735
+ var onRequest = function onRequest() {
4778
4736
  return new Promise(function ($return, $error) {
4779
- var globalData, apiBase, hostUrl;
4737
+ var params, _result;
4780
4738
  var $Try_1_Post = function () {
4781
4739
  try {
4782
- return $return();
4740
+ return $return(Promise.resolve());
4783
4741
  } catch ($boundEx) {
4784
4742
  return $error($boundEx);
4785
4743
  }
4786
4744
  };
4787
4745
  var $Try_1_Catch = function (error) {
4788
4746
  try {
4789
- setErrorMessage((error === null || error === void 0 ? void 0 : error['message']) || '获取初始加载数据失败');
4747
+ setResult({
4748
+ status: 'error',
4749
+ respData: error
4750
+ });
4790
4751
  return $Try_1_Post();
4791
4752
  } catch ($boundEx) {
4792
4753
  return $error($boundEx);
4793
4754
  }
4794
4755
  };
4795
4756
  try {
4796
- if (options.layoutMode === 'iframe-main') {
4797
- window['__flat_iframe_parent_window'] = true;
4798
- }
4799
- if (options.getGlobalData) {
4800
- return Promise.resolve(options.getGlobalData()).then(function ($await_3) {
4801
- try {
4802
- globalData = $await_3;
4803
- if (globalData) {
4804
- window['GLOBAL'] = globalData;
4805
- }
4806
- return $If_2.call(this);
4807
- } catch ($boundEx) {
4808
- return $Try_1_Catch($boundEx);
4809
- }
4810
- }.bind(this), $Try_1_Catch);
4811
- }
4812
- function $If_2() {
4813
- apiBase = window['GLOBAL'].apiBase;
4814
- if (apiBase) {
4815
- window['GLOBAL'].apiBase = getSameProtocolUrl(apiBase);
4816
- }
4817
- hostUrl = window['GLOBAL'].hostUrl;
4818
- if (hostUrl) {
4819
- window['GLOBAL'].hostUrl = getSameProtocolUrl(hostUrl);
4757
+ params = typeof serviceConfig.params === 'function' ? serviceConfig.params() : serviceConfig.params;
4758
+ return Promise.resolve(serviceConfig.onRequest(params)).then(function ($await_2) {
4759
+ try {
4760
+ _result = $await_2;
4761
+ setResult({
4762
+ status: 'success',
4763
+ respData: _result
4764
+ });
4765
+ return $Try_1_Post();
4766
+ } catch ($boundEx) {
4767
+ return $Try_1_Catch($boundEx);
4820
4768
  }
4821
- setRenderFlag(true);
4822
- return $Try_1_Post();
4823
- }
4824
- return $If_2.call(this);
4769
+ }, $Try_1_Catch);
4825
4770
  } catch (error) {
4826
4771
  $Try_1_Catch(error);
4827
4772
  }
4828
4773
  });
4829
- }, []);
4830
- if (errorMessage) {
4831
- return /*#__PURE__*/jsx(Result, {
4832
- status: "error",
4833
- title: errorMessage
4774
+ };
4775
+ fbaHooks.useEffectCustomAsync(onRequest, []);
4776
+ var onReload = useMemoizedFn(function () {
4777
+ setResult({
4778
+ status: 'loading'
4834
4779
  });
4835
- }
4836
- if (!renderFlag) {
4837
- return /*#__PURE__*/jsx(Loader, {
4838
- spinning: true
4780
+ void onRequest();
4781
+ });
4782
+ var onRefresh = useMemoizedFn(function () {
4783
+ setAgainRefresh(true);
4784
+ onRequest().finally(function () {
4785
+ setAgainRefresh(false);
4786
+ });
4787
+ });
4788
+ useImperativeHandle(ref, function () {
4789
+ return {
4790
+ onRefresh: onRefresh,
4791
+ onReload: onReload
4792
+ };
4793
+ });
4794
+ if (result.status === 'error') {
4795
+ var _result$respData;
4796
+ if (errorRender) {
4797
+ return errorRender(result.respData);
4798
+ }
4799
+ return /*#__PURE__*/jsx(Page, {
4800
+ fullIndex: 0,
4801
+ style: {
4802
+ backgroundColor: '#fff'
4803
+ },
4804
+ children: /*#__PURE__*/jsx(Result, {
4805
+ status: "error",
4806
+ title: '数据获取异常',
4807
+ subTitle: ((_result$respData = result.respData) === null || _result$respData === void 0 ? void 0 : _result$respData.message) || '数据请求异常',
4808
+ extra: [/*#__PURE__*/jsx(Button, {
4809
+ type: "primary",
4810
+ onClick: onReload,
4811
+ children: "\u91CD\u65B0\u83B7\u53D6"
4812
+ }, "console")]
4813
+ })
4839
4814
  });
4840
4815
  }
4841
- return /*#__PURE__*/jsx(BootstrapContent, _objectSpread2({}, options));
4816
+ if (result.status === 'loading' && !isAsync) {
4817
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({
4818
+ loading: true
4819
+ }, otherProps), {}, {
4820
+ children: /*#__PURE__*/jsx(Fragment, {})
4821
+ }));
4822
+ }
4823
+ return /*#__PURE__*/jsxs(PageWrapperCtxProvider, {
4824
+ value: {
4825
+ onReload: onReload,
4826
+ onRefresh: onRefresh
4827
+ },
4828
+ children: [againRefresh ? /*#__PURE__*/jsx(Loader, {
4829
+ spinning: true,
4830
+ style: {
4831
+ backgroundColor: 'transparent'
4832
+ }
4833
+ }) : null, /*#__PURE__*/jsx(PageContent, _objectSpread2({
4834
+ loading: result.status === 'loading',
4835
+ respData: result.respData
4836
+ }, otherProps))]
4837
+ });
4838
+ });
4839
+ var usePageWrapper = function usePageWrapper() {
4840
+ var ctx = usePageWrapperCtx();
4841
+ return ctx;
4842
4842
  };
4843
4843
 
4844
4844
  /**
@@ -4862,5 +4862,5 @@ var onUpdateTheme = function onUpdateTheme(theme) {
4862
4862
  });
4863
4863
  };
4864
4864
 
4865
- export { Bread, HistoryBackButton, LayoutPage, Page, PageWrapper, bootstrap, getIframeTabUid, menuPubSub, message, modal, notification, onUpdateTheme, useHistoryBack, useIframe, useIframeTabActive, usePageWrapper, useRefreshRegisterIframeTab, useRegisterRefreshCurrentIframeTab };
4865
+ export { Bootstrap, Bread, HistoryBackButton, LayoutPage, Page, PageWrapper, bootstrap, getIframeTabUid, menuPubSub, message, modal, notification, onUpdateTheme, useHistoryBack, useIframe, useIframeTabActive, usePageWrapper, useRefreshRegisterIframeTab, useRegisterRefreshCurrentIframeTab };
4866
4866
  //# sourceMappingURL=index.js.map