@flatbiz/pro-layout 5.2.2 → 5.2.3

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
@@ -568,6 +568,8 @@ export type BootstrapOptions = {
568
568
  };
569
569
  /** 浏览器title */
570
570
  browserTitle?: string;
571
+ /** 获取全局数据,默认值使用window.GLOBAL */
572
+ getGlobalData?: () => TGlobalData;
571
573
  };
572
574
  export type LayoutCtxProps = {
573
575
  menus: TMenuItem[];
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { App as App$1, Breadcrumb, FloatButton, Result, Button, Dropdown, Space,
6
6
  import { classNames } from '@dimjs/utils/class-names/class-names';
7
7
  import { 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, getOssRunningEnv, sessionStorageCache, ensureSlash as ensureSlash$1, removeSlash, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, isWindows, valueIsEqual, toLinkPathWithQuery, openNewWindow, treeToArray, cloneObject, getUuid, EventEmitter, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull, localStorageCache } from '@flatbiz/utils';
9
+ import { getRunningEnv, sessionStorageCache, 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
10
  import { fbaHooks } from '@flatbiz/antd/fba-hooks';
11
11
  import { parse } from '@dimjs/utils/json/parse';
12
12
  import { useMemoizedFn, useUpdateEffect, useDebounceFn } from 'ahooks';
@@ -294,7 +294,6 @@ var IframeEventEmitter = /*#__PURE__*/function () {
294
294
  }]);
295
295
  }();
296
296
 
297
- var globalData = getGlobalData();
298
297
  var iframeOpenNewTabItemOperateLinkKey = 'iframe-open-new-tab-item-operate-link';
299
298
 
300
299
  /**
@@ -338,7 +337,7 @@ var getIframeOpenNewTabItemOperateLinkList = function getIframeOpenNewTabItemOpe
338
337
  return isArray(operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList) ? operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList : [];
339
338
  };
340
339
  var getDefaultHeaderThemeConfig = function getDefaultHeaderThemeConfig() {
341
- var env = getOssRunningEnv();
340
+ var env = getRunningEnv();
342
341
  var headerThemeConfig = {
343
342
  inte: {
344
343
  bgColor: '#38B990'
@@ -1922,7 +1921,10 @@ var AppNoLayout = function AppNoLayout(props) {
1922
1921
  });
1923
1922
  };
1924
1923
 
1925
- var appName = globalData.appName || 'flatbiz-layout';
1924
+ var getAppName = function getAppName() {
1925
+ var defaultGlobalData = getGlobalData();
1926
+ return defaultGlobalData.appName || 'flatbiz-layout';
1927
+ };
1926
1928
  function removeNodesAtDepth(tree, depth, maxDepth) {
1927
1929
  for (var i = tree.length - 1; i >= 0; i--) {
1928
1930
  var node = tree[i];
@@ -1941,8 +1943,12 @@ function removeNodesAtDepth(tree, depth, maxDepth) {
1941
1943
  * @param isIframeType
1942
1944
  * @returns
1943
1945
  */
1944
- var getMenus = function getMenus(isIframeType, siderBarMaxMenuLevel, disableTopbarMenu) {
1945
- var menus = globalData.menus || [];
1946
+ var getMenus = function getMenus(isIframeType, siderBarMaxMenuLevel, disableTopbarMenu, customGlobalData) {
1947
+ var defaultGlobalData = getGlobalData();
1948
+ var menus = customGlobalData ? customGlobalData.menus : defaultGlobalData.menus || [];
1949
+ if (customGlobalData) {
1950
+ window['GLOBAL'] = customGlobalData;
1951
+ }
1946
1952
  treeToArray(menus, 'children').forEach(function (item) {
1947
1953
  var _item$children;
1948
1954
  if (isPlainObject(item.link)) {
@@ -1950,7 +1956,7 @@ var getMenus = function getMenus(isIframeType, siderBarMaxMenuLevel, disableTopb
1950
1956
  item.link = ((_item$link = item.link) === null || _item$link === void 0 ? void 0 : _item$link[getEnvName()]) || ((_item$link2 = item.link) === null || _item$link2 === void 0 ? void 0 : _item$link2['prod']);
1951
1957
  }
1952
1958
  var path = "/".concat(removeSlash(item.path, 'before-after'));
1953
- var routeBaseName = removeSlash(globalData.routeBaseName, 'before-after');
1959
+ var routeBaseName = removeSlash(defaultGlobalData.routeBaseName, 'before-after');
1954
1960
  /**
1955
1961
  * path 处理
1956
1962
  */
@@ -2081,6 +2087,7 @@ var getTargetMenuParentChain = function getTargetMenuParentChain(menuId, siderBa
2081
2087
  return chainMenuIdList;
2082
2088
  };
2083
2089
  var saveIframeTabToCache = function saveIframeTabToCache(menuList) {
2090
+ var appName = getAppName();
2084
2091
  var newList = isArray(menuList) ? menuList : [];
2085
2092
  window[appName] = newList;
2086
2093
  sessionStorageCache.set(appName, {
@@ -2088,6 +2095,7 @@ var saveIframeTabToCache = function saveIframeTabToCache(menuList) {
2088
2095
  });
2089
2096
  };
2090
2097
  var getIframeTabCacheList = function getIframeTabCacheList() {
2098
+ var appName = getAppName();
2091
2099
  try {
2092
2100
  if (window[appName]) return _toConsumableArray(window[appName]);
2093
2101
  var _ref = sessionStorageCache.get(appName) || {},
@@ -2100,10 +2108,12 @@ var getIframeTabCacheList = function getIframeTabCacheList() {
2100
2108
  }
2101
2109
  };
2102
2110
  var saveCacheIframeActiveItem = function saveCacheIframeActiveItem(item) {
2111
+ var appName = getAppName();
2103
2112
  window["".concat(appName, "-iframeActiveItem")] = item;
2104
2113
  sessionStorageCache.set("".concat(appName, "-iframeActiveItem"), _objectSpread2({}, item));
2105
2114
  };
2106
2115
  var getCacheIframeActiveItem = function getCacheIframeActiveItem() {
2116
+ var appName = getAppName();
2107
2117
  if (getIframeTabCacheList().length === 0) return undefined;
2108
2118
  try {
2109
2119
  if (window["".concat(appName, "-iframeActiveItem")]) return window["".concat(appName, "-iframeActiveItem")];
@@ -2167,6 +2177,7 @@ var addIframeTabListByMenuItem = function addIframeTabListByMenuItem(iframeTabLi
2167
2177
  };
2168
2178
  };
2169
2179
  var clearStorage = function clearStorage() {
2180
+ var appName = getAppName();
2170
2181
  sessionStorageCache.remove(appName);
2171
2182
  // sessionStorageCache.remove(`${appName}-iframeActiveItem`);
2172
2183
  };
@@ -4491,7 +4502,7 @@ var layoutPubSub = {
4491
4502
  };
4492
4503
 
4493
4504
  var Bootstrap = function Bootstrap(options) {
4494
- var _options$headerThemeC, _options$headerThemeC2, _options$headerThemeC3, _options$sidebarTheme, _options$sidebarTheme2, _options$sidebarTheme3;
4505
+ var _options$headerThemeC, _options$headerThemeC2, _options$headerThemeC3, _options$sidebarTheme, _options$sidebarTheme2, _options$sidebarTheme3, _options$getGlobalDat;
4495
4506
  var _useState = useState(options.initDark),
4496
4507
  _useState2 = _slicedToArray(_useState, 2),
4497
4508
  isDark = _useState2[0],
@@ -4537,6 +4548,7 @@ var Bootstrap = function Bootstrap(options) {
4537
4548
  var sidebarThemeConfigNew = extend({}, sidebarThemeConfig, customSidebarThemeConfig);
4538
4549
  var iframeTabClickRefresh = isUndefinedOrNull(options.iframeTabClickRefresh) ? true : options.iframeTabClickRefresh;
4539
4550
  var _useMemo = useMemo(function () {
4551
+ var globalData = getGlobalData();
4540
4552
  var routeList = function () {
4541
4553
  if (!globalData.moduleName) {
4542
4554
  console.error('请在window.GLOBAL中添加属性moduleName(模块名称,例如:moduleName="system/admin")');
@@ -4618,7 +4630,7 @@ var Bootstrap = function Bootstrap(options) {
4618
4630
  }, [options.routeList]),
4619
4631
  routeList = _useMemo.routeList,
4620
4632
  breadList = _useMemo.breadList;
4621
- var _getMenus = getMenus(isIframeMain || isIframeTabItem, options.siderBarMaxMenuLevel, options.disableTopbarMenu),
4633
+ var _getMenus = getMenus(isIframeMain || isIframeTabItem, options.siderBarMaxMenuLevel, options.disableTopbarMenu, (_options$getGlobalDat = options.getGlobalData) === null || _options$getGlobalDat === void 0 ? void 0 : _options$getGlobalDat.call(options)),
4622
4634
  menus = _getMenus.menus,
4623
4635
  completeMenus = _getMenus.completeMenus;
4624
4636
  var appProviderValue = _objectSpread2(_objectSpread2({}, options), {}, {
@@ -4644,6 +4656,7 @@ var Bootstrap = function Bootstrap(options) {
4644
4656
  var configProviderProps = useMemo(function () {
4645
4657
  var _options$configProvid, _options$configProvid2, _options$configProvid3;
4646
4658
  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;
4659
+ var globalData = getGlobalData();
4647
4660
  var algorithmArray = toArray(algorithm);
4648
4661
  algorithmArray = [].concat(_toConsumableArray(algorithmArray), [isDark ? theme.darkAlgorithm : null, options.compact ? theme.compactAlgorithm : null]).filter(Boolean);
4649
4662
  var configTheme = (_options$configProvid2 = options.configProviderProps) === null || _options$configProvid2 === void 0 ? void 0 : _options$configProvid2.theme;