@flatbiz/pro-layout 4.4.21 → 5.0.1

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 ADDED
@@ -0,0 +1,4127 @@
1
+ /* eslint-disable */
2
+ import './index.css';
3
+ /*! @flatjs/forge MIT @flatbiz/pro-layout */
4
+
5
+ import { App as App$1, Breadcrumb, FloatButton, Result, Button, message as message$1, Dropdown, Space, Menu, Layout, Tabs, Typography, theme } from 'antd';
6
+ import { classNames } from '@dimjs/utils/class-names/class-names';
7
+ import { createContext, useContext, useMemo, Fragment, Children, cloneElement, forwardRef, useState, useImperativeHandle, isValidElement, Suspense, useEffect, useRef, memo, Component } from 'react';
8
+ import { useParams, useLocation, useSearchParams, matchPath, Link, useNavigate, Routes, Route, Navigate, BrowserRouter } from 'react-router-dom';
9
+ import { ensureSlash as ensureSlash$1, removeSlash, getGlobalData, toLinkPath, isHttpUri, toArray, urlJoinMulti, urlJoin, isWindowsEnv, valueIsEqual, toLinkPathWithQuery, sessionStorageCache, treeToArray, cloneObject, getUuid, treeFilter, arrayFindByLoosely, arrayFindIndexByLoosely, isUndefinedOrNull } from '@flatbiz/utils';
10
+ import { pick } from '@dimjs/utils/pick/pick';
11
+ import { paramStrToJson } from '@dimjs/utils/uri/param-str-to-json';
12
+ import { jsx, jsxs } from 'react/jsx-runtime';
13
+ import { isPromise } from '@dimjs/lang/is-promise';
14
+ import { hooks } from '@wove/react/hooks';
15
+ import { ButtonWrapper, fbaHooks, dialogLoading, ConfigProviderWrapper, SvgHttpView, InputWrapper, IconWrapper, FbaApp } from '@flatbiz/antd';
16
+ import { modifyQueryString } from '@dimjs/utils/uri/modify-query-string';
17
+ import { uriParse } from '@dimjs/utils/uri/uri-parse';
18
+ import { isArray } from '@dimjs/lang/is-array';
19
+ import { isUndefined } from '@dimjs/lang/is-undefined';
20
+ import { isFragment } from 'react-is';
21
+ import { createCtx as createCtx$1 } from '@wove/react/create-ctx';
22
+ import { createRoot } from 'react-dom/client';
23
+ import { getQueryString } from '@dimjs/utils/uri/get-query-string';
24
+ import { extend } from '@dimjs/utils/extend/extend';
25
+ import { get } from '@dimjs/utils/get/get';
26
+ import { isString } from '@dimjs/lang/is-string';
27
+ import { exception } from '@wove/react/exception';
28
+ import { parse } from '@dimjs/utils/json/parse';
29
+ import { findAncestors } from '@dimjs/utils/tree/find-ancestors';
30
+ import { getEnvName } from '@dimjs/utils/env/get-env-name';
31
+ import { isPlainObject } from '@dimjs/lang/is-plain-object';
32
+ import _MenuFoldOutlined from '@ant-design/icons/es/icons/MenuFoldOutlined.js';
33
+ import _MenuUnfoldOutlined from '@ant-design/icons/es/icons/MenuUnfoldOutlined.js';
34
+ import _UserOutlined from '@ant-design/icons/es/icons/UserOutlined.js';
35
+ import _LogoutOutlined from '@ant-design/icons/es/icons/LogoutOutlined.js';
36
+ import _CaretDownOutlined from '@ant-design/icons/es/icons/CaretDownOutlined.js';
37
+ import _LoadingOutlined from '@ant-design/icons/es/icons/LoadingOutlined.js';
38
+ import _CloseOutlined from '@ant-design/icons/es/icons/CloseOutlined.js';
39
+ import _RedoOutlined from '@ant-design/icons/es/icons/RedoOutlined.js';
40
+ import { arrayRemove } from '@dimjs/utils/array/array-remove';
41
+ import { Model } from '@dimjs/model-react';
42
+
43
+ var message;
44
+ var notification;
45
+ var modal;
46
+ var useAntdApp = (function () {
47
+ var staticFunction = App$1.useApp();
48
+ message = staticFunction.message;
49
+ modal = staticFunction.modal;
50
+ notification = staticFunction.notification;
51
+ return null;
52
+ });
53
+
54
+ function _arrayLikeToArray(r, a) {
55
+ (null == a || a > r.length) && (a = r.length);
56
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
57
+ return n;
58
+ }
59
+ function _arrayWithHoles(r) {
60
+ if (Array.isArray(r)) return r;
61
+ }
62
+ function _arrayWithoutHoles(r) {
63
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
64
+ }
65
+ function _assertThisInitialized(e) {
66
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
67
+ return e;
68
+ }
69
+ function _callSuper(t, o, e) {
70
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
71
+ }
72
+ function _classCallCheck(a, n) {
73
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
74
+ }
75
+ function _defineProperties(e, r) {
76
+ for (var t = 0; t < r.length; t++) {
77
+ var o = r[t];
78
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
79
+ }
80
+ }
81
+ function _createClass(e, r, t) {
82
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
83
+ writable: !1
84
+ }), e;
85
+ }
86
+ function _defineProperty(e, r, t) {
87
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
88
+ value: t,
89
+ enumerable: !0,
90
+ configurable: !0,
91
+ writable: !0
92
+ }) : e[r] = t, e;
93
+ }
94
+ function _getPrototypeOf(t) {
95
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
96
+ return t.__proto__ || Object.getPrototypeOf(t);
97
+ }, _getPrototypeOf(t);
98
+ }
99
+ function _inherits(t, e) {
100
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
101
+ t.prototype = Object.create(e && e.prototype, {
102
+ constructor: {
103
+ value: t,
104
+ writable: !0,
105
+ configurable: !0
106
+ }
107
+ }), Object.defineProperty(t, "prototype", {
108
+ writable: !1
109
+ }), e && _setPrototypeOf(t, e);
110
+ }
111
+ function _isNativeReflectConstruct() {
112
+ try {
113
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
114
+ } catch (t) {}
115
+ return (_isNativeReflectConstruct = function () {
116
+ return !!t;
117
+ })();
118
+ }
119
+ function _iterableToArray(r) {
120
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
121
+ }
122
+ function _iterableToArrayLimit(r, l) {
123
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
124
+ if (null != t) {
125
+ var e,
126
+ n,
127
+ i,
128
+ u,
129
+ a = [],
130
+ f = !0,
131
+ o = !1;
132
+ try {
133
+ if (i = (t = t.call(r)).next, 0 === l) {
134
+ if (Object(t) !== t) return;
135
+ f = !1;
136
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
137
+ } catch (r) {
138
+ o = !0, n = r;
139
+ } finally {
140
+ try {
141
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
142
+ } finally {
143
+ if (o) throw n;
144
+ }
145
+ }
146
+ return a;
147
+ }
148
+ }
149
+ function _nonIterableRest() {
150
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
151
+ }
152
+ function _nonIterableSpread() {
153
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
154
+ }
155
+ function ownKeys(e, r) {
156
+ var t = Object.keys(e);
157
+ if (Object.getOwnPropertySymbols) {
158
+ var o = Object.getOwnPropertySymbols(e);
159
+ r && (o = o.filter(function (r) {
160
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
161
+ })), t.push.apply(t, o);
162
+ }
163
+ return t;
164
+ }
165
+ function _objectSpread2(e) {
166
+ for (var r = 1; r < arguments.length; r++) {
167
+ var t = null != arguments[r] ? arguments[r] : {};
168
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
169
+ _defineProperty(e, r, t[r]);
170
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
171
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
172
+ });
173
+ }
174
+ return e;
175
+ }
176
+ function _objectWithoutProperties(e, t) {
177
+ if (null == e) return {};
178
+ var o,
179
+ r,
180
+ i = _objectWithoutPropertiesLoose(e, t);
181
+ if (Object.getOwnPropertySymbols) {
182
+ var s = Object.getOwnPropertySymbols(e);
183
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
184
+ }
185
+ return i;
186
+ }
187
+ function _objectWithoutPropertiesLoose(r, e) {
188
+ if (null == r) return {};
189
+ var t = {};
190
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
191
+ if (e.includes(n)) continue;
192
+ t[n] = r[n];
193
+ }
194
+ return t;
195
+ }
196
+ function _possibleConstructorReturn(t, e) {
197
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
198
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
199
+ return _assertThisInitialized(t);
200
+ }
201
+ function _setPrototypeOf(t, e) {
202
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
203
+ return t.__proto__ = e, t;
204
+ }, _setPrototypeOf(t, e);
205
+ }
206
+ function _slicedToArray(r, e) {
207
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
208
+ }
209
+ function _toConsumableArray(r) {
210
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
211
+ }
212
+ function _toPrimitive(t, r) {
213
+ if ("object" != typeof t || !t) return t;
214
+ var e = t[Symbol.toPrimitive];
215
+ if (void 0 !== e) {
216
+ var i = e.call(t, r || "default");
217
+ if ("object" != typeof i) return i;
218
+ throw new TypeError("@@toPrimitive must return a primitive value.");
219
+ }
220
+ return ("string" === r ? String : Number)(t);
221
+ }
222
+ function _toPropertyKey(t) {
223
+ var i = _toPrimitive(t, "string");
224
+ return "symbol" == typeof i ? i : i + "";
225
+ }
226
+ function _unsupportedIterableToArray(r, a) {
227
+ if (r) {
228
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
229
+ var t = {}.toString.call(r).slice(8, -1);
230
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
231
+ }
232
+ }
233
+
234
+ /**
235
+ * A helper to create a Context and Provider with no upfront default value, and
236
+ * without having to check for undefined all the time.
237
+ */
238
+ function createCtx() {
239
+ var ctx = /*#__PURE__*/createContext(undefined);
240
+ function useCtx() {
241
+ var c = useContext(ctx);
242
+ if (c === undefined) throw new Error('useCtx must be inside a Provider with a value');
243
+ return c;
244
+ }
245
+ return [useCtx, ctx.Provider]; // 'as const' makes TypeScript infer a tuple
246
+ }
247
+
248
+ var _createCtx$1 = createCtx(),
249
+ _createCtx2$1 = _slicedToArray(_createCtx$1, 2),
250
+ useLayoutCtx = _createCtx2$1[0],
251
+ LayoutProvider = _createCtx2$1[1];
252
+ var _createCtx3 = createCtx(),
253
+ _createCtx4 = _slicedToArray(_createCtx3, 2),
254
+ bootstrapCtx = _createCtx4[0],
255
+ BootstrapCtx = _createCtx4[1];
256
+
257
+ var useBread = function useBread(breads, routeBaseName) {
258
+ var _matchPath;
259
+ var params = useParams();
260
+ var location = useLocation();
261
+ var _useSearchParams = useSearchParams(),
262
+ _useSearchParams2 = _slicedToArray(_useSearchParams, 1),
263
+ search = _useSearchParams2[0];
264
+ var newBreadList = breads.map(function (item) {
265
+ var breadData = typeof item.breadConfig === 'function' ? item.breadConfig({
266
+ params: params,
267
+ search: search
268
+ }) : item.breadConfig;
269
+ return _objectSpread2(_objectSpread2({}, breadData), {}, {
270
+ path: item.path
271
+ });
272
+ });
273
+ routeBaseName = ensureSlash$1(routeBaseName);
274
+ var locationBreadPath = ensureSlash$1(location.pathname.replace(routeBaseName, ''));
275
+ var routes = newBreadList.map(function (s) {
276
+ var pathFn = s.to || s.path;
277
+ var path = typeof pathFn === 'function' ? pathFn({
278
+ params: params,
279
+ search: search
280
+ }) : pathFn;
281
+ var query = s.query || [];
282
+ var allQueries = paramStrToJson(window.location.href);
283
+ var savedQueries = pick(allQueries, ['env'].concat(query));
284
+ var name = typeof s.name === 'function' ? s.name() : s.name;
285
+ return {
286
+ path: path,
287
+ name: name,
288
+ query: savedQueries
289
+ };
290
+ });
291
+
292
+ /**
293
+ * 当路由中存在动态参数时,解决参数匹配替换问题
294
+ * 1. 路由path链路
295
+ * a/b
296
+ * a/b/:id
297
+ * a/b/:id/detail
298
+ * =>
299
+ * 动态参数id = 123
300
+ * a/b
301
+ * a/b/123
302
+ * a/b/123/detail
303
+ */
304
+
305
+ // 从长到短排序
306
+ routes = routes.sort(function (a, b) {
307
+ var _b$path, _a$path;
308
+ return ((_b$path = b.path) === null || _b$path === void 0 ? void 0 : _b$path.length) - ((_a$path = a.path) === null || _a$path === void 0 ? void 0 : _a$path.length);
309
+ });
310
+ var lastPathTarget = routes.find(function (item) {
311
+ return matchPath(ensureSlash$1(item.path), locationBreadPath) || ensureSlash$1(item.path) === '//' || locationBreadPath.includes(ensureSlash$1(item.path));
312
+ });
313
+ if (lastPathTarget === undefined || lastPathTarget === null) return [];
314
+ var routesNew = routes.sort(function (a, b) {
315
+ var _a$path2, _b$path2;
316
+ return ((_a$path2 = a.path) === null || _a$path2 === void 0 ? void 0 : _a$path2.length) - ((_b$path2 = b.path) === null || _b$path2 === void 0 ? void 0 : _b$path2.length);
317
+ }).filter(function (item) {
318
+ return ensureSlash$1(lastPathTarget.path).includes(ensureSlash$1(item.path));
319
+ });
320
+ var marchParams = (_matchPath = matchPath(ensureSlash$1(lastPathTarget.path), locationBreadPath)) === null || _matchPath === void 0 ? void 0 : _matchPath.params;
321
+ var resultRoutes = routesNew.map(function (item) {
322
+ if (marchParams) {
323
+ var pathFmt = ensureSlash$1(item.path);
324
+ Object.keys(marchParams).forEach(function (key) {
325
+ if (pathFmt.includes("/:".concat(key, "/"))) {
326
+ pathFmt = pathFmt.replace("/:".concat(key, "/"), "/".concat(marchParams[key], "/"));
327
+ }
328
+ });
329
+ item.path = removeSlash(pathFmt, 'after');
330
+ }
331
+ return item;
332
+ });
333
+ return resultRoutes;
334
+ };
335
+
336
+ var Bread = function Bread(props) {
337
+ var _ctx$breadcrumbProps;
338
+ var ctx = bootstrapCtx();
339
+ var globalData = getGlobalData();
340
+ var breadRoutes = useBread(ctx.breads || {}, globalData.routeBaseName);
341
+ var breadcrumbItems = useMemo(function () {
342
+ var items = ctx.breadTitle ? [{
343
+ title: ctx.breadTitle
344
+ }] : [];
345
+ var routes = breadRoutes.sort(function (a, b) {
346
+ return a.path.length - b.path.length;
347
+ });
348
+ routes.forEach(function (item, index) {
349
+ var content = item && /*#__PURE__*/jsx(Fragment, {
350
+ children: item.name
351
+ });
352
+ if (item) {
353
+ if (routes.length - 1 !== index) {
354
+ items.push({
355
+ title: /*#__PURE__*/jsx(Link, {
356
+ to: toLinkPath(item.path, item.query),
357
+ children: content
358
+ })
359
+ });
360
+ } else {
361
+ items.push({
362
+ title: item.name
363
+ });
364
+ }
365
+ }
366
+ });
367
+ return items;
368
+ }, [breadRoutes, ctx.breadTitle]);
369
+ if (!breadRoutes.length) {
370
+ return null;
371
+ }
372
+ return /*#__PURE__*/jsxs("div", {
373
+ className: "bread-wrapper",
374
+ children: [/*#__PURE__*/jsx(Breadcrumb, _objectSpread2(_objectSpread2({}, ctx.breadcrumbProps), {}, {
375
+ className: classNames('bread', (_ctx$breadcrumbProps = ctx.breadcrumbProps) === null || _ctx$breadcrumbProps === void 0 ? void 0 : _ctx$breadcrumbProps.className),
376
+ items: breadcrumbItems
377
+ })), /*#__PURE__*/jsx("div", {
378
+ className: "bread-extend",
379
+ children: props.children
380
+ })]
381
+ });
382
+ };
383
+
384
+ // export const urlJoin = (first: string, second: string) => {
385
+ // return (first || '').replace(/\/$/, '') + '/' + (second || '').replace(/^\//, '');
386
+ // };
387
+ /**
388
+ * make sure the endfix slash as expect.
389
+ * @param str path fragment
390
+ * @param slashEndfix flag to indicates if we need keep last slash `/`
391
+ */
392
+ var ensureSlash = function ensureSlash(str) {
393
+ var slashEndfix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
394
+ str = str.replace(/\/$/, '');
395
+ return slashEndfix ? str + '/' : str;
396
+ };
397
+
398
+ /**
399
+ * 按照item.`path`长度越长的排列到最前面
400
+ * @param items
401
+ * @returns
402
+ */
403
+ var sortItemsByPath = function sortItemsByPath() {
404
+ var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
405
+ return items.slice(0).sort(function (a, b) {
406
+ return (b.path || '').length - (a.path || '').length;
407
+ });
408
+ };
409
+
410
+ /**
411
+ * path1 是否 包含 path2
412
+ * @param path1
413
+ * @param path2
414
+ * @returns
415
+ */
416
+ var pathIncludePath = function pathIncludePath(path1, path2) {
417
+ return ensureSlash(path1, true).startsWith(ensureSlash(path2, true));
418
+ };
419
+
420
+ /**
421
+ * 找到第一个叶子节点
422
+ * ```
423
+ * tileMenuList: 通过treeToArray(treeList)
424
+ * ```
425
+ * @param tileMenuList 菜单平铺数据
426
+ */
427
+ var findOneLeafNode = function findOneLeafNode(tileMenuList) {
428
+ return tileMenuList.filter(function (item) {
429
+ return !item.children || item.children.length === 0;
430
+ })[0];
431
+ };
432
+
433
+ /**
434
+ * 获取 rotue path(不包含routeBaseName)
435
+ * ```
436
+ * 例如:
437
+ * /pages/hyperse/demo-layout/main/system-set/menu1?env=me
438
+ * routeBaseName = pages/hyperse/demo-layout
439
+ * =>
440
+ * /main/system-set/menu1
441
+ * ```
442
+ * @param path
443
+ * @returns
444
+ */
445
+ var getPurePath = function getPurePath(path) {
446
+ var _getHostUrlAndRouteBa2 = getHostUrlAndRouteBaseName(path),
447
+ routeBaseName = _getHostUrlAndRouteBa2.routeBaseName;
448
+ return urlJoin('/', path).replace(urlJoin('/', routeBaseName), '').split('?')[0];
449
+ };
450
+
451
+ /**
452
+ * 获取 iframe rotue path(不包含routeBaseName、main)
453
+ * ```
454
+ * 例如:
455
+ * routeBaseName = pages/hyperse/demo-layout
456
+ * 1. /pages/hyperse/demo-layout/main/system-set/menu1?env=me
457
+ * 2. /main/system-set/menu1?env=me
458
+ * 3. /system-set/menu1
459
+ * =>
460
+ * /system-set/menu1
461
+ * ```
462
+ * @param path
463
+ * @returns
464
+ */
465
+ var getIframeTabPurePath = function getIframeTabPurePath(pathOrUrl) {
466
+ var pathname = isHttpUri(pathOrUrl) ? uriParse(pathOrUrl).pathname : pathOrUrl;
467
+ var _getHostUrlAndRouteBa3 = getHostUrlAndRouteBaseName(pathOrUrl),
468
+ routeBaseName = _getHostUrlAndRouteBa3.routeBaseName;
469
+ var purePath = urlJoin('/', pathname).replace(urlJoinMulti('/', routeBaseName, '/'), '').split('?')[0];
470
+ purePath = urlJoinMulti('/', purePath, '/');
471
+ if (purePath.startsWith('/main/')) {
472
+ purePath = purePath.replace('/main/', '/');
473
+ }
474
+ return removeSlash(purePath, 'after');
475
+ };
476
+ var getIframeMainPurePath = function getIframeMainPurePath(pathOrUrl) {
477
+ var tabPurePath = getIframeTabPurePath(pathOrUrl);
478
+ return urlJoin('/main', tabPurePath);
479
+ };
480
+
481
+ /**
482
+ * 解析指定iframe main url数据
483
+ * ```
484
+ * 例如
485
+ * http://dev.flatjs.com:6900/pages/hyperse/demo-iframe/main/module1/menu1?name=xxx
486
+ * =>
487
+ * path: /main/module1/menu1
488
+ * search: ?name=xxx
489
+ * ```
490
+ * @param url
491
+ */
492
+ var parseIframeMainUrlInfo = function parseIframeMainUrlInfo(url) {
493
+ var purePath = getIframeMainPurePath(url);
494
+ var uriParseValue = uriParse(url);
495
+ var search = uriParseValue.search;
496
+ return {
497
+ path: purePath,
498
+ search: search,
499
+ pathSearch: "".concat(purePath).concat(search || '')
500
+ };
501
+ };
502
+
503
+ /**
504
+ * 解析指定iframe 内部 url数据
505
+ * ```
506
+ * 例如
507
+ * http://dev.flatjs.com:6900/pages/hyperse/demo-iframe/main/module1/menu1?name=xxx
508
+ * =>
509
+ * path: /module1/menu1
510
+ * search: ?name=xxx
511
+ * ```
512
+ * @param url
513
+ */
514
+ var parseIframeTabItemUrlInfo = function parseIframeTabItemUrlInfo(url) {
515
+ var purePath = getIframeTabPurePath(url);
516
+ var uriParseValue = uriParse(url);
517
+ var search = uriParseValue.search;
518
+ return {
519
+ path: purePath,
520
+ search: search,
521
+ pathSearch: "".concat(purePath).concat(search || '')
522
+ };
523
+ };
524
+ var pathStartWithPath = function pathStartWithPath(path1, path2) {
525
+ return urlJoin(getIframeTabPurePath(path1), '/').startsWith(urlJoin(getIframeTabPurePath(path2), '/'));
526
+ };
527
+
528
+ /**
529
+ * 猜测 iframe tab link
530
+ * @param pathOrUrl
531
+ *
532
+ * ```
533
+ * 例如1
534
+ * routeBaseName = pages/hyperse/demo-layout
535
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1?name=xxx
536
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1?name=xxx
537
+ * /main/module1/menu1?name=xxx
538
+ * /module1/menu1?name=xxx
539
+ * =>
540
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1?name=xxx
541
+ * ```
542
+ *
543
+ * ```
544
+ * *****
545
+ * 例如2
546
+ * routeBaseName = pages/hyperse/demo-layout
547
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1
548
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1
549
+ * /main/module1/menu1
550
+ * /module1/menu1
551
+ * =>
552
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1
553
+ * ```
554
+ */
555
+ var guessIframeTabItemLink = function guessIframeTabItemLink(pathOrUrl) {
556
+ var _getHostUrlAndRouteBa4 = getHostUrlAndRouteBaseName(pathOrUrl),
557
+ routeBaseName = _getHostUrlAndRouteBa4.routeBaseName,
558
+ hostUrl = _getHostUrlAndRouteBa4.hostUrl;
559
+ var pathSearch = '';
560
+ if (isHttpUri(pathOrUrl)) {
561
+ pathSearch = parseIframeTabItemUrlInfo(pathOrUrl).pathSearch;
562
+ } else {
563
+ var purePath = getIframeTabPurePath(pathOrUrl);
564
+ var search = pathOrUrl.split('?')[1] || '';
565
+ pathSearch = search ? "".concat(purePath, "?").concat(search) : purePath;
566
+ }
567
+ return urlJoinMulti(hostUrl, routeBaseName, pathSearch);
568
+ };
569
+ var guessNormalItemLink = function guessNormalItemLink(pathOrUrl) {
570
+ var result = getHostUrlAndRouteBaseName(pathOrUrl);
571
+ var routeBaseName = result.routeBaseName;
572
+ pathOrUrl = removeSlash(pathOrUrl, 'before-after');
573
+ routeBaseName = removeSlash(routeBaseName, 'before-after');
574
+ if (!isHttpUri(pathOrUrl)) {
575
+ if (pathOrUrl.startsWith(routeBaseName)) {
576
+ return urlJoinMulti(result.hostUrl, pathOrUrl);
577
+ }
578
+ return urlJoinMulti(result.hostUrl, routeBaseName, pathOrUrl);
579
+ }
580
+ return pathOrUrl;
581
+ };
582
+
583
+ /**
584
+ * 猜测 iframe main link
585
+ * @param pathOrUrl
586
+ *
587
+ * ```
588
+ * 例如1
589
+ * routeBaseName = pages/hyperse/demo-layout
590
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1?name=xxx
591
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1?name=xxx
592
+ * /main/module1/menu1?name=xxx
593
+ * /module1/menu1?name=xxx
594
+ * =>
595
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1?name=xxx
596
+ * ```
597
+ *
598
+ * ```
599
+ * *****
600
+ * 例如2
601
+ * routeBaseName = pages/hyperse/demo-layout
602
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1
603
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/module1/menu1
604
+ * /main/module1/menu1
605
+ * /module1/menu1
606
+ * =>
607
+ * http://dev.flatjs.com/pages/hyperse/demo-iframe/main/module1/menu1
608
+ * ```
609
+ */
610
+ var guessIframeMainLink = function guessIframeMainLink(pathOrUrl) {
611
+ var _getHostUrlAndRouteBa5 = getHostUrlAndRouteBaseName(pathOrUrl),
612
+ routeBaseName = _getHostUrlAndRouteBa5.routeBaseName,
613
+ hostUrl = _getHostUrlAndRouteBa5.hostUrl;
614
+ var pathSearch = '';
615
+ if (isHttpUri(pathOrUrl)) {
616
+ pathSearch = parseIframeMainUrlInfo(pathOrUrl).pathSearch;
617
+ } else {
618
+ var purePath = getIframeMainPurePath(pathOrUrl);
619
+ var search = pathOrUrl.split('?')[1] || '';
620
+ pathSearch = search ? "".concat(purePath, "?").concat(search) : purePath;
621
+ }
622
+ return urlJoinMulti(hostUrl, routeBaseName, pathSearch);
623
+ };
624
+ var removeUrlProtocol = function removeUrlProtocol(url) {
625
+ var protocol = uriParse(url).protocol;
626
+ return url.replace(protocol, '');
627
+ };
628
+
629
+ /**
630
+ * 判断是否第三方链接
631
+ * @param link
632
+ * @returns
633
+ */
634
+ var judgeLinkIsThird = function judgeLinkIsThird(link) {
635
+ // 此处不能使用 getHostUrlAndRouteBaseName
636
+ var _getGlobalData = getGlobalData(),
637
+ routeBaseName = _getGlobalData.routeBaseName,
638
+ hostUrl = _getGlobalData.hostUrl,
639
+ siblingProjectConfigs = _getGlobalData.siblingProjectConfigs;
640
+ var ruleBaseUrl = urlJoinMulti(hostUrl, routeBaseName, '/');
641
+ var ruleBaseUrlNew = removeUrlProtocol(ruleBaseUrl);
642
+ var linkNew = removeUrlProtocol(link);
643
+ if (linkNew.startsWith(ruleBaseUrlNew)) {
644
+ return false;
645
+ }
646
+ if (toArray(siblingProjectConfigs).length) {
647
+ var target = siblingProjectConfigs === null || siblingProjectConfigs === void 0 ? void 0 : siblingProjectConfigs.find(function (item) {
648
+ var itemUrl = urlJoinMulti(item.hostUrl, item.routeBaseName, '/');
649
+ var itemUrlNew = removeUrlProtocol(itemUrl);
650
+ return linkNew.startsWith(itemUrlNew);
651
+ });
652
+ if (target) {
653
+ return false;
654
+ }
655
+ }
656
+ return true;
657
+ };
658
+
659
+ /**
660
+ * 是否为iframe架构的其他项目
661
+ * ```
662
+ * 与 window.GLOBAL.siblingProjectConfigs 比较
663
+ * ```
664
+ */
665
+ var judgeIframeSiblingProject = function judgeIframeSiblingProject(link) {
666
+ var _getGlobalData2 = getGlobalData(),
667
+ routeBaseName = _getGlobalData2.routeBaseName,
668
+ hostUrl = _getGlobalData2.hostUrl,
669
+ siblingProjectConfigs = _getGlobalData2.siblingProjectConfigs;
670
+ var linkPath = getIframeTabPurePath(link);
671
+ var ruleBaseUrl = urlJoinMulti(hostUrl, routeBaseName, '/');
672
+ var ruleBaseUrlNew = removeUrlProtocol(ruleBaseUrl);
673
+ var linkNew = removeUrlProtocol(link);
674
+ if (!linkNew.startsWith(ruleBaseUrlNew)) {
675
+ var target = getHostUrlAndRouteBaseName(link);
676
+ if (target) {
677
+ return {
678
+ routeBaseName: target.routeBaseName,
679
+ hostUrl: target.hostUrl,
680
+ moduleUrl: target ? urlJoinMulti(target.hostUrl, target.routeBaseName, linkPath) : undefined
681
+ };
682
+ }
683
+ return undefined;
684
+ }
685
+ var projectTarget;
686
+ var moduleTarget;
687
+ siblingProjectConfigs === null || siblingProjectConfigs === void 0 || siblingProjectConfigs.forEach(function (item) {
688
+ var _item$modules;
689
+ (_item$modules = item.modules) === null || _item$modules === void 0 || _item$modules.forEach(function (temp) {
690
+ if (pathStartWithPath(link, temp.path) && !moduleTarget) moduleTarget = temp;
691
+ });
692
+ if (moduleTarget) projectTarget = item;
693
+ });
694
+ if (moduleTarget) {
695
+ return {
696
+ routeBaseName: projectTarget.routeBaseName,
697
+ hostUrl: projectTarget.hostUrl,
698
+ moduleUrl: urlJoinMulti(projectTarget.hostUrl, projectTarget.routeBaseName, moduleTarget.path),
699
+ name: moduleTarget.name
700
+ };
701
+ }
702
+ return undefined;
703
+ };
704
+ var syncUrlSearch = function syncUrlSearch(targetUrl, url) {
705
+ var searchJson = paramStrToJson(targetUrl);
706
+ return modifyQueryString(url, searchJson);
707
+ };
708
+ var getHostUrlAndRouteBaseName = function getHostUrlAndRouteBaseName(pathOrUrl) {
709
+ var _getGlobalData3 = getGlobalData(),
710
+ siblingProjectConfigs = _getGlobalData3.siblingProjectConfigs,
711
+ routeBaseName = _getGlobalData3.routeBaseName,
712
+ hostUrl = _getGlobalData3.hostUrl;
713
+ if (!isHttpUri(pathOrUrl)) {
714
+ return {
715
+ routeBaseName: routeBaseName,
716
+ hostUrl: hostUrl
717
+ };
718
+ }
719
+ var link = pathOrUrl;
720
+ var linkNew = removeUrlProtocol(link);
721
+ if (toArray(siblingProjectConfigs).length) {
722
+ var target = siblingProjectConfigs === null || siblingProjectConfigs === void 0 ? void 0 : siblingProjectConfigs.find(function (item) {
723
+ var itemUrl = urlJoinMulti(item.hostUrl, item.routeBaseName, '/');
724
+ var itemUrlNew = removeUrlProtocol(itemUrl);
725
+ return linkNew.startsWith(itemUrlNew);
726
+ });
727
+ if (target) {
728
+ return {
729
+ routeBaseName: target.routeBaseName,
730
+ hostUrl: target.hostUrl
731
+ };
732
+ }
733
+ }
734
+ return {
735
+ routeBaseName: routeBaseName,
736
+ hostUrl: hostUrl
737
+ };
738
+ };
739
+
740
+ var _excluded$2 = ["level"];
741
+ /**
742
+ * 通过面包屑路径返回
743
+ * @param props
744
+ * @returns
745
+ * ```
746
+ * 1. breads 模块面包屑配置
747
+ * 2. level回退级别,如果传递数据未获取到路由配置,则取上一级
748
+ * 例如:-1,-2,-3
749
+ * 3. 为什么不能使用useNavigate(-1)
750
+ * 因为内部iframe和外部浏览器共用history历史记录,导致里外浏览器栈混乱
751
+ * 4. 什么场景使用
752
+ * 使用iframe tab的项目,在执行路由回退时使用
753
+ * 5. onClick返回 promise reject,则不会进行回退处理(V4.2.4)
754
+ * ```
755
+ */
756
+ var HistoryBackButton = function HistoryBackButton(props) {
757
+ var ctx = bootstrapCtx();
758
+ var level = props.level,
759
+ otherProps = _objectWithoutProperties(props, _excluded$2);
760
+ var _getHostUrlAndRouteBa = getHostUrlAndRouteBaseName(location.href),
761
+ routeBaseName = _getHostUrlAndRouteBa.routeBaseName;
762
+ var routerList = useBread(ctx.breads, routeBaseName);
763
+ var navigate = useNavigate();
764
+ var path = useMemo(function () {
765
+ var newLevel = level || -1;
766
+ if (routerList.length >= 2) {
767
+ var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
768
+ if (routerItem) {
769
+ return toLinkPath(routerItem.path, routerItem.query);
770
+ } else {
771
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
772
+ return '';
773
+ }
774
+ }
775
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
776
+ return '';
777
+ }, []);
778
+ var onBack = function onBack() {
779
+ if (path) {
780
+ navigate(toLinkPath(path));
781
+ } else {
782
+ console.warn("\u672A\u83B7\u53D6\u5230\u9762\u5305\u5C51\u6570\u636E\uFF0C\u65E0\u8FD4\u56DE\u94FE\u63A5");
783
+ }
784
+ };
785
+ var onClick = hooks.useCallbackRef(function (event) {
786
+ var _props$onClick;
787
+ var result = props === null || props === void 0 || (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, event);
788
+ if (result && isPromise(result)) {
789
+ return result.then(function () {
790
+ onBack();
791
+ });
792
+ }
793
+ onBack();
794
+ return;
795
+ });
796
+ return /*#__PURE__*/jsx(ButtonWrapper, _objectSpread2(_objectSpread2({}, otherProps), {}, {
797
+ onClick: onClick,
798
+ children: props.children || '返回'
799
+ }));
800
+ };
801
+ var useHistoryBack = function useHistoryBack(props) {
802
+ var ctx = bootstrapCtx();
803
+ var level = (props === null || props === void 0 ? void 0 : props.level) || -1;
804
+ var _getHostUrlAndRouteBa2 = getHostUrlAndRouteBaseName(location.href),
805
+ routeBaseName = _getHostUrlAndRouteBa2.routeBaseName;
806
+ var routerList = useBread(ctx.breads, routeBaseName);
807
+ var path = useMemo(function () {
808
+ var newLevel = level || -1;
809
+ if (routerList.length >= 2) {
810
+ var routerItem = routerList[routerList.length - 1 - Math.abs(newLevel)] || routerList[routerList.length - 2];
811
+ if (routerItem) {
812
+ return toLinkPath(routerItem.path, routerItem.query);
813
+ } else {
814
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
815
+ return '';
816
+ }
817
+ }
818
+ console.warn("\u672A\u83B7\u53D6\u5230\u3010level\uFF1A".concat(newLevel, "\u3011\u9762\u5305\u5C51\u6570\u636E"));
819
+ return '';
820
+ }, []);
821
+ return {
822
+ path: path
823
+ };
824
+ };
825
+
826
+ var Loader = function Loader(_ref) {
827
+ var _ref$spinning = _ref.spinning,
828
+ spinning = _ref$spinning === void 0 ? false : _ref$spinning,
829
+ _ref$fullScreen = _ref.fullScreen,
830
+ fullScreen = _ref$fullScreen === void 0 ? false : _ref$fullScreen,
831
+ _ref$style = _ref.style,
832
+ style = _ref$style === void 0 ? {} : _ref$style;
833
+ return /*#__PURE__*/jsx("div", {
834
+ style: style,
835
+ className: classNames('loader', {
836
+ hidden: !spinning,
837
+ fullScreen: fullScreen
838
+ }),
839
+ children: /*#__PURE__*/jsxs("div", {
840
+ className: "loader-wrapper",
841
+ children: [/*#__PURE__*/jsx("div", {
842
+ className: "loader-inner"
843
+ }), /*#__PURE__*/jsx("div", {
844
+ className: "loader-text",
845
+ children: "LOADING"
846
+ })]
847
+ })
848
+ });
849
+ };
850
+
851
+ /**
852
+ * 页面包装组件
853
+ * ```
854
+ * 1. 如果初始化面包屑被隐藏,在特殊页面级可以独立设置显示面包屑
855
+ * <Page bread={<Bread />}/>
856
+ * 2. 如果需要在 面包屑上添加按钮,初始化设置 bootstrap.hideDefaultBread = true,在需要按钮的页面上配置
857
+ * <Page bread={<Bread><Button>我是按钮</Button></Bread>}/>
858
+ * ```
859
+ * @param props
860
+ * @returns
861
+ */
862
+ var Page = function Page(props) {
863
+ var loading = props.loading;
864
+ var isWindows = isWindowsEnv();
865
+ var className = classNames('page', {
866
+ 'page-loading': loading,
867
+ 'page-flex': !isUndefined(props.fullIndex),
868
+ 'page-windows': isWindows
869
+ }, props.className);
870
+ var backTopTarget = hooks.useCallbackRef(function () {
871
+ if (!isUndefined(props.fullIndex)) {
872
+ return document.querySelector('.page-full');
873
+ }
874
+ return document.querySelector('.page');
875
+ });
876
+ return /*#__PURE__*/jsxs(Fragment, {
877
+ children: [props.bread, /*#__PURE__*/jsxs("div", {
878
+ style: props.style,
879
+ className: className,
880
+ id: props.elementId,
881
+ children: [Children.map(props.children, function (item, index) {
882
+ if (index === props.fullIndex) {
883
+ var _item$props;
884
+ return /*#__PURE__*/jsx(Fragment, {
885
+ children: /*#__PURE__*/cloneElement(item, {
886
+ className: classNames('page-full', item === null || item === void 0 || (_item$props = item['props']) === null || _item$props === void 0 ? void 0 : _item$props.className)
887
+ })
888
+ }, index);
889
+ }
890
+ return /*#__PURE__*/jsx(Fragment, {
891
+ children: item
892
+ }, index);
893
+ }), /*#__PURE__*/jsx(FloatButton.BackTop, {
894
+ target: backTopTarget
895
+ }), loading && /*#__PURE__*/jsx(Loader, {
896
+ spinning: true
897
+ })]
898
+ })]
899
+ });
900
+ };
901
+
902
+ var _createCtx = createCtx$1(),
903
+ _createCtx2 = _slicedToArray(_createCtx, 2),
904
+ usePageWrapperCtx = _createCtx2[0],
905
+ PageWrapperCtxProvider = _createCtx2[1];
906
+
907
+ var _excluded$1 = ["respData"],
908
+ _excluded2 = ["serviceConfig", "isAsync", "errorRender"];
909
+ var PageContent$1 = function PageContent(props) {
910
+ var _props$children;
911
+ var respData = props.respData,
912
+ otherProps = _objectWithoutProperties(props, _excluded$1);
913
+ var children = typeof props.children === 'function' ? (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.call(props, respData) : props.children;
914
+ if (isFragment(children)) {
915
+ var childrenList = Children.toArray(children.props.children);
916
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
917
+ children: childrenList
918
+ }));
919
+ }
920
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({}, otherProps), {}, {
921
+ children: children
922
+ }));
923
+ };
924
+
925
+ /**
926
+ * 为Page内置接口处理流程组件,如果无全局初始化接口请求场景,请使用Page组件
927
+ * ```
928
+ * 包括
929
+ * 1. loading显示效果
930
+ * 2. error显示效果
931
+ * 3. 正常接口数据渲染
932
+ * ```
933
+ * @param props
934
+ * @returns
935
+ */
936
+ var PageWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
937
+ var serviceConfig = props.serviceConfig,
938
+ isAsync = props.isAsync,
939
+ errorRender = props.errorRender,
940
+ otherProps = _objectWithoutProperties(props, _excluded2);
941
+ var _useState = useState({
942
+ status: 'loading'
943
+ }),
944
+ _useState2 = _slicedToArray(_useState, 2),
945
+ result = _useState2[0],
946
+ setResult = _useState2[1];
947
+ var onRequest = function onRequest() {
948
+ return new Promise(function ($return, $error) {
949
+ var params, _result;
950
+ var $Try_1_Post = function () {
951
+ try {
952
+ return $return(Promise.resolve());
953
+ } catch ($boundEx) {
954
+ return $error($boundEx);
955
+ }
956
+ };
957
+ var $Try_1_Catch = function (error) {
958
+ try {
959
+ setResult({
960
+ status: 'error',
961
+ respData: error
962
+ });
963
+ return $Try_1_Post();
964
+ } catch ($boundEx) {
965
+ return $error($boundEx);
966
+ }
967
+ };
968
+ try {
969
+ params = typeof serviceConfig.params === 'function' ? serviceConfig.params() : serviceConfig.params;
970
+ return Promise.resolve(serviceConfig.onRequest(params)).then(function ($await_2) {
971
+ try {
972
+ _result = $await_2;
973
+ setResult({
974
+ status: 'success',
975
+ respData: _result
976
+ });
977
+ return $Try_1_Post();
978
+ } catch ($boundEx) {
979
+ return $Try_1_Catch($boundEx);
980
+ }
981
+ }, $Try_1_Catch);
982
+ } catch (error) {
983
+ $Try_1_Catch(error);
984
+ }
985
+ });
986
+ };
987
+ fbaHooks.useEffectCustomAsync(onRequest, []);
988
+ var onReload = hooks.useCallbackRef(function () {
989
+ setResult({
990
+ status: 'loading'
991
+ });
992
+ void onRequest();
993
+ });
994
+ useImperativeHandle(ref, function () {
995
+ return {
996
+ onRefresh: function onRefresh(showLoading) {
997
+ var showLoadingNew = showLoading === undefined ? true : showLoading;
998
+ if (showLoadingNew) {
999
+ dialogLoading.open();
1000
+ }
1001
+ onRequest().finally(function () {
1002
+ if (showLoadingNew) {
1003
+ dialogLoading.close();
1004
+ }
1005
+ });
1006
+ }
1007
+ };
1008
+ });
1009
+ if (result.status === 'error') {
1010
+ var _result$respData;
1011
+ if (errorRender) {
1012
+ return errorRender(result.respData);
1013
+ }
1014
+ return /*#__PURE__*/jsx(Page, {
1015
+ fullIndex: 0,
1016
+ style: {
1017
+ backgroundColor: '#fff'
1018
+ },
1019
+ children: /*#__PURE__*/jsx(Result, {
1020
+ status: "error",
1021
+ title: '数据获取异常',
1022
+ subTitle: ((_result$respData = result.respData) === null || _result$respData === void 0 ? void 0 : _result$respData.message) || '数据请求异常',
1023
+ extra: [/*#__PURE__*/jsx(Button, {
1024
+ type: "primary",
1025
+ onClick: onReload,
1026
+ children: "\u91CD\u65B0\u83B7\u53D6"
1027
+ }, "console")]
1028
+ })
1029
+ });
1030
+ }
1031
+ if (result.status === 'loading' && !isAsync) {
1032
+ return /*#__PURE__*/jsx(Page, _objectSpread2(_objectSpread2({
1033
+ loading: true
1034
+ }, otherProps), {}, {
1035
+ children: /*#__PURE__*/jsx(Fragment, {})
1036
+ }));
1037
+ }
1038
+ return /*#__PURE__*/jsx(PageWrapperCtxProvider, {
1039
+ value: {
1040
+ onReload: onReload
1041
+ },
1042
+ children: /*#__PURE__*/jsx(PageContent$1, _objectSpread2({
1043
+ loading: result.status === 'loading',
1044
+ respData: result.respData
1045
+ }, otherProps))
1046
+ });
1047
+ });
1048
+ var usePageWrapper = function usePageWrapper() {
1049
+ var ctx = usePageWrapperCtx();
1050
+ return {
1051
+ onReload: function onReload() {
1052
+ ctx.onReload();
1053
+ }
1054
+ };
1055
+ };
1056
+
1057
+ var AntdAppWrapper = function AntdAppWrapper(props) {
1058
+ var theme = fbaHooks.useThemeToken();
1059
+ var appProviderValue = props.appProviderValue;
1060
+ var headerThemeConfig = appProviderValue.headerThemeConfig;
1061
+ var sidebarThemeConfig = appProviderValue.sidebarThemeConfig;
1062
+ var varStyleList = [{
1063
+ '--header-bgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.bgColor
1064
+ }, {
1065
+ '--header-textColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.textColor
1066
+ }, {
1067
+ '--header-menuColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuColor
1068
+ }, {
1069
+ '--header-menuActiveTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveTextColor
1070
+ }, {
1071
+ '--header-menuActiveBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuActiveBgColor
1072
+ }, {
1073
+ '--header-menuSelectedBgColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedBgColor
1074
+ }, {
1075
+ '--header-menuSelectedTextColor': headerThemeConfig === null || headerThemeConfig === void 0 ? void 0 : headerThemeConfig.menuSelectedTextColor
1076
+ }, {
1077
+ '--sidebar-bgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.bgColor
1078
+ }, {
1079
+ '--sidebar-menuActiveBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveBgColor
1080
+ }, {
1081
+ '--sidebar-menuActiveTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuActiveTextColor
1082
+ }, {
1083
+ '--sidebar-menuSelectedBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedBgColor
1084
+ }, {
1085
+ '--sidebar-menuSelectedTextColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSelectedTextColor
1086
+ }, {
1087
+ '--sidebar-menuSubMenuBgColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuSubMenuBgColor
1088
+ }, {
1089
+ '--sidebar-menuColor': sidebarThemeConfig === null || sidebarThemeConfig === void 0 ? void 0 : sidebarThemeConfig.menuColor
1090
+ }, {
1091
+ '--color-primary': theme.colorPrimary
1092
+ }];
1093
+ if (appProviderValue.dark) {
1094
+ varStyleList.push({
1095
+ '--block-bg-color': get(appProviderValue, 'bgColorConfig.dark.blockBgColor', '#000')
1096
+ });
1097
+ varStyleList.push({
1098
+ '--bg-color': get(appProviderValue, 'bgColorConfig.dark.bgColor', '#1b1a1a')
1099
+ });
1100
+ } else {
1101
+ varStyleList.push({
1102
+ '--block-bg-color': get(appProviderValue, 'bgColorConfig.light.blockBgColor', '#FFF')
1103
+ });
1104
+ varStyleList.push({
1105
+ '--bg-color': get(appProviderValue, 'bgColorConfig.light.bgColor', '#F2F2F2')
1106
+ });
1107
+ }
1108
+ var varStyleText = '';
1109
+ varStyleList.forEach(function (item) {
1110
+ var key = Object.keys(item)[0];
1111
+ if (item[key]) {
1112
+ varStyleText = varStyleText + "".concat(key, ":").concat(item[key], ";");
1113
+ }
1114
+ });
1115
+ document.body.style.cssText = "".concat(document.body.style.cssText, ";").concat(varStyleText);
1116
+ if (appProviderValue.dark) {
1117
+ document.body.classList.remove('light-theme');
1118
+ document.body.classList.add('dark-theme');
1119
+ } else {
1120
+ document.body.classList.remove('dark-theme');
1121
+ document.body.classList.add('light-theme');
1122
+ }
1123
+ if (appProviderValue.compact) {
1124
+ document.body.classList.add('compact-theme');
1125
+ } else {
1126
+ document.body.classList.remove('compact-theme');
1127
+ }
1128
+ return /*#__PURE__*/jsx(App$1, {
1129
+ className: appProviderValue.className,
1130
+ children: props.children
1131
+ });
1132
+ };
1133
+
1134
+ var NotFound = function NotFound() {
1135
+ return /*#__PURE__*/jsx(Result, {
1136
+ status: "404",
1137
+ title: "404",
1138
+ subTitle: "Sorry, \u60A8\u8BBF\u95EE\u7684\u5730\u5740\u4E0D\u5B58\u5728"
1139
+ });
1140
+ };
1141
+
1142
+ var AppRoutes = function AppRoutes(props) {
1143
+ var hideBreads = getQueryString('hideBreads');
1144
+ var routeList = props.routeList;
1145
+ var globbingRouteList = routeList.filter(function (item) {
1146
+ return valueIsEqual(item.path, ['*', '/*', '/*/']);
1147
+ });
1148
+ return /*#__PURE__*/jsx(Fragment, {
1149
+ children: /*#__PURE__*/jsxs(Routes, {
1150
+ children: [routeList.map(function (route, index) {
1151
+ var path = route.path,
1152
+ caseSensitive = route.caseSensitive,
1153
+ Element = route.element,
1154
+ redirect = route.redirect;
1155
+ var isGlobbing = valueIsEqual(path, ['*', '/*', '/*/']);
1156
+ if (isString(redirect)) {
1157
+ return /*#__PURE__*/jsx(Route, {
1158
+ path: path,
1159
+ element: /*#__PURE__*/jsx(Navigate, {
1160
+ to: toLinkPathWithQuery(redirect)
1161
+ })
1162
+ }, index);
1163
+ }
1164
+ if (Element) {
1165
+ var elementRender = null;
1166
+ if (/*#__PURE__*/isValidElement(Element)) {
1167
+ elementRender = Element;
1168
+ } else {
1169
+ var CElement = Element;
1170
+ elementRender = /*#__PURE__*/jsx(Suspense, {
1171
+ fallback: /*#__PURE__*/jsx(Loader, {
1172
+ spinning: true
1173
+ }),
1174
+ children: /*#__PURE__*/jsx(CElement, {})
1175
+ });
1176
+ }
1177
+ var tempPath = isGlobbing ? '*' : path.endsWith('/*') ? path : urlJoinMulti(path, '*');
1178
+ return /*#__PURE__*/jsx(Route, {
1179
+ path: tempPath,
1180
+ caseSensitive: caseSensitive,
1181
+ element: /*#__PURE__*/jsxs(Fragment, {
1182
+ children: [props.breads && props.hideDefaultBread !== true && !hideBreads ? /*#__PURE__*/jsx(Bread, {
1183
+ children: props.breadExtendRender
1184
+ }) : null, elementRender]
1185
+ })
1186
+ }, index);
1187
+ }
1188
+ return null;
1189
+ }), globbingRouteList.length === 0 ? /*#__PURE__*/jsx(Route, {
1190
+ path: "*",
1191
+ element: /*#__PURE__*/jsx(NotFound, {})
1192
+ }) : null]
1193
+ })
1194
+ });
1195
+ };
1196
+
1197
+ var currentIsIframe = function currentIsIframe() {
1198
+ return self != top;
1199
+ };
1200
+
1201
+ /**
1202
+ * Iframe Tab 模块使用
1203
+ * ```
1204
+ * 当Iframe Tab独立访问时,触发逻辑跳转正常访问页面(包含菜单)
1205
+ * ```
1206
+ */
1207
+ var IframeTabMode = function IframeTabMode(props) {
1208
+ if (!currentIsIframe()) {
1209
+ window.location.href = guessIframeMainLink(location.href);
1210
+ return null;
1211
+ }
1212
+ return props.children;
1213
+ };
1214
+
1215
+ var guessNoLayoutLink = function guessNoLayoutLink(url) {
1216
+ var _getHostUrlAndRouteBa = getHostUrlAndRouteBaseName(url),
1217
+ routeBaseName = _getHostUrlAndRouteBa.routeBaseName;
1218
+ var main = "".concat(routeBaseName, "/main/");
1219
+ if (url.indexOf(main) >= 0) {
1220
+ return url.replace(main, "".concat(routeBaseName, "/"));
1221
+ }
1222
+ return url;
1223
+ };
1224
+
1225
+ /**
1226
+ * No Layout 模块使用
1227
+ * ```
1228
+ * 当No Layout存在于ifram tab中时,触发逻辑跳转正常访问页面(包含菜单)
1229
+ * ```
1230
+ */
1231
+ var NoLayoutMode = function NoLayoutMode(props) {
1232
+ if (currentIsIframe()) {
1233
+ window.parent.location.href = guessNoLayoutLink(location.href);
1234
+ return null;
1235
+ }
1236
+ return props.children;
1237
+ };
1238
+
1239
+ var ContentLayoutCheck = function ContentLayoutCheck(props) {
1240
+ if (props.layoutMode === 'iframe-tab') {
1241
+ return /*#__PURE__*/jsx(IframeTabMode, {
1242
+ children: props.children
1243
+ });
1244
+ }
1245
+ if (props.layoutMode === 'no-layout') {
1246
+ return /*#__PURE__*/jsx(NoLayoutMode, {
1247
+ children: props.children
1248
+ });
1249
+ }
1250
+ return props.children;
1251
+ };
1252
+
1253
+ var IFrameEvents = /*#__PURE__*/function (IFrameEvents) {
1254
+ IFrameEvents["messageReceived"] = "messageReceived";
1255
+ return IFrameEvents;
1256
+ }({});
1257
+ var IFRAME_EVENT_FLAG = "HYPERSE-LAYOUT";
1258
+ var IframeEventEmitter = /*#__PURE__*/function () {
1259
+ function IframeEventEmitter() {
1260
+ _classCallCheck(this, IframeEventEmitter);
1261
+ _defineProperty(this, "events", {});
1262
+ }
1263
+ return _createClass(IframeEventEmitter, [{
1264
+ key: "on",
1265
+ value: function on(name, listener) {
1266
+ if (!this.events[name]) {
1267
+ this.events[name] = [];
1268
+ }
1269
+ this.events[name].push(listener);
1270
+ return this;
1271
+ }
1272
+ }, {
1273
+ key: "off",
1274
+ value: function off(name, listenerToRemove) {
1275
+ if (this.events[name]) {
1276
+ this.events[name] = this.events[name].filter(function (listener) {
1277
+ return listener !== listenerToRemove;
1278
+ });
1279
+ }
1280
+ return this;
1281
+ }
1282
+ }, {
1283
+ key: "emit",
1284
+ value: function emit(name, data) {
1285
+ var handlers = this.events[name] || [];
1286
+ if (handlers.length) {
1287
+ // console.log('IframeEventEmitter.emit(), name: ', name, 'handlers:', handlers);
1288
+ for (var index = 0; index < handlers.length; index++) {
1289
+ var handler = handlers[index];
1290
+ if (handler) {
1291
+ handler(data);
1292
+ }
1293
+ }
1294
+ }
1295
+ return this;
1296
+ }
1297
+ }]);
1298
+ }();
1299
+
1300
+ var getAllIframeElements = function getAllIframeElements() {
1301
+ var allFrames = document.querySelectorAll('[id^="iframe_"]');
1302
+ return allFrames;
1303
+ };
1304
+
1305
+ /**
1306
+ * 主父级窗体window对象使用的消息通讯
1307
+ */
1308
+ var iframeApi = {
1309
+ /**
1310
+ * 广播消息到所有的iframes子页面
1311
+ * @param data 消息内容
1312
+ */
1313
+ broadcastMessages: function broadcastMessages(data) {
1314
+ var allIframes = getAllIframeElements();
1315
+ for (var index = 0; index < allIframes.length; index++) {
1316
+ var _iframe$contentWindow;
1317
+ var iframe = allIframes[index];
1318
+ (_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 || _iframe$contentWindow.postMessage(JSON.stringify({
1319
+ type: IFRAME_EVENT_FLAG,
1320
+ data: data
1321
+ }), '*');
1322
+ }
1323
+ return iframeApi;
1324
+ },
1325
+ /**
1326
+ * 发送特定消息到父亲级window对象
1327
+ * @param data 消息内容
1328
+ */
1329
+ postMessage: function postMessage(data) {
1330
+ window.parent.postMessage(JSON.stringify({
1331
+ type: IFRAME_EVENT_FLAG,
1332
+ data: data
1333
+ }), '*');
1334
+ return iframeApi;
1335
+ },
1336
+ openNewTabItem: function openNewTabItem(data) {
1337
+ window.parent.postMessage(JSON.stringify({
1338
+ type: IFRAME_EVENT_FLAG,
1339
+ data: {
1340
+ type: 'redirect_to_frame_layout_menu_item',
1341
+ data: data
1342
+ }
1343
+ }), '*');
1344
+ return iframeApi;
1345
+ },
1346
+ openNewThirdTabItem: function openNewThirdTabItem(menuId, options) {
1347
+ window.parent.postMessage(JSON.stringify({
1348
+ type: IFRAME_EVENT_FLAG,
1349
+ data: {
1350
+ type: 'redirect_to_frame_layout_menu_third_item',
1351
+ data: {
1352
+ menuId: menuId,
1353
+ options: options
1354
+ }
1355
+ }
1356
+ }), '*');
1357
+ return iframeApi;
1358
+ },
1359
+ openBrowserWindow: function openBrowserWindow(url) {
1360
+ window.parent.postMessage(JSON.stringify({
1361
+ type: IFRAME_EVENT_FLAG,
1362
+ data: {
1363
+ type: 'open_browser_window',
1364
+ data: {
1365
+ url: url
1366
+ }
1367
+ }
1368
+ }), '*');
1369
+ return iframeApi;
1370
+ },
1371
+ locationHref: function locationHref(url) {
1372
+ window.parent.postMessage(JSON.stringify({
1373
+ type: IFRAME_EVENT_FLAG,
1374
+ data: {
1375
+ type: 'browser_location_href',
1376
+ data: {
1377
+ url: url
1378
+ }
1379
+ }
1380
+ }), '*');
1381
+ return iframeApi;
1382
+ },
1383
+ tabItemHistoryChange: function tabItemHistoryChange(link) {
1384
+ window.parent.postMessage(JSON.stringify({
1385
+ type: IFRAME_EVENT_FLAG,
1386
+ data: {
1387
+ type: 'history_change',
1388
+ data: {
1389
+ link: link
1390
+ }
1391
+ }
1392
+ }), '*');
1393
+ return iframeApi;
1394
+ },
1395
+ openNewTabItemByMenuId: function openNewTabItemByMenuId(menuId) {
1396
+ window.parent.postMessage(JSON.stringify({
1397
+ type: IFRAME_EVENT_FLAG,
1398
+ data: {
1399
+ type: 'open_iframe_tabitem_by_menu_id',
1400
+ data: menuId
1401
+ }
1402
+ }), '*');
1403
+ return iframeApi;
1404
+ },
1405
+ /** 关闭当前iframe-tab,跳转上一个链路tab */closedIframeTabToPrevlink: function closedIframeTabToPrevlink() {
1406
+ var iframeNodeKey = window['__iframe_node_key'];
1407
+ var closedIframeTabId = iframeNodeKey.replace('iframe_', '');
1408
+ window.parent.postMessage(JSON.stringify({
1409
+ type: IFRAME_EVENT_FLAG,
1410
+ data: {
1411
+ type: 'closed-iframe-tab-to-prevlink',
1412
+ data: {
1413
+ closedIframeTabId: closedIframeTabId
1414
+ }
1415
+ }
1416
+ }), '*');
1417
+ return iframeApi;
1418
+ }
1419
+ };
1420
+
1421
+ var iframeEvent = new IframeEventEmitter();
1422
+ window.addEventListener('message', function (e) {
1423
+ try {
1424
+ var _parse = parse(e.data),
1425
+ type = _parse.type,
1426
+ data = _parse.data;
1427
+ // 忽略框架外的消息通讯传递
1428
+ if (type === IFRAME_EVENT_FLAG) {
1429
+ iframeEvent.emit(IFrameEvents.messageReceived, data);
1430
+ }
1431
+ } catch (_error) {
1432
+ /** */
1433
+ }
1434
+ });
1435
+
1436
+ /**
1437
+ * 使用Iframe通讯的API
1438
+ * @param onReceivedMessageCallback 接收iframe通讯消息的回调函数引用
1439
+ * @demo https://xx.xx.com/docs/admin/main/exchange
1440
+ * @example
1441
+ * ```tsx
1442
+ * const iframeApi = useIframe<MessageData>((data) => {
1443
+ * updateMessage(data);
1444
+ * });
1445
+ *
1446
+ * const handleClick = hooks.useCallbackRef(() => {
1447
+ * iframeApi.broadcastMessages({
1448
+ * fromHeader: '1',
1449
+ * });
1450
+ * });
1451
+ *
1452
+ * ```
1453
+ */
1454
+ var useIframe = function useIframe() {
1455
+ var onReceivedMessageCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
1456
+ /** */
1457
+ };
1458
+ var callbackRef = hooks.useCallbackRef(onReceivedMessageCallback);
1459
+ useEffect(function () {
1460
+ iframeEvent.off(IFrameEvents.messageReceived, callbackRef).on(IFrameEvents.messageReceived, callbackRef);
1461
+ return function () {
1462
+ iframeEvent.off(IFrameEvents.messageReceived, callbackRef);
1463
+ };
1464
+ }, [callbackRef]);
1465
+ return iframeApi;
1466
+ };
1467
+
1468
+ var ErrorHandling = function ErrorHandling(props) {
1469
+ var iframeApi = useIframe();
1470
+ // 可以通过`isFabricException(error)`获取异常类型进行过滤 action里面throw new FabricException()
1471
+ var _exception$useExcepti = exception.useException(),
1472
+ _exception$useExcepti2 = _slicedToArray(_exception$useExcepti, 2),
1473
+ error = _exception$useExcepti2[0],
1474
+ clearError = _exception$useExcepti2[1];
1475
+ hooks.useUpdateEffect(function () {
1476
+ if (error && error.message) {
1477
+ var _props$verifySessionE;
1478
+ clearError();
1479
+ if ((_props$verifySessionE = props.verifySessionExpired) !== null && _props$verifySessionE !== void 0 && _props$verifySessionE.call(props, error)) {
1480
+ iframeApi.postMessage({
1481
+ type: 'session_expired'
1482
+ });
1483
+ return;
1484
+ }
1485
+ void message$1.error(error.message);
1486
+ }
1487
+ }, [error]);
1488
+ return null;
1489
+ };
1490
+
1491
+ /**
1492
+ * iframe tab 注册刷新方法
1493
+ * ```
1494
+ * 1. 定义refreshKey唯一值
1495
+ * 2. 与 useRefreshRegisterIframeTab 结合实现iframe tab之间的刷新动作
1496
+ * ```
1497
+ */
1498
+ var useRegisterRefreshCurrentIframeTab = function useRegisterRefreshCurrentIframeTab(refreshKey, onRefresh) {
1499
+ useIframe(function (data) {
1500
+ return new Promise(function ($return, $error) {
1501
+ var iframeNodeKey, refreshFunc;
1502
+ if (data.type === '__refresh-iframe-tab') {
1503
+ var $Try_1_Post = function () {
1504
+ try {
1505
+ return $If_4.call(this);
1506
+ } catch ($boundEx) {
1507
+ return $error($boundEx);
1508
+ }
1509
+ }.bind(this);
1510
+ var $Try_1_Catch = function (error) {
1511
+ try {
1512
+ console.error(error);
1513
+ return $Try_1_Post();
1514
+ } catch ($boundEx) {
1515
+ return $error($boundEx);
1516
+ }
1517
+ };
1518
+ try {
1519
+ iframeNodeKey = window['__iframe_node_key'];
1520
+ refreshFunc = window.parent["__refresh_".concat(iframeNodeKey)];
1521
+ if (data.data.refreshKey === refreshKey) {
1522
+ var $Try_2_Finally = function ($Try_2_Exit) {
1523
+ return function ($Try_2_Value) {
1524
+ try {
1525
+ refreshFunc.end();
1526
+ return $Try_2_Exit && $Try_2_Exit.call(this, $Try_2_Value);
1527
+ } catch ($boundEx) {
1528
+ return $Try_1_Catch($boundEx);
1529
+ }
1530
+ }.bind(this);
1531
+ }.bind(this);
1532
+ refreshFunc.start();
1533
+ var $Try_2_Post = function () {
1534
+ try {
1535
+ return $If_5.call(this);
1536
+ } catch ($boundEx) {
1537
+ return $Try_1_Catch($boundEx);
1538
+ }
1539
+ }.bind(this);
1540
+ var $Try_2_Catch = function ($exception_3) {
1541
+ try {
1542
+ throw $exception_3;
1543
+ } catch ($boundEx) {
1544
+ return $Try_2_Finally($Try_1_Catch)($boundEx);
1545
+ }
1546
+ };
1547
+ try {
1548
+ return Promise.resolve(onRefresh(data.data.params)).then(function ($await_6) {
1549
+ try {
1550
+ return $Try_2_Finally($Try_2_Post)();
1551
+ } catch ($boundEx) {
1552
+ return $Try_2_Catch($boundEx);
1553
+ }
1554
+ }, $Try_2_Catch);
1555
+ } catch ($exception_3) {
1556
+ $Try_2_Catch($exception_3);
1557
+ }
1558
+ }
1559
+ function $If_5() {
1560
+ return $Try_1_Post();
1561
+ }
1562
+ return $If_5.call(this);
1563
+ } catch (error) {
1564
+ $Try_1_Catch(error);
1565
+ }
1566
+ }
1567
+ function $If_4() {
1568
+ return $return();
1569
+ }
1570
+ return $If_4.call(this);
1571
+ });
1572
+ });
1573
+ };
1574
+
1575
+ /**
1576
+ * 根据 refreshKey,刷新指定iframe tab(在iframe tab中调用)
1577
+ * ```
1578
+ * 1. 使用 useRegisterRefreshCurrentIframeTab 定义的refreshKey
1579
+ * 2. 可通过 params 给刷新方法传参
1580
+ * ```
1581
+ * @returns
1582
+ */
1583
+ var useRefreshRegisterIframeTab = function useRefreshRegisterIframeTab() {
1584
+ var iframeApi = useIframe();
1585
+ return function (refreshKey, params) {
1586
+ iframeApi.postMessage({
1587
+ type: '__refresh-iframe-tab',
1588
+ data: {
1589
+ refreshKey: refreshKey,
1590
+ params: params
1591
+ }
1592
+ });
1593
+ };
1594
+ };
1595
+
1596
+ var IframeTabRoutesTiming = function IframeTabRoutesTiming() {
1597
+ var iframeApi = useIframe();
1598
+ var _useLocation = useLocation(),
1599
+ pathname = _useLocation.pathname,
1600
+ search = _useLocation.search;
1601
+ hooks.useUpdateEffect(function () {
1602
+ iframeApi.tabItemHistoryChange(location.href);
1603
+ }, [pathname, search]);
1604
+ return /*#__PURE__*/jsx(Fragment, {});
1605
+ };
1606
+
1607
+ var LayoutPage = function LayoutPage(props) {
1608
+ // const LeaveMenuCompt = layoutCtx.LeaveMenu || LeaveMenuDefault;
1609
+ var isWindows = isWindowsEnv();
1610
+ var className = classNames('layout-page-wrapper', {
1611
+ 'layout-page-noheader': props.hideHeader,
1612
+ 'layout-page-windows': isWindows
1613
+ }, props.className);
1614
+ return /*#__PURE__*/jsx(Fragment, {
1615
+ children: /*#__PURE__*/jsx("div", {
1616
+ className: className,
1617
+ id: props.elementId,
1618
+ children: /*#__PURE__*/jsx("div", {
1619
+ className: "layout-page",
1620
+ children: props.children
1621
+ })
1622
+ })
1623
+ });
1624
+ };
1625
+
1626
+ /**
1627
+ * 无结构渲染,用于 layoutMode 为 no-layout、iframe-tab 场景
1628
+ * @param props
1629
+ * @returns
1630
+ */
1631
+ var AppNoLayout = function AppNoLayout(props) {
1632
+ useAntdApp();
1633
+ var LayoutContent = props.LayoutComponent || LayoutPage;
1634
+ var ErrorHandlingRender = props.ErrorHandling || ErrorHandling;
1635
+ return /*#__PURE__*/jsx(ContentLayoutCheck, {
1636
+ layoutMode: props.iframeTabAloneView ? undefined : props.layoutMode,
1637
+ children: /*#__PURE__*/jsxs(Fragment, {
1638
+ children: [props.disableErrorHandling ? null : /*#__PURE__*/jsx(ErrorHandlingRender, {
1639
+ verifySessionExpired: props.verifySessionExpired
1640
+ }), props.layoutMode === 'iframe-tab' && /*#__PURE__*/jsx(IframeTabRoutesTiming, {}), /*#__PURE__*/jsx(LayoutContent, {
1641
+ hideHeader: props.hideHeader,
1642
+ className: props.layoutPageClassName,
1643
+ children: /*#__PURE__*/jsx(AppRoutes, _objectSpread2({}, props))
1644
+ })]
1645
+ })
1646
+ });
1647
+ };
1648
+
1649
+ var globalData = getGlobalData();
1650
+ var iframeOpenNewTabItemOperateLinkKey = 'iframe-open-new-tab-item-operate-link';
1651
+
1652
+ /**
1653
+ * 保存操作 OpenNewTabItem 链路
1654
+ */
1655
+ var saveIframeOpenNewTabItemOperateLink = function saveIframeOpenNewTabItemOperateLink(params) {
1656
+ var operateLinkData = sessionStorageCache.get(iframeOpenNewTabItemOperateLinkKey);
1657
+ var dataList = isArray(operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList) ? operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList : [];
1658
+ dataList.push(params);
1659
+ sessionStorageCache.set(iframeOpenNewTabItemOperateLinkKey, {
1660
+ dataList: dataList
1661
+ });
1662
+ };
1663
+ var getIframeOpenNewTabItemOperateLinkList = function getIframeOpenNewTabItemOperateLinkList() {
1664
+ var operateLinkData = sessionStorageCache.get(iframeOpenNewTabItemOperateLinkKey);
1665
+ return isArray(operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList) ? operateLinkData === null || operateLinkData === void 0 ? void 0 : operateLinkData.dataList : [];
1666
+ };
1667
+
1668
+ var appName = globalData.appName || 'hyperse-layout';
1669
+ function removeNodesAtDepth(tree, depth, maxDepth) {
1670
+ for (var i = tree.length - 1; i >= 0; i--) {
1671
+ var node = tree[i];
1672
+ if (node.children && depth <= maxDepth) {
1673
+ node.children = removeNodesAtDepth(node.children, depth + 1, maxDepth);
1674
+ }
1675
+ if (depth === maxDepth + 1) {
1676
+ tree.splice(i, 1);
1677
+ }
1678
+ }
1679
+ return tree;
1680
+ }
1681
+
1682
+ /**
1683
+ * 处理不合规 menus 数据
1684
+ * @param isIframeType
1685
+ * @returns
1686
+ */
1687
+ var getMenus = function getMenus(isIframeType, siderBarMaxMenuLevel, disableTopbarMenu) {
1688
+ var menus = globalData.menus || [];
1689
+ treeToArray(menus, 'children').forEach(function (item) {
1690
+ var _item$children;
1691
+ if (isPlainObject(item.link)) {
1692
+ var _item$link, _item$link2;
1693
+ 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']);
1694
+ }
1695
+ var path = "/".concat(removeSlash(item.path, 'before-after'));
1696
+ var routeBaseName = removeSlash(globalData.routeBaseName, 'before-after');
1697
+ /**
1698
+ * path 处理
1699
+ */
1700
+ if (isIframeType) {
1701
+ if (path.startsWith("/".concat(routeBaseName, "/main"))) {
1702
+ item.path = path.replace("/".concat(routeBaseName), '');
1703
+ } else if (!path.startsWith('/main')) {
1704
+ item.path = "/main".concat(path);
1705
+ }
1706
+ } else {
1707
+ if (path.startsWith("/".concat(routeBaseName))) {
1708
+ item.path = path.replace("/".concat(routeBaseName), '');
1709
+ }
1710
+ }
1711
+ if (!((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) || !!siderBarMaxMenuLevel) {
1712
+ if (isIframeType) {
1713
+ if (!item.link) {
1714
+ item.link = guessIframeTabItemLink(item.path);
1715
+ } else if (!isHttpUri(item.link)) {
1716
+ // 解决link不完整,以及link中包含/main
1717
+ item.link = guessIframeTabItemLink(item.link);
1718
+ }
1719
+ } else {
1720
+ if (item.link && !isHttpUri(item.link)) {
1721
+ // 解决link不完整
1722
+ item.link = guessNormalItemLink(item.link);
1723
+ }
1724
+ }
1725
+ }
1726
+ });
1727
+ if (siderBarMaxMenuLevel) {
1728
+ var maxDepth = !disableTopbarMenu ? siderBarMaxMenuLevel + 1 : siderBarMaxMenuLevel;
1729
+ var newTreeList = removeNodesAtDepth(cloneObject(menus), 1, maxDepth);
1730
+ console.log('menus', menus, newTreeList);
1731
+ return {
1732
+ menus: newTreeList,
1733
+ completeMenus: menus
1734
+ };
1735
+ }
1736
+ return {
1737
+ menus: menus,
1738
+ completeMenus: menus
1739
+ };
1740
+ };
1741
+
1742
+ /**
1743
+ * 连接是否相同
1744
+ * 1. 删除连接上的env后比较
1745
+ * @param link1
1746
+ * @param link
1747
+ */
1748
+ var linkEqual = function linkEqual(link1, link2) {
1749
+ var link1New = modifyQueryString(link1, {
1750
+ env: undefined
1751
+ });
1752
+ var link2New = modifyQueryString(link2, {
1753
+ env: undefined
1754
+ });
1755
+ return link1New === link2New;
1756
+ };
1757
+ var findFirstLeafNode = function findFirstLeafNode(target) {
1758
+ var _findFirstNodeTarget2 = function _findFirstNodeTarget(itemList) {
1759
+ var _itemList$;
1760
+ if (isArray((_itemList$ = itemList[0]) === null || _itemList$ === void 0 ? void 0 : _itemList$.children) && itemList[0].children.length > 0) {
1761
+ return _findFirstNodeTarget2(itemList[0].children || []);
1762
+ }
1763
+ return itemList[0];
1764
+ };
1765
+ if (target.children && target.children.length > 0) {
1766
+ return _findFirstNodeTarget2(target.children);
1767
+ }
1768
+ return target;
1769
+ };
1770
+
1771
+ /**
1772
+ * 根据 path,定位侧边栏目标菜单
1773
+ * @param tileMenus
1774
+ * @param path
1775
+ * @returns
1776
+ */
1777
+ var parseSiderTargetMenuByPath = function parseSiderTargetMenuByPath(tileMenus, link) {
1778
+ var path = getIframeTabPurePath(link);
1779
+ if (['', '/'].includes(path)) {
1780
+ return findFirstLeafNode(tileMenus[0]);
1781
+ }
1782
+ var sortedTileMenusByPath = sortItemsByPath(tileMenus);
1783
+ var target = sortedTileMenusByPath.find(function (item) {
1784
+ return pathIncludePath(path, getIframeTabPurePath(item.path));
1785
+ });
1786
+ if (target !== null && target !== void 0 && target.children && isArray(target === null || target === void 0 ? void 0 : target.children) && target.children.length > 0) {
1787
+ // 找到 第一个叶子节点
1788
+ var leafNode = findFirstLeafNode(target);
1789
+ /**
1790
+ * 1. 可以匹配
1791
+ * location: system/idx
1792
+ * leafNode: system/idx/list
1793
+ * 2. 不可匹配
1794
+ * location: system/idx/xxx
1795
+ * leafNode: system/idx/list
1796
+ */
1797
+ if (!pathIncludePath(getIframeTabPurePath(leafNode.path), path)) return undefined;
1798
+ return leafNode;
1799
+ }
1800
+ return target;
1801
+ };
1802
+
1803
+ /**
1804
+ * 根据 path,定位一级目标菜单
1805
+ */
1806
+ var parseFirstMenuByPath = function parseFirstMenuByPath(menus, link) {
1807
+ var path = getIframeTabPurePath(link);
1808
+ var sortedMenus = sortItemsByPath(menus);
1809
+ var target = sortedMenus.find(function (item) {
1810
+ return pathIncludePath(path, getIframeTabPurePath(item.path));
1811
+ });
1812
+ return target;
1813
+ };
1814
+
1815
+ // 获取目标菜单父级链路
1816
+ var getTargetMenuParentChain = function getTargetMenuParentChain(menuId, siderBarMenus) {
1817
+ var result = findAncestors(siderBarMenus, function (item) {
1818
+ return valueIsEqual(item.id, menuId);
1819
+ });
1820
+ var chainMenuIdList = [];
1821
+ result.forEach(function (item) {
1822
+ return chainMenuIdList.push("".concat(item.id));
1823
+ });
1824
+ return chainMenuIdList;
1825
+ };
1826
+ var saveIframeTabToCache = function saveIframeTabToCache(menuList) {
1827
+ var newList = isArray(menuList) ? menuList : [];
1828
+ window[appName] = newList;
1829
+ sessionStorageCache.set(appName, {
1830
+ menuList: newList
1831
+ });
1832
+ };
1833
+ var getIframeTabCacheList = function getIframeTabCacheList() {
1834
+ try {
1835
+ if (window[appName]) return _toConsumableArray(window[appName]);
1836
+ var _ref = sessionStorageCache.get(appName) || {},
1837
+ menuList = _ref.menuList;
1838
+ var newList = isArray(menuList) ? menuList : [];
1839
+ window[appName] = newList;
1840
+ return newList;
1841
+ } catch (_error) {
1842
+ return [];
1843
+ }
1844
+ };
1845
+ var saveCacheIframeActiveItem = function saveCacheIframeActiveItem(item) {
1846
+ window["".concat(appName, "-iframeActiveItem")] = item;
1847
+ sessionStorageCache.set("".concat(appName, "-iframeActiveItem"), _objectSpread2({}, item));
1848
+ };
1849
+ var getCacheIframeActiveItem = function getCacheIframeActiveItem() {
1850
+ if (getIframeTabCacheList().length === 0) return undefined;
1851
+ try {
1852
+ if (window["".concat(appName, "-iframeActiveItem")]) return window["".concat(appName, "-iframeActiveItem")];
1853
+ var activeItem = sessionStorageCache.get("".concat(appName, "-iframeActiveItem"));
1854
+ var item = activeItem && activeItem.id ? activeItem : undefined;
1855
+ window["".concat(appName, "-iframeActiveItem")] = item;
1856
+ return item;
1857
+ } catch (_error) {
1858
+ return undefined;
1859
+ }
1860
+ };
1861
+
1862
+ /**
1863
+ * 更新 or 保存 iframeList
1864
+ * @param item
1865
+ * @param iframeTabList
1866
+ */
1867
+ var addOrUpdateIframeTabListByMenuItem = function addOrUpdateIframeTabListByMenuItem(item, iframeTabList) {
1868
+ var targetLink = item.link;
1869
+ /**
1870
+ * 1. iframeTabList中link 与 targetLink是否完全相同
1871
+ */
1872
+ var target = iframeTabList.find(function (item) {
1873
+ return linkEqual(item.link, targetLink);
1874
+ });
1875
+ if (target) {
1876
+ return {
1877
+ iframeTabListNew: iframeTabList,
1878
+ iframeTabActiveItem: target
1879
+ };
1880
+ }
1881
+ return addIframeTabListByMenuItem(iframeTabList, item);
1882
+ };
1883
+ var addIframeTabListByMenuItem = function addIframeTabListByMenuItem(iframeTabList, item) {
1884
+ var pathSearch;
1885
+ var siderbarMenuLinkIsThird = judgeLinkIsThird(item.link);
1886
+ if (siderbarMenuLinkIsThird) {
1887
+ pathSearch = item.path;
1888
+ } else {
1889
+ pathSearch = parseIframeMainUrlInfo(toLinkPath(item.link)).pathSearch;
1890
+ }
1891
+ var newItem = {
1892
+ id: getUuid(),
1893
+ link: toLinkPath(item.link),
1894
+ name: item.name,
1895
+ metaTitle: item.metaTitle,
1896
+ iframeKey: "".concat(Date.now()),
1897
+ menuId: item.id ? "".concat(item.id) : undefined,
1898
+ pathSearch: pathSearch
1899
+ };
1900
+ var newList = iframeTabList.concat(newItem);
1901
+ return {
1902
+ iframeTabListNew: newList,
1903
+ iframeTabActiveItem: newItem
1904
+ };
1905
+ };
1906
+ var clearStorage = function clearStorage() {
1907
+ sessionStorageCache.remove(appName);
1908
+ // sessionStorageCache.remove(`${appName}-iframeActiveItem`);
1909
+ };
1910
+
1911
+ /**
1912
+ * 判断目标 link 是否为 菜单叶子节点
1913
+ * @param targetLink
1914
+ * @param siderBarTileMenus
1915
+ * @returns
1916
+ */
1917
+ var judgeTargetLinkIsLeafNodeMenu = function judgeTargetLinkIsLeafNodeMenu(targetLink, siderBarTileMenus) {
1918
+ var sortedTileMenusByPath = sortItemsByPath(siderBarTileMenus);
1919
+ var targetPath = getIframeTabPurePath(targetLink);
1920
+ var target = sortedTileMenusByPath.find(function (item) {
1921
+ return pathIncludePath(targetPath, getIframeTabPurePath(item.path));
1922
+ });
1923
+ return target ? toArray(target === null || target === void 0 ? void 0 : target.children).length === 0 : false;
1924
+ };
1925
+
1926
+ /**
1927
+ * 初始化根据当前 location 定位 iframe tab
1928
+ * ```
1929
+ * ```
1930
+ * @param siderBarTileMenus 侧边栏平铺菜单列表
1931
+ * @param siderbarTargetMenu 侧边栏激活菜单
1932
+ * @returns
1933
+ */
1934
+ var initSyncIframeTabCacheByLocation = function initSyncIframeTabCacheByLocation(siderBarTileMenus, siderbarTargetMenu) {
1935
+ var iframeTabCacheList = getIframeTabCacheList();
1936
+ // iframe 激活 tab
1937
+ var iframeTabActiveItem = getCacheIframeActiveItem();
1938
+ if (siderbarTargetMenu) {
1939
+ var locationIsLeafNode = judgeTargetLinkIsLeafNodeMenu(location.href, siderBarTileMenus);
1940
+ // 是否外部第三方链接
1941
+ var siderbarMenuLinkIsThird = judgeLinkIsThird(siderbarTargetMenu.link);
1942
+ var siderbarMenuLinkIsExternal = judgeIframeSiblingProject(siderbarTargetMenu.link);
1943
+
1944
+ /**
1945
+ * 1. 如果 location.href 为叶子节点,可指定为 待渲染link(location.href与siderbarTargetMenu.link参数可能不同)
1946
+ * 2. 如果 location.href 不是叶子节点,可能存在链接不完整,则指定 siderbarTargetMenu.link 为 待渲染link
1947
+ */
1948
+ var waitRenderLink;
1949
+ var waitRenderLinkPathSearch;
1950
+ if (siderbarMenuLinkIsThird) {
1951
+ waitRenderLink = syncUrlSearch(location.href, siderbarTargetMenu.link);
1952
+ waitRenderLinkPathSearch = parseIframeMainUrlInfo(location.href).pathSearch;
1953
+ } else if (siderbarMenuLinkIsExternal) {
1954
+ // 取出当前
1955
+ var locationPathSearch = parseIframeTabItemUrlInfo(location.href).pathSearch;
1956
+ var siderbarTarget = parseIframeTabItemUrlInfo(siderbarTargetMenu.link).pathSearch;
1957
+ if (locationPathSearch) {
1958
+ waitRenderLink = toLinkPath(siderbarTargetMenu.link.replace(siderbarTarget, locationPathSearch));
1959
+ } else {
1960
+ waitRenderLink = toLinkPath(siderbarTargetMenu.link);
1961
+ }
1962
+ waitRenderLinkPathSearch = parseIframeMainUrlInfo(waitRenderLink).pathSearch;
1963
+ } else {
1964
+ waitRenderLink = guessIframeTabItemLink(toLinkPath(locationIsLeafNode ? location.href : siderbarTargetMenu.link));
1965
+ waitRenderLinkPathSearch = parseIframeMainUrlInfo(waitRenderLink).pathSearch;
1966
+ }
1967
+ if (iframeTabActiveItem) {
1968
+ var iframeTabActiveLink = iframeTabActiveItem.link;
1969
+ /**
1970
+ * 如果 waitRenderLink 与 iframeTabActiveLink 完全相同
1971
+ */
1972
+ if (linkEqual(waitRenderLink, iframeTabActiveLink)) {
1973
+ var result = {
1974
+ // name: tabName,
1975
+ menuId: siderbarTargetMenu.id,
1976
+ link: waitRenderLink,
1977
+ pathSearch: waitRenderLinkPathSearch
1978
+ };
1979
+ updateCaheIframeListByActiveId(iframeTabActiveItem.id, result);
1980
+ return _objectSpread2(_objectSpread2({}, iframeTabActiveItem), result);
1981
+ }
1982
+ var path1 = getIframeTabPurePath(location.href);
1983
+ var path2 = getIframeTabPurePath(iframeTabActiveLink);
1984
+ if (path1 === path2) {
1985
+ updateCaheIframeListByActiveId(iframeTabActiveItem.id, {
1986
+ link: waitRenderLink,
1987
+ pathSearch: waitRenderLinkPathSearch
1988
+ });
1989
+ return _objectSpread2(_objectSpread2({}, iframeTabActiveItem), {}, {
1990
+ link: waitRenderLink,
1991
+ pathSearch: waitRenderLinkPathSearch
1992
+ });
1993
+ }
1994
+ /**
1995
+ * location.href 与 iframeTabActive link 没有关系,则覆盖当前iframe tab
1996
+ */
1997
+ var link = siderbarMenuLinkIsExternal ? syncUrlSearch(location.href, siderbarTargetMenu.link) : waitRenderLink;
1998
+ var _newItem = {
1999
+ link: link,
2000
+ name: getIframeTabName(waitRenderLink, siderbarTargetMenu.name),
2001
+ metaTitle: siderbarTargetMenu.metaTitle,
2002
+ id: getUuid(),
2003
+ iframeKey: "".concat(Date.now()),
2004
+ menuId: "".concat(siderbarTargetMenu.id),
2005
+ pathSearch: waitRenderLinkPathSearch
2006
+ };
2007
+ // 覆盖 当前 iframe tab
2008
+ updateCaheIframeListByActiveId(iframeTabActiveItem.id, _newItem);
2009
+ return _newItem;
2010
+ } else {
2011
+ var _link = siderbarMenuLinkIsExternal ? siderbarTargetMenu.link : waitRenderLink;
2012
+ var _newItem2 = {
2013
+ link: _link,
2014
+ name: getIframeTabName(waitRenderLink, siderbarTargetMenu.name),
2015
+ metaTitle: siderbarTargetMenu.metaTitle,
2016
+ id: getUuid(),
2017
+ iframeKey: "".concat(Date.now()),
2018
+ menuId: "".concat(siderbarTargetMenu.id),
2019
+ pathSearch: waitRenderLinkPathSearch
2020
+ };
2021
+ saveIframeTabToCache(iframeTabCacheList.concat(_newItem2));
2022
+ return _newItem2;
2023
+ }
2024
+ }
2025
+ /**
2026
+ * 未定位到菜单
2027
+ * 1. 新增未知异常新窗口
2028
+ * 2. 判断切换显示未知异常已存在窗口
2029
+ */
2030
+ var locationLink = guessIframeTabItemLink(toLinkPath(location.href));
2031
+ var locationLinkPathSearch = parseIframeMainUrlInfo(locationLink).pathSearch;
2032
+ var siblingProjectTarget = judgeIframeSiblingProject(location.href);
2033
+ if (iframeTabCacheList.length > 0) {
2034
+ // 缓存 是否存在 相同link
2035
+ var _newItem3 = iframeTabCacheList.find(function (item) {
2036
+ return linkEqual(guessIframeTabItemLink(item.link), locationLink);
2037
+ });
2038
+ if (_newItem3) {
2039
+ return _newItem3;
2040
+ }
2041
+ var locationPath = getIframeTabPurePath(location.href);
2042
+ // 缓存 是否存在 相同 path
2043
+ _newItem3 = iframeTabCacheList.find(function (item) {
2044
+ var currentPath = getIframeTabPurePath(item.link);
2045
+ return linkEqual(currentPath, locationPath);
2046
+ });
2047
+ if (_newItem3) {
2048
+ var _link2 = siblingProjectTarget ? _newItem3.link : locationLink;
2049
+ updateCaheIframeListByActiveId(_newItem3.id, {
2050
+ link: _link2
2051
+ });
2052
+ return _objectSpread2(_objectSpread2({}, _newItem3), {}, {
2053
+ link: _link2,
2054
+ pathSearch: locationLinkPathSearch
2055
+ });
2056
+ }
2057
+ }
2058
+ var newItem = {
2059
+ id: getUuid(),
2060
+ iframeKey: "".concat(Date.now()),
2061
+ link: siblingProjectTarget ? siblingProjectTarget.moduleUrl : locationLink,
2062
+ name: (siblingProjectTarget === null || siblingProjectTarget === void 0 ? void 0 : siblingProjectTarget.name) || getIframeTabName(location.pathname, '未知页面'),
2063
+ menuId: undefined,
2064
+ metaTitle: undefined,
2065
+ pathSearch: locationLinkPathSearch
2066
+ };
2067
+ if (iframeTabActiveItem) {
2068
+ updateCaheIframeListByActiveId(iframeTabActiveItem.id, newItem);
2069
+ } else {
2070
+ saveIframeTabToCache(iframeTabCacheList.concat(newItem));
2071
+ }
2072
+ return newItem;
2073
+ };
2074
+
2075
+ /**
2076
+ * 判断当前地址 是否 与iframeTabList 中link相同
2077
+ * @param iframeTabList
2078
+ */
2079
+ var findIframeTabItemByEqualUrl = function findIframeTabItemByEqualUrl(url, iframeTabList) {
2080
+ var target = iframeTabList.find(function (item) {
2081
+ return linkEqual(guessIframeTabItemLink(url), guessIframeTabItemLink(item.link));
2082
+ });
2083
+ return target;
2084
+ };
2085
+
2086
+ /**
2087
+ * 刷新当前激活的 iframeTabItem
2088
+ * @param iframeTabActiveId
2089
+ * @param newLink
2090
+ * @param iframeTabList
2091
+ * @returns
2092
+ */
2093
+ var refreshIframeTabLink = function refreshIframeTabLink(iframeTabActiveId, dataItem, iframeTabList) {
2094
+ var findIndex = iframeTabList.findIndex(function (item) {
2095
+ return item.id === iframeTabActiveId;
2096
+ });
2097
+ if (findIndex >= 0) {
2098
+ iframeTabList[findIndex] = _objectSpread2(_objectSpread2(_objectSpread2({}, iframeTabList[findIndex]), dataItem), {
2099
+ iframeKey: "".concat(Date.now())
2100
+ });
2101
+ }
2102
+ return {
2103
+ iframeTabList: iframeTabList,
2104
+ target: iframeTabList[findIndex]
2105
+ };
2106
+ };
2107
+
2108
+ /**
2109
+ * 刷新当前激活的 iframeTabItem
2110
+ * @param iframeTabActiveId
2111
+ * @param newLink
2112
+ * @param iframeTabList
2113
+ * @returns
2114
+ */
2115
+ var refreshIframeTabIframeKey = function refreshIframeTabIframeKey(iframeTabActiveId) {
2116
+ var iframeTabList = getIframeTabCacheList();
2117
+ var iframeTabTarget = iframeTabList.find(function (item) {
2118
+ return item.id === iframeTabActiveId;
2119
+ });
2120
+ if (iframeTabTarget) {
2121
+ iframeTabTarget.iframeKey = "".concat(Date.now());
2122
+ }
2123
+ return iframeTabList;
2124
+ };
2125
+ var updateCaheIframeListByActiveId = function updateCaheIframeListByActiveId(activeId, option) {
2126
+ var iframeTabList = getIframeTabCacheList();
2127
+ var targetIndex = iframeTabList.findIndex(function (item) {
2128
+ return valueIsEqual(item.id, activeId);
2129
+ });
2130
+ if (targetIndex >= 0) {
2131
+ iframeTabList[targetIndex] = _objectSpread2(_objectSpread2({}, iframeTabList[targetIndex]), option);
2132
+ saveCacheIframeActiveItem(iframeTabList[targetIndex]);
2133
+ }
2134
+ saveIframeTabToCache(iframeTabList);
2135
+ };
2136
+
2137
+ /**
2138
+ * 外部针对出现 iframe tab标题为未知页面的配置
2139
+ * window['_iframeTabConfig'] = {
2140
+ * '/system-get/menu3/detail': {
2141
+ * name: '详情',
2142
+ * },
2143
+ * };
2144
+ * @param pathOrUrl
2145
+ * @returns
2146
+ */
2147
+ var getIframeTabClientConfig = function getIframeTabClientConfig(pathOrUrl) {
2148
+ var _parseIframeTabItemUr = parseIframeTabItemUrlInfo(pathOrUrl),
2149
+ path = _parseIframeTabItemUr.path;
2150
+ var config = window['_iframeTabConfig'] || {};
2151
+ var target = Object.keys(config).find(function (key) {
2152
+ return urlJoin('/', key) === path;
2153
+ });
2154
+ return target && isPlainObject(config[target]) ? config[target] : {};
2155
+ };
2156
+ var getIframeTabName = function getIframeTabName(pathOrUrl, defaultName) {
2157
+ return getIframeTabClientConfig(pathOrUrl).name || defaultName;
2158
+ };
2159
+
2160
+ var Shrink = function Shrink(props) {
2161
+ var layoutCtx = useLayoutCtx();
2162
+ var onCollapseClick = hooks.useCallbackRef(function () {
2163
+ // 设置手动控制侧边栏菜单收缩
2164
+ if (layoutCtx.collapsed) {
2165
+ var _layoutCtx$onShrinkCh;
2166
+ window['__manual_control_shrink'] = true;
2167
+ layoutCtx.onChangeCollapsed(false);
2168
+ (_layoutCtx$onShrinkCh = layoutCtx.onShrinkChange) === null || _layoutCtx$onShrinkCh === void 0 || _layoutCtx$onShrinkCh.call(layoutCtx, 'open');
2169
+ } else {
2170
+ window['__manual_control_shrink'] = false;
2171
+ setTimeout(function () {
2172
+ var _layoutCtx$onShrinkCh2;
2173
+ layoutCtx.onChangeCollapsed(true);
2174
+ (_layoutCtx$onShrinkCh2 = layoutCtx.onShrinkChange) === null || _layoutCtx$onShrinkCh2 === void 0 || _layoutCtx$onShrinkCh2.call(layoutCtx, 'close');
2175
+ }, 100);
2176
+ }
2177
+ });
2178
+ if (layoutCtx.siderBarMenus.length > 0 && !layoutCtx.hideSidebarMenu) {
2179
+ return /*#__PURE__*/jsx("div", {
2180
+ className: classNames('layout-shrink', props.className),
2181
+ onClick: onCollapseClick,
2182
+ children: layoutCtx.collapsed ? /*#__PURE__*/jsx(_MenuUnfoldOutlined, {}) : /*#__PURE__*/jsx(_MenuFoldOutlined, {})
2183
+ });
2184
+ }
2185
+ return /*#__PURE__*/jsx("div", {
2186
+ className: classNames('layout-shrink', props.className)
2187
+ });
2188
+ };
2189
+
2190
+ var HeaderAccount = function HeaderAccount() {
2191
+ var _layoutCtx$onCustomUs2, _global$user2;
2192
+ var global = hooks.useGlobal();
2193
+ var layoutCtx = useLayoutCtx();
2194
+ var onSignOutHandle = hooks.useCallbackRef(function () {
2195
+ var _layoutCtx$onSignOut;
2196
+ // 清除缓存
2197
+ clearStorage();
2198
+ (_layoutCtx$onSignOut = layoutCtx.onSignOut) === null || _layoutCtx$onSignOut === void 0 || _layoutCtx$onSignOut.call(layoutCtx, global.user, global.hostUrl);
2199
+ });
2200
+ var defaultMenuItems = [{
2201
+ label: '退出登录',
2202
+ key: '0',
2203
+ onClick: onSignOutHandle,
2204
+ icon: /*#__PURE__*/jsx(_LogoutOutlined, {})
2205
+ }];
2206
+ var getUserAvatar = function getUserAvatar() {
2207
+ var _layoutCtx$onCustomUs, _global$user;
2208
+ var customUserAvatar = (_layoutCtx$onCustomUs = layoutCtx.onCustomUserAvatar) === null || _layoutCtx$onCustomUs === void 0 ? void 0 : _layoutCtx$onCustomUs.call(layoutCtx, global);
2209
+ if (customUserAvatar) {
2210
+ return typeof customUserAvatar === 'string' ? /*#__PURE__*/jsx("img", {
2211
+ className: "user-avatar",
2212
+ src: customUserAvatar,
2213
+ alt: ""
2214
+ }) : customUserAvatar;
2215
+ }
2216
+ var avatar = (_global$user = global.user) === null || _global$user === void 0 ? void 0 : _global$user.avatar;
2217
+ return avatar ? /*#__PURE__*/jsx("img", {
2218
+ className: "user-avatar",
2219
+ src: avatar,
2220
+ alt: ""
2221
+ }) : /*#__PURE__*/jsx(Button, {
2222
+ size: "small",
2223
+ shape: "circle",
2224
+ icon: /*#__PURE__*/jsx(_UserOutlined, {})
2225
+ }, "user");
2226
+ };
2227
+ return /*#__PURE__*/jsx("div", {
2228
+ className: "header-account",
2229
+ children: /*#__PURE__*/jsx(Dropdown, {
2230
+ menu: {
2231
+ items: layoutCtx.accountOperateMenuItems ? layoutCtx.accountOperateMenuItems : defaultMenuItems
2232
+ },
2233
+ arrow: true,
2234
+ trigger: ['hover'],
2235
+ overlayClassName: "account-dropdown-overlay",
2236
+ getPopupContainer: function getPopupContainer() {
2237
+ return document.querySelector('.header-account');
2238
+ },
2239
+ children: /*#__PURE__*/jsx("div", {
2240
+ className: "header-account-wraper",
2241
+ children: /*#__PURE__*/jsxs(Space, {
2242
+ size: [8, 0],
2243
+ children: [getUserAvatar(), /*#__PURE__*/jsx("div", {
2244
+ style: {
2245
+ maxWidth: 68
2246
+ },
2247
+ children: ((_layoutCtx$onCustomUs2 = layoutCtx.onCustomUserName) === null || _layoutCtx$onCustomUs2 === void 0 ? void 0 : _layoutCtx$onCustomUs2.call(layoutCtx, global)) || ((_global$user2 = global.user) === null || _global$user2 === void 0 ? void 0 : _global$user2.userName) || '...'
2248
+ })]
2249
+ })
2250
+ })
2251
+ })
2252
+ });
2253
+ };
2254
+
2255
+ var HeaderBrand = function HeaderBrand() {
2256
+ var _hooks$useGlobal = hooks.useGlobal(),
2257
+ defaultPage = _hooks$useGlobal.defaultPage;
2258
+ var layoutCtx = useLayoutCtx();
2259
+ var toDefaultPage = hooks.useCallbackRef(function () {
2260
+ if (defaultPage) {
2261
+ window.location.href = defaultPage;
2262
+ }
2263
+ });
2264
+ var sidebarWidth = layoutCtx.sidebarWidth;
2265
+ var headerHeight = layoutCtx.headerHeight;
2266
+ return /*#__PURE__*/jsx("div", {
2267
+ className: "layout-brand",
2268
+ onClick: toDefaultPage,
2269
+ style: {
2270
+ width: sidebarWidth,
2271
+ height: headerHeight,
2272
+ lineHeight: "".concat(headerHeight, "px")
2273
+ },
2274
+ children: layoutCtx.HeaderBrand ? layoutCtx.HeaderBrand() : /*#__PURE__*/jsxs(Fragment, {
2275
+ children: [layoutCtx.logoPath ? /*#__PURE__*/jsx("div", {
2276
+ className: "brand-logo",
2277
+ style: {
2278
+ backgroundImage: "url(".concat(layoutCtx.logoPath, ")")
2279
+ }
2280
+ }) : null, /*#__PURE__*/jsx("div", {
2281
+ className: "brand-name",
2282
+ children: layoutCtx.brandName
2283
+ })]
2284
+ })
2285
+ });
2286
+ };
2287
+
2288
+ var HeaderBarIcon = function HeaderBarIcon(props) {
2289
+ var svgImg = props.iconImg || props.iconImgActive;
2290
+ if (svgImg) {
2291
+ var isSvg = !isHttpUri(svgImg) ? true : svgImg.endsWith('.svg');
2292
+ if (isSvg) {
2293
+ return /*#__PURE__*/jsx(Fragment, {
2294
+ children: props.isActive ? /*#__PURE__*/jsx("div", {
2295
+ className: "menu-icon-img-active",
2296
+ style: {
2297
+ marginRight: 5,
2298
+ display: 'block'
2299
+ },
2300
+ children: props.iconImgActive ? /*#__PURE__*/jsx(SvgHttpView, {
2301
+ svgPath: props.iconImgActive,
2302
+ color: props.textColor,
2303
+ style: {
2304
+ display: 'block'
2305
+ },
2306
+ width: 16,
2307
+ height: 16
2308
+ }) : /*#__PURE__*/jsx(SvgHttpView, {
2309
+ svgPath: svgImg,
2310
+ color: props.activeColor,
2311
+ style: {
2312
+ display: 'block'
2313
+ },
2314
+ width: 16,
2315
+ height: 16
2316
+ })
2317
+ }) : /*#__PURE__*/jsx("div", {
2318
+ className: "menu-icon-img",
2319
+ style: {
2320
+ marginRight: 5,
2321
+ display: 'block'
2322
+ },
2323
+ children: /*#__PURE__*/jsx(SvgHttpView, {
2324
+ svgPath: svgImg,
2325
+ color: props.textColor,
2326
+ style: {
2327
+ display: 'block'
2328
+ },
2329
+ width: 16,
2330
+ height: 16
2331
+ })
2332
+ })
2333
+ });
2334
+ }
2335
+ }
2336
+ if (props.iconImg && props.iconImgActive) {
2337
+ return /*#__PURE__*/jsx(Fragment, {
2338
+ children: props.isActive ? /*#__PURE__*/jsx("div", {
2339
+ className: "menu-icon-img-active",
2340
+ style: {
2341
+ backgroundImage: "url(".concat(props.iconImgActive, ")"),
2342
+ marginRight: 5,
2343
+ display: 'block'
2344
+ }
2345
+ }) : /*#__PURE__*/jsx("div", {
2346
+ className: "menu-icon-img",
2347
+ style: {
2348
+ backgroundImage: "url('".concat(props.iconImg, "')"),
2349
+ marginRight: 5,
2350
+ display: 'block'
2351
+ }
2352
+ })
2353
+ });
2354
+ }
2355
+ return /*#__PURE__*/jsx(Fragment, {});
2356
+ };
2357
+ var Header = function Header() {
2358
+ var _layoutCtx$headerThem, _layoutCtx$headerThem2, _layoutCtx$headerThem3, _layoutCtx$headerThem4, _layoutCtx$headerThem5, _layoutCtx$headerThem6, _layoutCtx$headerThem7;
2359
+ var layoutCtx = useLayoutCtx();
2360
+ var menus = layoutCtx.menus,
2361
+ topMenuActiveItem = layoutCtx.topMenuActiveItem,
2362
+ siderBarMenus = layoutCtx.siderBarMenus,
2363
+ headerHeight = layoutCtx.headerHeight;
2364
+ var activeColor = (_layoutCtx$headerThem = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem === void 0 ? void 0 : _layoutCtx$headerThem.menuSelectedTextColor;
2365
+ var textColor = (_layoutCtx$headerThem2 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem2 === void 0 ? void 0 : _layoutCtx$headerThem2.textColor;
2366
+ var topMenus = useMemo(function () {
2367
+ return layoutCtx.disableTopbarMenu ? [] : menus.map(function (item) {
2368
+ return {
2369
+ key: "".concat(item.id),
2370
+ icon: layoutCtx.showHeaderMenuIcon ? /*#__PURE__*/jsx(HeaderBarIcon, {
2371
+ iconImg: item.iconImg,
2372
+ iconImgActive: item.iconImgActive,
2373
+ activeColor: activeColor,
2374
+ textColor: textColor,
2375
+ isActive: valueIsEqual(topMenuActiveItem === null || topMenuActiveItem === void 0 ? void 0 : topMenuActiveItem.id, item.id)
2376
+ }) : undefined,
2377
+ label: item.name
2378
+ };
2379
+ });
2380
+ }, [activeColor, layoutCtx.disableTopbarMenu, layoutCtx.showHeaderMenuIcon, menus, textColor, topMenuActiveItem === null || topMenuActiveItem === void 0 ? void 0 : topMenuActiveItem.id]);
2381
+ var onClick = hooks.useCallbackRef(function (data) {
2382
+ var targetItem = menus.filter(function (item) {
2383
+ return valueIsEqual(data.key, item.id);
2384
+ })[0];
2385
+ if (targetItem.target === '_blank') {
2386
+ window.open(targetItem.link);
2387
+ return;
2388
+ }
2389
+ var isIframeRoute = layoutCtx.iframeTopbarMenuClickType === 'route';
2390
+ var isNormal = layoutCtx.layoutMode === 'normal';
2391
+ if (!isNormal && isIframeRoute) {
2392
+ var _layoutCtx$topMenuAct;
2393
+ if (!valueIsEqual((_layoutCtx$topMenuAct = layoutCtx.topMenuActiveItem) === null || _layoutCtx$topMenuAct === void 0 ? void 0 : _layoutCtx$topMenuAct.id, targetItem.id)) {
2394
+ layoutCtx.iframeTopRouteMenuChange(targetItem);
2395
+ }
2396
+ return;
2397
+ }
2398
+ if (!isNormal && !valueIsEqual(targetItem === null || targetItem === void 0 ? void 0 : targetItem.id, topMenuActiveItem === null || topMenuActiveItem === void 0 ? void 0 : topMenuActiveItem.id)) {
2399
+ // 清理上一个TOPBAR链接的storage缓存.
2400
+ clearStorage();
2401
+ }
2402
+ /**
2403
+ * 此处后端配置的link 可能权限不存在,直接获取第一个子菜单的叶子节点link
2404
+ * 1. 如果有 link,则直接使用
2405
+ * 2. 如果没有配置link,则使用children中的第一个叶子节点
2406
+ */
2407
+ if (targetItem.link) {
2408
+ // top menu中配置的 菜单域名可能不同,不能使用 当前GLOBAL中的host,直接使用link
2409
+ window.location.href = toLinkPath(targetItem.link);
2410
+ } else {
2411
+ var leafNode = findOneLeafNode(treeToArray(targetItem.children || [], 'children'));
2412
+ if (leafNode !== null && leafNode !== void 0 && leafNode.link) {
2413
+ window.location.href = toLinkPath(isNormal ? guessNormalItemLink(leafNode.link) : guessIframeMainLink(leafNode.link));
2414
+ return;
2415
+ } else if (leafNode !== null && leafNode !== void 0 && leafNode.path) {
2416
+ window.location.href = toLinkPath(isNormal ? guessNormalItemLink(leafNode.path) : guessIframeMainLink(leafNode.path));
2417
+ return;
2418
+ }
2419
+ }
2420
+ });
2421
+ var className = classNames('hyperse-layout-main-header', {
2422
+ 'hyperse-layout-main-header-has-menu': topMenus.length > 0
2423
+ });
2424
+ return /*#__PURE__*/jsxs("div", {
2425
+ className: className,
2426
+ style: {
2427
+ height: headerHeight
2428
+ },
2429
+ children: [siderBarMenus.length === 0 || layoutCtx.hideSidebarMenu ? /*#__PURE__*/jsx(HeaderBrand, {}) : null, layoutCtx.showTopMenuShrink ? /*#__PURE__*/jsx(Shrink, {
2430
+ className: "header-shrink"
2431
+ }) : null, layoutCtx.systemName ? /*#__PURE__*/jsx("div", {
2432
+ className: "hyperse-layout-system-name",
2433
+ children: layoutCtx.systemName
2434
+ }) : null, /*#__PURE__*/jsxs("div", {
2435
+ className: "hyperse-layout-header-fill",
2436
+ children: [/*#__PURE__*/jsx(ConfigProviderWrapper, _objectSpread2(_objectSpread2({
2437
+ theme: {
2438
+ token: {
2439
+ fontSize: (_layoutCtx$headerThem3 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem3 === void 0 ? void 0 : _layoutCtx$headerThem3.menuTextFontSize
2440
+ },
2441
+ components: {
2442
+ Menu: {
2443
+ itemColor: (_layoutCtx$headerThem4 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem4 === void 0 ? void 0 : _layoutCtx$headerThem4.menuColor,
2444
+ itemHoverColor: (_layoutCtx$headerThem5 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem5 === void 0 ? void 0 : _layoutCtx$headerThem5.menuActiveTextColor,
2445
+ horizontalItemSelectedBg: (_layoutCtx$headerThem6 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem6 === void 0 ? void 0 : _layoutCtx$headerThem6.menuSelectedBgColor,
2446
+ horizontalItemSelectedColor: (_layoutCtx$headerThem7 = layoutCtx.headerThemeConfig) === null || _layoutCtx$headerThem7 === void 0 ? void 0 : _layoutCtx$headerThem7.menuSelectedTextColor
2447
+ }
2448
+ }
2449
+ }
2450
+ }, layoutCtx.topMenuConfigProviderProps), {}, {
2451
+ children: topMenus.length > 0 ? /*#__PURE__*/jsx(Menu, {
2452
+ className: "hyperse-layout-topmenu",
2453
+ mode: "horizontal",
2454
+ overflowedIndicatorPopupClassName: "hyperse-layout-topmenu-overflowed-modal",
2455
+ direction: "rtl",
2456
+ triggerSubMenuAction: "click",
2457
+ selectedKeys: topMenuActiveItem !== null && topMenuActiveItem !== void 0 && topMenuActiveItem.id ? ["".concat(topMenuActiveItem.id)] : undefined
2458
+ // defaultSelectedKeys={topMenuActiveItem?.id ? [`${topMenuActiveItem.id}`] : undefined}
2459
+ ,
2460
+ items: topMenus,
2461
+ onClick: onClick,
2462
+ theme: "light"
2463
+ }) : null
2464
+ })), layoutCtx.Header ? /*#__PURE__*/jsx(layoutCtx.Header, {}) : null]
2465
+ }), /*#__PURE__*/jsx(HeaderAccount, {})]
2466
+ });
2467
+ };
2468
+
2469
+ var Sider = Layout.Sider;
2470
+ var SiderBarIcon = function SiderBarIcon(props) {
2471
+ var svgImg = props.iconImg || props.icon;
2472
+ if (svgImg) {
2473
+ var isSvg = !isHttpUri(svgImg) ? true : svgImg.endsWith('.svg');
2474
+ if (isSvg) {
2475
+ return /*#__PURE__*/jsxs(Fragment, {
2476
+ children: [/*#__PURE__*/jsx("div", {
2477
+ className: "menu-icon-img",
2478
+ children: /*#__PURE__*/jsx(SvgHttpView, {
2479
+ svgPath: svgImg,
2480
+ color: props.textColor,
2481
+ style: {
2482
+ display: 'block'
2483
+ },
2484
+ width: 16,
2485
+ height: 16
2486
+ })
2487
+ }), /*#__PURE__*/jsx("div", {
2488
+ className: "menu-icon-img-active",
2489
+ children: /*#__PURE__*/jsx(SvgHttpView, {
2490
+ svgPath: svgImg,
2491
+ color: props.colorActive,
2492
+ style: {
2493
+ display: 'block'
2494
+ },
2495
+ width: 16,
2496
+ height: 16
2497
+ })
2498
+ })]
2499
+ });
2500
+ }
2501
+ }
2502
+ if (props.iconImg && props.iconImgActive) {
2503
+ return /*#__PURE__*/jsxs(Fragment, {
2504
+ children: [/*#__PURE__*/jsx("div", {
2505
+ className: "menu-icon-img",
2506
+ style: {
2507
+ backgroundImage: "url(".concat(props.iconImg, ")")
2508
+ }
2509
+ }), /*#__PURE__*/jsx("div", {
2510
+ className: "menu-icon-img-active",
2511
+ style: {
2512
+ backgroundImage: "url(".concat(props.iconImgActive, ")")
2513
+ }
2514
+ })]
2515
+ });
2516
+ }
2517
+ return /*#__PURE__*/jsx("div", {
2518
+ className: "menu-icon-placeholder"
2519
+ });
2520
+ };
2521
+ var SiderBar = function SiderBar() {
2522
+ var _layoutCtx$sidebarThe, _layoutCtx$sidebarThe2, _layoutCtx$sidebarThe3, _layoutCtx$sidebarThe4, _layoutCtx$sidebarThe5, _layoutCtx$sidebarThe6, _layoutCtx$sidebarThe7, _layoutCtx$sidebarThe8, _layoutCtx$sidebarThe9, _layoutCtx$sidebarThe10, _layoutCtx$sidebarThe11, _layoutCtx$sidebarThe12, _layoutCtx$sidebarThe13, _layoutCtx$sidebarThe14;
2523
+ var _useState = useState(),
2524
+ _useState2 = _slicedToArray(_useState, 2),
2525
+ searchValue = _useState2[0],
2526
+ setSearchValue = _useState2[1];
2527
+ var openKeysRef = useRef();
2528
+ var layoutCtx = useLayoutCtx();
2529
+ var multipleOpen = layoutCtx.siderBarFirstMenuFoldMultipleOpen;
2530
+ multipleOpen = typeof multipleOpen === 'undefined' ? true : multipleOpen;
2531
+ var colorActive = (_layoutCtx$sidebarThe = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe === void 0 ? void 0 : _layoutCtx$sidebarThe.menuActiveTextColor;
2532
+ var textColor = (_layoutCtx$sidebarThe2 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe2 === void 0 ? void 0 : _layoutCtx$sidebarThe2.menuColor;
2533
+ var navigate = useNavigate();
2534
+ var siderBarTileMenus = layoutCtx.siderBarTileMenus;
2535
+ var menuItemActiveKeyRef = useRef();
2536
+ var antdMenuitems = useMemo(function () {
2537
+ var menusTreeList = layoutCtx.siderBarMenus;
2538
+ if (searchValue) {
2539
+ menusTreeList = treeFilter(cloneObject(menusTreeList), function (node) {
2540
+ var _node$name;
2541
+ var value = (_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.toLowerCase();
2542
+ return value.indexOf(searchValue.toLowerCase()) >= 0;
2543
+ }, {
2544
+ childrenName: 'children'
2545
+ });
2546
+ openKeysRef.current = treeToArray(menusTreeList, 'children').map(function (item) {
2547
+ return String(item.id);
2548
+ });
2549
+ } else {
2550
+ openKeysRef.current = undefined;
2551
+ }
2552
+ var _getMenuItem = function getMenuItem(itemList, index) {
2553
+ return itemList.map(function (item) {
2554
+ if (item.children && item.children.length > 0) {
2555
+ return {
2556
+ key: String(item.id),
2557
+ icon: /*#__PURE__*/jsx(SiderBarIcon, {
2558
+ iconImg: item.iconImg,
2559
+ iconImgActive: item.iconImgActive,
2560
+ colorActive: colorActive,
2561
+ icon: item.icon,
2562
+ textColor: textColor
2563
+ }),
2564
+ label: item.name,
2565
+ children: _getMenuItem(item.children, index + 1),
2566
+ popupClassName: 'hyperse-layout-sider-submenu-popup',
2567
+ className: index === 0 && !item.iconImg && !item.iconImgActive ? 'hyperse-layout-menu-item-no-icon' : undefined
2568
+ };
2569
+ }
2570
+ return {
2571
+ key: String(item.id),
2572
+ icon: /*#__PURE__*/jsx(SiderBarIcon, {
2573
+ iconImg: item.iconImg,
2574
+ iconImgActive: item.iconImgActive,
2575
+ colorActive: colorActive,
2576
+ icon: item.icon,
2577
+ textColor: textColor
2578
+ }),
2579
+ label: item.name
2580
+ };
2581
+ });
2582
+ };
2583
+ return _getMenuItem(menusTreeList, 0);
2584
+ }, [colorActive, layoutCtx.siderBarMenus, searchValue]);
2585
+ var onClick = hooks.useCallbackRef(function (data) {
2586
+ if (!valueIsEqual(menuItemActiveKeyRef.current, data.key)) {
2587
+ var _layoutCtx$siderBarMe;
2588
+ (_layoutCtx$siderBarMe = layoutCtx.siderBarMenuOnChange) === null || _layoutCtx$siderBarMe === void 0 || _layoutCtx$siderBarMe.call(layoutCtx, data);
2589
+ }
2590
+ menuItemActiveKeyRef.current = data.key;
2591
+ var targetItem = siderBarTileMenus.filter(function (item) {
2592
+ return valueIsEqual(data.key, item.id);
2593
+ })[0];
2594
+ if (targetItem.target === '_blank') {
2595
+ window.open(targetItem.link);
2596
+ return;
2597
+ }
2598
+ window['__sider_bar_menu_click'] = true;
2599
+ layoutCtx.onChangeSelectedKeys(data.keyPath);
2600
+ if (layoutCtx.layoutMode === 'iframe-main') {
2601
+ layoutCtx.onIframeChange(data.key, 'menuClick');
2602
+ return;
2603
+ }
2604
+ if (targetItem.link) {
2605
+ window.location.href = toLinkPath(targetItem.link);
2606
+ return;
2607
+ }
2608
+ if (targetItem.path) {
2609
+ navigate(toLinkPath(targetItem.path));
2610
+ document.title = targetItem.metaTitle || targetItem.name;
2611
+ }
2612
+ });
2613
+ var onOpenChange = hooks.useCallbackRef(function (openKeys) {
2614
+ if (!multipleOpen && openKeys.length > 0) {
2615
+ var target = openKeys[openKeys.length - 1];
2616
+ // 判断点击的是否为一级菜单
2617
+ if (layoutCtx.siderBarMenus.find(function (item) {
2618
+ return valueIsEqual(item.id, target);
2619
+ })) {
2620
+ layoutCtx.onChangeOpendKeys([target]);
2621
+ return;
2622
+ }
2623
+ }
2624
+ layoutCtx.onChangeOpendKeys(openKeys);
2625
+ });
2626
+ var _useState3 = useState(0),
2627
+ _useState4 = _slicedToArray(_useState3, 2),
2628
+ refreshKey = _useState4[0],
2629
+ setRefreshKey = _useState4[1];
2630
+ useEffect(function () {
2631
+ // 在操作shrink时,两种类型的Menu结构都缓存时,在切换shrink时会出现错误菜单闪屏(未找到更合适的解决方案,此处修改Menu key值后菜单重置可解决闪屏问题)
2632
+ setRefreshKey(Date.now());
2633
+ }, [layoutCtx.collapsed]);
2634
+ var menuProps = {
2635
+ mode: !layoutCtx.collapsed ? 'inline' : 'vertical',
2636
+ items: antdMenuitems,
2637
+ inlineIndent: (_layoutCtx$sidebarThe3 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe3 === void 0 ? void 0 : _layoutCtx$sidebarThe3.inlineIndent,
2638
+ onClick: onClick,
2639
+ selectedKeys: layoutCtx.selectedKeys,
2640
+ onOpenChange: onOpenChange
2641
+ };
2642
+ if (!layoutCtx.collapsed) {
2643
+ menuProps.openKeys = openKeysRef.current || layoutCtx.opendKeys;
2644
+ }
2645
+ var onSearchChange = function onSearchChange(event) {
2646
+ var value = event.target.value;
2647
+ setSearchValue(value);
2648
+ };
2649
+ var sliderBarColor = ((_layoutCtx$sidebarThe4 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe4 === void 0 ? void 0 : _layoutCtx$sidebarThe4.bgColor) || '';
2650
+ var manualControlShrink = window['__manual_control_shrink'];
2651
+ var onMouseLeave = function onMouseLeave() {
2652
+ if (manualControlShrink || !layoutCtx.sidebarMouseHoverOpen) return;
2653
+ if (!layoutCtx.collapsed) {
2654
+ layoutCtx.onChangeCollapsed(true);
2655
+ }
2656
+ };
2657
+ var onMouseEnter = hooks.useDebounceClick(function () {
2658
+ if (manualControlShrink || !layoutCtx.sidebarMouseHoverOpen) return;
2659
+ if (layoutCtx.collapsed) {
2660
+ layoutCtx.onChangeCollapsed(false);
2661
+ }
2662
+ }, 500);
2663
+ return /*#__PURE__*/jsxs(Sider, {
2664
+ theme: "light",
2665
+ className: "hyperse-layout-sider",
2666
+ collapsed: layoutCtx.collapsed,
2667
+ width: layoutCtx.sidebarWidth,
2668
+ collapsedWidth: layoutCtx.collapsedWidth,
2669
+ children: [/*#__PURE__*/jsx(HeaderBrand, {}), /*#__PURE__*/jsxs(ConfigProviderWrapper, _objectSpread2(_objectSpread2({
2670
+ theme: {
2671
+ token: {
2672
+ controlHeight: (_layoutCtx$sidebarThe5 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe5 === void 0 ? void 0 : _layoutCtx$sidebarThe5.menuItemHeight,
2673
+ fontSize: (_layoutCtx$sidebarThe6 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe6 === void 0 ? void 0 : _layoutCtx$sidebarThe6.menuTextFontSize
2674
+ },
2675
+ components: {
2676
+ Menu: {
2677
+ itemBg: (_layoutCtx$sidebarThe7 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe7 === void 0 ? void 0 : _layoutCtx$sidebarThe7.bgColor,
2678
+ itemColor: (_layoutCtx$sidebarThe8 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe8 === void 0 ? void 0 : _layoutCtx$sidebarThe8.menuColor,
2679
+ itemHoverColor: (_layoutCtx$sidebarThe9 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe9 === void 0 ? void 0 : _layoutCtx$sidebarThe9.menuActiveTextColor,
2680
+ itemHoverBg: (_layoutCtx$sidebarThe10 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe10 === void 0 ? void 0 : _layoutCtx$sidebarThe10.menuActiveBgColor,
2681
+ itemActiveBg: (_layoutCtx$sidebarThe11 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe11 === void 0 ? void 0 : _layoutCtx$sidebarThe11.menuActiveBgColor,
2682
+ itemSelectedColor: (_layoutCtx$sidebarThe12 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe12 === void 0 ? void 0 : _layoutCtx$sidebarThe12.menuSelectedTextColor,
2683
+ itemSelectedBg: (_layoutCtx$sidebarThe13 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe13 === void 0 ? void 0 : _layoutCtx$sidebarThe13.menuSelectedBgColor,
2684
+ subMenuItemBg: (_layoutCtx$sidebarThe14 = layoutCtx.sidebarThemeConfig) === null || _layoutCtx$sidebarThe14 === void 0 ? void 0 : _layoutCtx$sidebarThe14.menuSubMenuBgColor
2685
+ }
2686
+ }
2687
+ }
2688
+ }, layoutCtx.sidebarMenuConfigProviderProps), {}, {
2689
+ children: [layoutCtx.sliderBarSearch ? /*#__PURE__*/jsxs("div", {
2690
+ className: classNames('sider-bar-search', {
2691
+ 'sider-bar-search-bgfff': valueIsEqual(sliderBarColor.toLocaleLowerCase(), ['#fff', '#ffff'])
2692
+ }),
2693
+ children: [/*#__PURE__*/jsx(InputWrapper, {
2694
+ allowClear: true,
2695
+ placeholder: "\u641C\u7D22",
2696
+ onChange: onSearchChange
2697
+ }), multipleOpen ? /*#__PURE__*/jsx("div", {
2698
+ style: {
2699
+ marginLeft: 10
2700
+ },
2701
+ children: /*#__PURE__*/jsx(IconWrapper, {
2702
+ onClick: function onClick() {
2703
+ layoutCtx.onChangeOpendKeys([]);
2704
+ },
2705
+ size: "small",
2706
+ icon: /*#__PURE__*/jsx(SvgHttpView, {
2707
+ svgPath: "lucide/fold-vertical",
2708
+ width: 18,
2709
+ height: 18
2710
+ })
2711
+ })
2712
+ }) : null]
2713
+ }) : null, /*#__PURE__*/jsx(Menu, _objectSpread2(_objectSpread2({}, menuProps), {}, {
2714
+ onMouseLeave: onMouseLeave,
2715
+ onMouseEnter: onMouseEnter
2716
+ }), refreshKey)]
2717
+ })), !layoutCtx.hideSidebarShrink && /*#__PURE__*/jsx(Shrink, {
2718
+ className: "sider-bar-shrink"
2719
+ })]
2720
+ });
2721
+ };
2722
+
2723
+ var EventHandling = function EventHandling() {
2724
+ var navigate = useNavigate();
2725
+ var layoutCtx = useLayoutCtx();
2726
+ var _hooks$useGlobal = hooks.useGlobal(),
2727
+ user = _hooks$useGlobal.user,
2728
+ hostUrl = _hooks$useGlobal.hostUrl;
2729
+ useIframe(function (result) {
2730
+ if (result.type === 'redirect_to_frame_layout_menu_item') {
2731
+ var iframeTabItem = result.data;
2732
+ layoutCtx.onIframeChangeByHttpUrl(guessIframeMainLink(iframeTabItem.link), {
2733
+ name: iframeTabItem.name,
2734
+ metaTitle: iframeTabItem.metaTitle
2735
+ });
2736
+ } else if (result.type === 'redirect_to_frame_layout_menu_third_item') {
2737
+ var menuId = result.data.menuId;
2738
+ var target = layoutCtx.siderBarTileMenus.find(function (item) {
2739
+ return valueIsEqual(item.id, menuId);
2740
+ });
2741
+ if (!target) {
2742
+ void message$1.error("menuId\uFF1A".concat(menuId, "\uFF0C\u672A\u5339\u914D\u5230\u83DC\u5355\u6570\u636E"));
2743
+ return;
2744
+ }
2745
+ var link = result.data['options'].link;
2746
+ var name = result.data['options'].name;
2747
+ layoutCtx.onOpenNewIframeThirdMenuItem({
2748
+ menuItem: target,
2749
+ link: link,
2750
+ name: name
2751
+ });
2752
+ } else if (result.type === 'open_browser_window') {
2753
+ var _result$data;
2754
+ var url = (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data['url'];
2755
+ if (url) {
2756
+ window.open(url);
2757
+ }
2758
+ } else if (result.type === 'browser_location_href') {
2759
+ var _result$data2;
2760
+ var _url = (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2['url'];
2761
+ if (_url) {
2762
+ window.location.href = guessIframeMainLink(_url);
2763
+ }
2764
+ } else if (result.type === 'history_change') {
2765
+ var _result$data3;
2766
+ if (layoutCtx.cancelIframeRouteSyncParent) {
2767
+ return;
2768
+ }
2769
+ var _link = (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3['link'];
2770
+ var _parseIframeMainUrlIn = parseIframeMainUrlInfo(_link),
2771
+ pathSearch = _parseIframeMainUrlIn.pathSearch;
2772
+ navigate(pathSearch);
2773
+ var _target = parseSiderTargetMenuByPath(layoutCtx.siderBarTileMenus, _link);
2774
+ var tabName = getIframeTabName(_link, _target.name);
2775
+ // 更新缓存数据
2776
+ updateCaheIframeListByActiveId(layoutCtx.iframeTabActiveItem.id, {
2777
+ link: _link,
2778
+ name: tabName,
2779
+ metaTitle: _target.metaTitle,
2780
+ pathSearch: pathSearch
2781
+ });
2782
+ layoutCtx.onUpdateIframeTabName(tabName);
2783
+ } else if (result.type === 'open_iframe_tabitem_by_menu_id') {
2784
+ var id = result.data;
2785
+ var _target2 = layoutCtx.siderBarTileMenus.find(function (item) {
2786
+ return valueIsEqual(item.id, id);
2787
+ });
2788
+ if (_target2) {
2789
+ if ((_target2 === null || _target2 === void 0 ? void 0 : _target2.target) === '_blank') {
2790
+ window.open(_target2.link);
2791
+ return;
2792
+ }
2793
+ layoutCtx.onIframeChange(_target2.id, 'menuClick', {
2794
+ locationMenu: true
2795
+ });
2796
+ }
2797
+ } else if (result.type === 'closed-iframe-tab-to-prevlink') {
2798
+ var _result$data4;
2799
+ var closedIframeTabId = (_result$data4 = result.data) === null || _result$data4 === void 0 ? void 0 : _result$data4['closedIframeTabId'];
2800
+ var operateLinkList = getIframeOpenNewTabItemOperateLinkList();
2801
+ if (closedIframeTabId) {
2802
+ var _target3 = operateLinkList.find(function (item) {
2803
+ return item.endTabId === closedIframeTabId;
2804
+ });
2805
+ layoutCtx.onDeleteCurrentIframeTabItemOpenTargetIframeTab(_target3 === null || _target3 === void 0 ? void 0 : _target3.startTabId, _target3 === null || _target3 === void 0 ? void 0 : _target3.startTabMenuId);
2806
+ }
2807
+ }
2808
+ });
2809
+ useIframe(function (result) {
2810
+ if (result.type === 'session_expired') {
2811
+ var _layoutCtx$onSessionE;
2812
+ (_layoutCtx$onSessionE = layoutCtx.onSessionExpired) === null || _layoutCtx$onSessionE === void 0 || _layoutCtx$onSessionE.call(layoutCtx, user, hostUrl);
2813
+ }
2814
+ });
2815
+ return /*#__PURE__*/jsx(Fragment, {});
2816
+ };
2817
+
2818
+ var IframePageInner = function IframePageInner(props) {
2819
+ return /*#__PURE__*/jsx(Fragment, {
2820
+ children: /*#__PURE__*/jsx("iframe", {
2821
+ id: "iframe_".concat(String(props.id)),
2822
+ src: props.link,
2823
+ width: "100%",
2824
+ height: "100%",
2825
+ style: {
2826
+ border: 'none'
2827
+ },
2828
+ onLoad: props.onLoad,
2829
+ className: "iframe-".concat(props.menuKey)
2830
+ }, props.iframeKey)
2831
+ });
2832
+ };
2833
+ var IframePage = /*#__PURE__*/memo(IframePageInner, function (prevProps, nextProps) {
2834
+ return prevProps.iframeKey === nextProps.iframeKey;
2835
+ });
2836
+
2837
+ var PageContent = function PageContent() {
2838
+ var _useLayoutCtx = useLayoutCtx(),
2839
+ iframeTabList = _useLayoutCtx.iframeTabList,
2840
+ iframeTabBarExtra = _useLayoutCtx.iframeTabBarExtra,
2841
+ iframeTabActiveItem = _useLayoutCtx.iframeTabActiveItem,
2842
+ onIframeChange = _useLayoutCtx.onIframeChange,
2843
+ onDeleteIframeTabItem = _useLayoutCtx.onDeleteIframeTabItem,
2844
+ siderBarTileMenus = _useLayoutCtx.siderBarTileMenus;
2845
+ var _useState = useState([]),
2846
+ _useState2 = _slicedToArray(_useState, 2),
2847
+ iframeLoadKeyList = _useState2[0],
2848
+ setIframeLoadKeyList = _useState2[1];
2849
+ var _useState3 = useState([]),
2850
+ _useState4 = _slicedToArray(_useState3, 2),
2851
+ refreshIframeIds = _useState4[0],
2852
+ setRefreshIframeIds = _useState4[1];
2853
+ var refreshIframeStart = hooks.useCallbackRef(function (tabItem) {
2854
+ refreshIframeIds.push(tabItem.id);
2855
+ setRefreshIframeIds(_toConsumableArray(refreshIframeIds));
2856
+ });
2857
+ var refreshIframeStartEnd = hooks.useCallbackRef(function (tabItem) {
2858
+ var newArray = arrayRemove(refreshIframeIds, tabItem.id);
2859
+ setRefreshIframeIds(_toConsumableArray(newArray));
2860
+ });
2861
+ fbaHooks.useEffectCustom(function () {
2862
+ if (iframeTabActiveItem.id) {
2863
+ window["__refresh_iframe_".concat(iframeTabActiveItem.id)] = {
2864
+ start: function start() {
2865
+ refreshIframeStart(iframeTabActiveItem);
2866
+ },
2867
+ end: refreshIframeStartEnd.bind(null, iframeTabActiveItem)
2868
+ };
2869
+ }
2870
+ }, [iframeTabActiveItem.id]);
2871
+ var onTabClick = hooks.useDebounceClick(function (key) {
2872
+ onIframeChange(key, 'iframeTabClick');
2873
+ }, 200);
2874
+ var onTabItemRemove = hooks.useCallbackRef(function (tabItemKey) {
2875
+ if (valueIsEqual(tabItemKey, iframeTabActiveItem.id)) {
2876
+ onDeleteIframeTabItem('me', tabItemKey);
2877
+ } else {
2878
+ onDeleteIframeTabItem('other', tabItemKey);
2879
+ }
2880
+ });
2881
+ var onClick = hooks.useCallbackRef(function (data) {
2882
+ if (data.key === '1') {
2883
+ onIframeChange(iframeTabActiveItem.id, 'iframeRefresh');
2884
+ } else if (data.key === '2') {
2885
+ onDeleteIframeTabItem('otherAll');
2886
+ } else if (data.key === '3') {
2887
+ onDeleteIframeTabItem('all');
2888
+ }
2889
+ });
2890
+ var menuItems = [{
2891
+ label: '刷新当前',
2892
+ key: '1',
2893
+ onClick: onClick.bind(null, {
2894
+ key: '1'
2895
+ }),
2896
+ icon: /*#__PURE__*/jsx(_RedoOutlined, {})
2897
+ }, {
2898
+ label: '关闭其他',
2899
+ key: '2',
2900
+ onClick: onClick.bind(null, {
2901
+ key: '2'
2902
+ }),
2903
+ icon: /*#__PURE__*/jsx(_CloseOutlined, {})
2904
+ }, {
2905
+ label: '关闭所有',
2906
+ key: '3',
2907
+ onClick: onClick.bind(null, {
2908
+ key: '3'
2909
+ }),
2910
+ icon: /*#__PURE__*/jsx(_LogoutOutlined, {})
2911
+ }];
2912
+ var tabItems = iframeTabList.map(function (item) {
2913
+ var pageSpinner = !arrayFindByLoosely(iframeLoadKeyList, item.iframeKey);
2914
+ var menuKey;
2915
+ if (item.menuId) {
2916
+ var _siderBarTileMenus$fi;
2917
+ menuKey = (_siderBarTileMenus$fi = siderBarTileMenus.find(function (temp) {
2918
+ return valueIsEqual(temp.id, item.menuId);
2919
+ })) === null || _siderBarTileMenus$fi === void 0 ? void 0 : _siderBarTileMenus$fi.key;
2920
+ }
2921
+ // const fixHeight = hideHeader ? 38 : 38 + (headerHeight as number);
2922
+ return {
2923
+ label: item.name,
2924
+ key: "".concat(item.id),
2925
+ style: {
2926
+ height: '100%',
2927
+ position: 'relative'
2928
+ },
2929
+ closable: true,
2930
+ closeIcon: arrayFindByLoosely(refreshIframeIds, item.id) ? /*#__PURE__*/jsx(_LoadingOutlined, {}) : /*#__PURE__*/jsx("span", {
2931
+ className: "tab-icon"
2932
+ }),
2933
+ children: /*#__PURE__*/jsxs(Fragment, {
2934
+ children: [/*#__PURE__*/jsx(Loader, {
2935
+ spinning: pageSpinner,
2936
+ style: {
2937
+ backgroundColor: 'var(--bg-color)'
2938
+ }
2939
+ }), /*#__PURE__*/jsx(IframePage, {
2940
+ id: item.id,
2941
+ link: item.link,
2942
+ iframeKey: item.iframeKey,
2943
+ onLoad: function onLoad() {
2944
+ var target = document.querySelector("#iframe_".concat(item.id));
2945
+ try {
2946
+ if (target.contentWindow) {
2947
+ target.contentWindow['__iframe_node_key'] = "iframe_".concat(item.id);
2948
+ }
2949
+ } catch (_error) {
2950
+ // 异常不处理,iframe写入属性可能会存在跨域问题
2951
+ }
2952
+ setIframeLoadKeyList(function (prev) {
2953
+ return prev.concat(item.iframeKey);
2954
+ });
2955
+ },
2956
+ menuKey: menuKey
2957
+ })]
2958
+ })
2959
+ };
2960
+ });
2961
+ return /*#__PURE__*/jsx(Tabs, {
2962
+ hideAdd: true,
2963
+ items: tabItems,
2964
+ activeKey: iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id,
2965
+ onTabClick: onTabClick
2966
+ // onChange={onTabChange}
2967
+ ,
2968
+ style: {
2969
+ height: '100%'
2970
+ },
2971
+ className: "iframe-tabs",
2972
+ type: iframeTabList.length === 1 ? 'card' : 'editable-card',
2973
+ onEdit: onTabItemRemove,
2974
+ tabBarExtraContent: {
2975
+ right: iframeTabBarExtra ? iframeTabBarExtra : /*#__PURE__*/jsx(Dropdown, {
2976
+ menu: {
2977
+ items: menuItems
2978
+ },
2979
+ arrow: true,
2980
+ className: "menu-tabs-operate",
2981
+ placement: "bottomRight",
2982
+ overlayClassName: "menu-tabs-operate-dropdown"
2983
+ // 此处不能使用 click
2984
+ ,
2985
+ trigger: ['hover'],
2986
+ children: /*#__PURE__*/jsx(_CaretDownOutlined, {})
2987
+ })
2988
+ }
2989
+ });
2990
+ };
2991
+ var PageContentSingleFrame = function PageContentSingleFrame() {
2992
+ var ctx = useLayoutCtx();
2993
+ var actived = ctx.iframeTabActiveItem;
2994
+ var _useState5 = useState([]),
2995
+ _useState6 = _slicedToArray(_useState5, 2),
2996
+ iframeLoadKeyList = _useState6[0],
2997
+ setIframeLoadKeyList = _useState6[1];
2998
+ var pageSpinner = !arrayFindByLoosely(iframeLoadKeyList, actived === null || actived === void 0 ? void 0 : actived.iframeKey);
2999
+ return /*#__PURE__*/jsxs("div", {
3000
+ style: {
3001
+ flex: 1,
3002
+ position: 'relative'
3003
+ },
3004
+ children: [/*#__PURE__*/jsx(Loader, {
3005
+ spinning: pageSpinner,
3006
+ style: {
3007
+ backgroundColor: 'var(--bg-color)'
3008
+ }
3009
+ }), /*#__PURE__*/jsx("iframe", {
3010
+ id: "iframe_".concat(String(actived === null || actived === void 0 ? void 0 : actived.id)),
3011
+ src: actived === null || actived === void 0 ? void 0 : actived.link,
3012
+ width: "100%",
3013
+ height: "100%",
3014
+ style: {
3015
+ border: 'none'
3016
+ },
3017
+ onLoad: function onLoad() {
3018
+ setIframeLoadKeyList(function (prev) {
3019
+ return prev.concat(actived === null || actived === void 0 ? void 0 : actived.iframeKey);
3020
+ });
3021
+ }
3022
+ }, actived === null || actived === void 0 ? void 0 : actived.iframeKey)]
3023
+ });
3024
+ };
3025
+ var PageLevelContent = function PageLevelContent() {
3026
+ var ctx = useLayoutCtx();
3027
+ var _useState7 = useState(),
3028
+ _useState8 = _slicedToArray(_useState7, 2),
3029
+ activeItem = _useState8[0],
3030
+ setActiveItem = _useState8[1];
3031
+ var targetList = useMemo(function () {
3032
+ var _treeToArray$find;
3033
+ var targetList = (_treeToArray$find = treeToArray(ctx.completeMenus, 'children').find(function (item) {
3034
+ var _ctx$siderBarMenuActi;
3035
+ return valueIsEqual(item.id, (_ctx$siderBarMenuActi = ctx.siderBarMenuActiveItem) === null || _ctx$siderBarMenuActi === void 0 ? void 0 : _ctx$siderBarMenuActi.id);
3036
+ })) === null || _treeToArray$find === void 0 ? void 0 : _treeToArray$find.children;
3037
+ return targetList || [ctx.siderBarMenuActiveItem];
3038
+ }, [ctx.completeMenus, ctx.siderBarMenuActiveItem]);
3039
+ var items = useMemo(function () {
3040
+ return targetList === null || targetList === void 0 ? void 0 : targetList.map(function (item) {
3041
+ return {
3042
+ key: "".concat(item.id),
3043
+ label: item.name,
3044
+ children: /*#__PURE__*/jsx(Fragment, {})
3045
+ };
3046
+ });
3047
+ }, [targetList]);
3048
+ useEffect(function () {
3049
+ var _targetList$;
3050
+ setActiveItem(_objectSpread2(_objectSpread2({}, targetList[0]), {}, {
3051
+ id: "".concat((_targetList$ = targetList[0]) === null || _targetList$ === void 0 ? void 0 : _targetList$.id)
3052
+ }));
3053
+ }, [targetList]);
3054
+ var onTabClick = function onTabClick(activeKey) {
3055
+ if (valueIsEqual(activeKey, activeItem === null || activeItem === void 0 ? void 0 : activeItem.id)) {
3056
+ var _frameInstance$conten;
3057
+ var frameInstance = document.querySelector("#content_topmenu_".concat(activeKey));
3058
+ setActiveItem(_objectSpread2(_objectSpread2({}, activeItem), {}, {
3059
+ key: Date.now(),
3060
+ link: toLinkPath((frameInstance === null || frameInstance === void 0 || (_frameInstance$conten = frameInstance['contentWindow']) === null || _frameInstance$conten === void 0 || (_frameInstance$conten = _frameInstance$conten.location) === null || _frameInstance$conten === void 0 ? void 0 : _frameInstance$conten.href) || (activeItem === null || activeItem === void 0 ? void 0 : activeItem.link))
3061
+ }));
3062
+ return;
3063
+ }
3064
+ var target = targetList.find(function (item) {
3065
+ return valueIsEqual(item.id, activeKey);
3066
+ });
3067
+ setActiveItem(_objectSpread2(_objectSpread2({}, target), {}, {
3068
+ id: "".concat(target === null || target === void 0 ? void 0 : target.id)
3069
+ }));
3070
+ };
3071
+ return /*#__PURE__*/jsxs("div", {
3072
+ style: {
3073
+ display: 'flex',
3074
+ flexDirection: 'column',
3075
+ height: '100%'
3076
+ },
3077
+ children: [items.length > 1 ? /*#__PURE__*/jsx(Tabs, {
3078
+ tabBarStyle: {
3079
+ margin: 0
3080
+ },
3081
+ onTabClick: onTabClick,
3082
+ defaultActiveKey: "1",
3083
+ activeKey: activeItem === null || activeItem === void 0 ? void 0 : activeItem.id,
3084
+ items: items,
3085
+ type: "card",
3086
+ className: "content-top-menus"
3087
+ }) : null, /*#__PURE__*/jsx("iframe", {
3088
+ id: "content_topmenu_".concat(activeItem === null || activeItem === void 0 ? void 0 : activeItem.id),
3089
+ src: activeItem === null || activeItem === void 0 ? void 0 : activeItem.link,
3090
+ width: "100%",
3091
+ height: "100%",
3092
+ style: {
3093
+ border: 'none',
3094
+ flex: 1
3095
+ }
3096
+ }, activeItem === null || activeItem === void 0 ? void 0 : activeItem.key)]
3097
+ });
3098
+ };
3099
+ var LayoutIFrame = function LayoutIFrame() {
3100
+ var layoutCtx = useLayoutCtx();
3101
+ if (layoutCtx.multiFrameTabs) {
3102
+ return /*#__PURE__*/jsx(PageContent, {});
3103
+ }
3104
+ if (layoutCtx.siderBarMaxMenuLevel) {
3105
+ return /*#__PURE__*/jsx(PageLevelContent, {});
3106
+ }
3107
+ return /*#__PURE__*/jsx(PageContentSingleFrame, {});
3108
+ };
3109
+
3110
+ var App = function App() {
3111
+ var layoutCtx = useLayoutCtx();
3112
+ var isIframeMain = layoutCtx.layoutMode === 'iframe-main';
3113
+ useAntdApp();
3114
+ var LayoutContent = layoutCtx.LayoutComponent || LayoutPage;
3115
+ var isWindows = isWindowsEnv();
3116
+ return /*#__PURE__*/jsxs(Fragment, {
3117
+ children: [/*#__PURE__*/jsx(EventHandling, {}), /*#__PURE__*/jsxs(Layout, {
3118
+ hasSider: true,
3119
+ className: classNames('hyperse-layout', {
3120
+ 'hyperse-layout-windows': isWindows
3121
+ }),
3122
+ children: [layoutCtx.siderBarMenus.length === 0 || layoutCtx.hideSidebarMenu ? null : /*#__PURE__*/jsx(SiderBar, {}), /*#__PURE__*/jsxs(Layout, {
3123
+ className: "hyperse-layout-main",
3124
+ hasSider: false,
3125
+ children: [!layoutCtx.hideHeader ? /*#__PURE__*/jsx(Header, {}) : null, isIframeMain ? /*#__PURE__*/jsx(LayoutIFrame, {}) : /*#__PURE__*/jsx(LayoutContent, {
3126
+ className: layoutCtx.layoutPageClassName,
3127
+ children: /*#__PURE__*/jsx(AppRoutes, {
3128
+ routeList: layoutCtx.routeList,
3129
+ breadExtendRender: layoutCtx.breadExtendRender,
3130
+ breads: layoutCtx.breads,
3131
+ hideDefaultBread: layoutCtx.hideDefaultBread,
3132
+ breadTitle: layoutCtx.breadTitle
3133
+ // initSiderBarMenuActiveItem={props.initSiderBarMenuActiveItem}
3134
+ ,
3135
+ layoutMode: layoutCtx.layoutMode
3136
+ })
3137
+ })]
3138
+ })]
3139
+ })]
3140
+ });
3141
+ };
3142
+
3143
+ var NormalRoutesTiming = function NormalRoutesTiming() {
3144
+ var layoutCtx = useLayoutCtx();
3145
+ var _useLocation = useLocation(),
3146
+ pathname = _useLocation.pathname,
3147
+ search = _useLocation.search;
3148
+ hooks.useUpdateEffect(function () {
3149
+ if (!window['__sider_bar_menu_click']) {
3150
+ layoutCtx.normalModePositionMenu(location.href);
3151
+ }
3152
+ window['__sider_bar_menu_click'] = false;
3153
+ }, [pathname, search]);
3154
+ return /*#__PURE__*/jsx(Fragment, {});
3155
+ };
3156
+
3157
+ var _excluded = ["sidebarWidth", "componentSize", "locale", "logoPath", "headerThemeConfig", "sidebarThemeConfig", "completeMenus"];
3158
+ var AppProvider = function AppProvider(props) {
3159
+ var navigate = useNavigate();
3160
+ var sidebarWidth = props.sidebarWidth,
3161
+ componentSize = props.componentSize,
3162
+ locale = props.locale,
3163
+ logoPath = props.logoPath,
3164
+ headerThemeConfig = props.headerThemeConfig,
3165
+ sidebarThemeConfig = props.sidebarThemeConfig,
3166
+ completeMenus = props.completeMenus,
3167
+ options = _objectWithoutProperties(props, _excluded);
3168
+ var isIframeMain = options.layoutMode === 'iframe-main';
3169
+ var unMatchHiddenSiderBar = isUndefined(options.unMatchHiddenSiderBar) ? true : options.unMatchHiddenSiderBar;
3170
+ var hideSidebarMenu = function () {
3171
+ if (options.disableTopbarMenu) return false;
3172
+ return typeof options.hideSidebarMenu === 'function' ? options.hideSidebarMenu() : options.hideSidebarMenu;
3173
+ }();
3174
+ var _useState = useState(props.initSidebarShrinkClosed),
3175
+ _useState2 = _slicedToArray(_useState, 2),
3176
+ collapsed = _useState2[0],
3177
+ setCollapsed = _useState2[1];
3178
+ var _useState3 = useState([]),
3179
+ _useState4 = _slicedToArray(_useState3, 2),
3180
+ opendKeys = _useState4[0],
3181
+ setOpendKeys = _useState4[1];
3182
+ var _useState5 = useState([]),
3183
+ _useState6 = _slicedToArray(_useState5, 2),
3184
+ selectedKeys = _useState6[0],
3185
+ setSelectedKeys = _useState6[1];
3186
+ var _useState7 = useState(),
3187
+ _useState8 = _slicedToArray(_useState7, 2),
3188
+ siderBarMenuActiveItem = _useState8[0],
3189
+ setSiderBarMenuActiveItem = _useState8[1];
3190
+ var _useState9 = useState(),
3191
+ _useState10 = _slicedToArray(_useState9, 2),
3192
+ topMenuActiveItem = _useState10[0],
3193
+ setTopMenuActiveItem = _useState10[1];
3194
+ var _useState11 = useState([]),
3195
+ _useState12 = _slicedToArray(_useState11, 2),
3196
+ siderBarMenus = _useState12[0],
3197
+ setSiderBarMenus = _useState12[1];
3198
+ // const initSiderBarMenuActiveItemRef = useRef<TMenuItem>();
3199
+
3200
+ var opendKeysTempRef = useRef();
3201
+ var ErrorHandlingRender = options.ErrorHandling || ErrorHandling;
3202
+ var siderBarTileMenus = useMemo(function () {
3203
+ return treeToArray(siderBarMenus, 'children');
3204
+ }, [siderBarMenus]);
3205
+ var getTopMenuItem = function getTopMenuItem(menuId) {
3206
+ var chainMenuIdList = getTargetMenuParentChain(menuId, menus);
3207
+ if (chainMenuIdList.length > 0) {
3208
+ var setTopMenuActiveId = chainMenuIdList[chainMenuIdList.length - 1];
3209
+ return menus.find(function (item) {
3210
+ return valueIsEqual(item.id, setTopMenuActiveId);
3211
+ });
3212
+ }
3213
+ return undefined;
3214
+ };
3215
+ var _useMemo = useMemo(function () {
3216
+ var menus = props.menus;
3217
+ var tileMenus = treeToArray(menus, 'children');
3218
+ var siderBarMenus = [];
3219
+ var siderbarTargetMenu = undefined;
3220
+ // 隐藏 侧边栏
3221
+ if (hideSidebarMenu) {
3222
+ if (!options.disableTopbarMenu) {
3223
+ var target = menus.find(function (item) {
3224
+ return pathIncludePath(getPurePath(location.pathname), item.path);
3225
+ });
3226
+ if (target) {
3227
+ setTopMenuActiveItem(target);
3228
+ }
3229
+ }
3230
+ } else {
3231
+ /**
3232
+ * 先查找叶子节点菜单,再反向查找上级菜单
3233
+ */
3234
+ siderbarTargetMenu = parseSiderTargetMenuByPath(tileMenus, location.href);
3235
+ if (siderbarTargetMenu) {
3236
+ var chainMenuIdList = getTargetMenuParentChain(siderbarTargetMenu.id, menus);
3237
+ if (!options.disableTopbarMenu) {
3238
+ if (chainMenuIdList.length > 0) {
3239
+ var setTopMenuActiveId = chainMenuIdList[chainMenuIdList.length - 1];
3240
+ var topMenuTarget = menus.find(function (item) {
3241
+ return valueIsEqual(item.id, setTopMenuActiveId);
3242
+ });
3243
+ setTopMenuActiveItem(topMenuTarget);
3244
+ siderBarMenus = (topMenuTarget === null || topMenuTarget === void 0 ? void 0 : topMenuTarget.children) || [];
3245
+ }
3246
+ } else {
3247
+ siderBarMenus = menus;
3248
+ }
3249
+ setSelectedKeys(chainMenuIdList);
3250
+ setOpendKeys(chainMenuIdList);
3251
+ opendKeysTempRef.current = chainMenuIdList;
3252
+ setSiderBarMenuActiveItem(siderbarTargetMenu);
3253
+ // initSiderBarMenuActiveItemRef.current = siderbarTargetMenu;
3254
+ document.title = siderbarTargetMenu.metaTitle || siderbarTargetMenu.name;
3255
+ } else {
3256
+ if (options.disableTopbarMenu) {
3257
+ siderBarMenus = menus;
3258
+ setSelectedKeys([]);
3259
+ setOpendKeys([]);
3260
+ opendKeysTempRef.current = [];
3261
+ setSiderBarMenuActiveItem(undefined);
3262
+ // initSiderBarMenuActiveItemRef.current = siderbarTargetMenu;
3263
+ } else {
3264
+ // 当开启顶部菜单时,找不到叶子节点,有可能找到顶部菜单
3265
+ var _target = parseFirstMenuByPath(menus, location.href);
3266
+ if (_target) {
3267
+ if (!unMatchHiddenSiderBar) {
3268
+ siderBarMenus = (_target === null || _target === void 0 ? void 0 : _target.children) || [];
3269
+ }
3270
+ } else {
3271
+ if (!unMatchHiddenSiderBar) {
3272
+ siderBarMenus = menus[0].children || [];
3273
+ }
3274
+ }
3275
+ setTopMenuActiveItem(_target);
3276
+ }
3277
+ }
3278
+ if (isIframeMain) {
3279
+ var initIframeTabActiveItem = initSyncIframeTabCacheByLocation(treeToArray(siderBarMenus, 'children'), siderbarTargetMenu);
3280
+ saveCacheIframeActiveItem(initIframeTabActiveItem);
3281
+ }
3282
+ }
3283
+ setSiderBarMenus(siderBarMenus);
3284
+ return {
3285
+ menus: menus,
3286
+ tileMenus: tileMenus
3287
+ };
3288
+ }, [isIframeMain, options.disableTopbarMenu, hideSidebarMenu, unMatchHiddenSiderBar]),
3289
+ menus = _useMemo.menus,
3290
+ tileMenus = _useMemo.tileMenus;
3291
+ var _useState13 = useState(getCacheIframeActiveItem()),
3292
+ _useState14 = _slicedToArray(_useState13, 2),
3293
+ iframeTabActiveItem = _useState14[0],
3294
+ setIframeTabActiveItem = _useState14[1];
3295
+ var _useState15 = useState(getIframeTabCacheList()),
3296
+ _useState16 = _slicedToArray(_useState15, 2),
3297
+ iframeTabList = _useState16[0],
3298
+ setIframeTabList = _useState16[1];
3299
+ fbaHooks.useEffectCustom(function () {
3300
+ saveIframeTabToCache(iframeTabList);
3301
+ }, [iframeTabList]);
3302
+ fbaHooks.useEffectCustom(function () {
3303
+ if (iframeTabActiveItem !== null && iframeTabActiveItem !== void 0 && iframeTabActiveItem.id) {
3304
+ saveCacheIframeActiveItem(iframeTabActiveItem);
3305
+ document.title = iframeTabActiveItem.metaTitle || iframeTabActiveItem.name;
3306
+ navigate(iframeTabActiveItem.pathSearch);
3307
+ }
3308
+ }, [iframeTabActiveItem]);
3309
+ var onChangeCollapsed = function onChangeCollapsed(boo) {
3310
+ if (boo) {
3311
+ opendKeysTempRef.current = opendKeys;
3312
+ } else {
3313
+ setOpendKeys(opendKeysTempRef.current || []);
3314
+ }
3315
+ setCollapsed(boo);
3316
+ };
3317
+ var onChangeSelectedKeys = function onChangeSelectedKeys(selectedKeys) {
3318
+ setSelectedKeys(selectedKeys);
3319
+ };
3320
+ var onChangeOpendKeys = function onChangeOpendKeys(opendKeys) {
3321
+ setOpendKeys(opendKeys);
3322
+ };
3323
+ var addOrUpdateIframeTab = function addOrUpdateIframeTab(item) {
3324
+ var _addOrUpdateIframeTab = addOrUpdateIframeTabListByMenuItem(item, getIframeTabCacheList()),
3325
+ iframeTabActiveItem = _addOrUpdateIframeTab.iframeTabActiveItem,
3326
+ iframeTabListNew = _addOrUpdateIframeTab.iframeTabListNew;
3327
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3328
+ setIframeTabActiveItem(iframeTabActiveItem);
3329
+ setSiderBarMenuActiveItem(item);
3330
+ };
3331
+ var onChangeSiderBarMenuActiveItem = function onChangeSiderBarMenuActiveItem(_siderBarMenus, _siderBarTileMenus, menuId) {
3332
+ if (menuId) {
3333
+ var menuTarget = _siderBarTileMenus.find(function (item) {
3334
+ return valueIsEqual(item.id, menuId);
3335
+ });
3336
+ if (menuTarget) {
3337
+ setSiderBarMenuActiveItem(menuTarget);
3338
+ var chainMenuIdList = getTargetMenuParentChain(menuTarget.id, _siderBarMenus);
3339
+ setSelectedKeys(chainMenuIdList);
3340
+ setOpendKeys(chainMenuIdList);
3341
+ return;
3342
+ }
3343
+ }
3344
+ setSelectedKeys([]);
3345
+ setOpendKeys([]);
3346
+ setSiderBarMenuActiveItem(undefined);
3347
+ };
3348
+ var onIframeChange = function onIframeChange(id, type, configs) {
3349
+ if (type === 'iframeTabClick' || type === 'iframeRefresh') {
3350
+ if (valueIsEqual(id, iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id)) {
3351
+ if (type === 'iframeTabClick' && !options.iframeTabClickRefresh) return;
3352
+ var iframeTabListNew = refreshIframeTabIframeKey(iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id);
3353
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3354
+ } else {
3355
+ var target = getIframeTabCacheList().find(function (item) {
3356
+ return valueIsEqual(item.id, id);
3357
+ });
3358
+ setIframeTabActiveItem(target);
3359
+ // const chainMenuIdList = getTargetMenuParentChain(target.menuId as string, menus);
3360
+ // console.log('chainMenuIdList', chainMenuIdList);
3361
+
3362
+ var _siderBarMenus = siderBarMenus;
3363
+ var _siderBarTileMenus = siderBarTileMenus;
3364
+ if (!options.disableTopbarMenu) {
3365
+ var topMenuItem = getTopMenuItem(target.menuId);
3366
+ /**
3367
+ * 当前 iframeTabList 是否存在 无匹配订单id的tab,例如: 未知异常页面;tab切换时,需要切换显示左侧菜单
3368
+ */
3369
+ if (iframeTabList.find(function (item) {
3370
+ return !item.menuId;
3371
+ })) {
3372
+ if (target.menuId) {
3373
+ var _topMenuActiveItem = topMenuItem;
3374
+ // if (!_topMenuActiveItem) {
3375
+ // _topMenuActiveItem = topMenuItem;
3376
+ // }
3377
+ _siderBarMenus = (_topMenuActiveItem === null || _topMenuActiveItem === void 0 ? void 0 : _topMenuActiveItem.children) || [];
3378
+ _siderBarTileMenus = treeToArray(_siderBarMenus, 'children');
3379
+ setSiderBarMenus(_siderBarMenus);
3380
+ setTopMenuActiveItem(_topMenuActiveItem);
3381
+ } else {
3382
+ _siderBarMenus = [];
3383
+ _siderBarTileMenus = [];
3384
+ if (unMatchHiddenSiderBar) {
3385
+ setSiderBarMenus(_siderBarMenus);
3386
+ }
3387
+ // 当开启顶部菜单时,找不到叶子节点,有可能找到顶部菜单
3388
+ var targetNew = parseFirstMenuByPath(menus, target === null || target === void 0 ? void 0 : target.link);
3389
+ setTopMenuActiveItem(targetNew);
3390
+ }
3391
+ } else {
3392
+ _siderBarMenus = (topMenuItem === null || topMenuItem === void 0 ? void 0 : topMenuItem.children) || [];
3393
+ _siderBarTileMenus = treeToArray(_siderBarMenus, 'children');
3394
+ setTopMenuActiveItem(topMenuItem);
3395
+ setSiderBarMenus(_siderBarMenus);
3396
+ }
3397
+ }
3398
+ onChangeSiderBarMenuActiveItem(_siderBarMenus, _siderBarTileMenus, target === null || target === void 0 ? void 0 : target.menuId);
3399
+ }
3400
+ } else if (type === 'menuClick') {
3401
+ if (valueIsEqual(id, siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.id)) {
3402
+ var refreshResult = refreshIframeTabLink(iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id, {
3403
+ link: toLinkPath(siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.link),
3404
+ name: siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.name,
3405
+ metaTitle: siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.metaTitle,
3406
+ pathSearch: siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.path
3407
+ }, getIframeTabCacheList());
3408
+ navigate(toLinkPath((siderBarMenuActiveItem === null || siderBarMenuActiveItem === void 0 ? void 0 : siderBarMenuActiveItem.path) || ''));
3409
+ setIframeTabList(_toConsumableArray(refreshResult.iframeTabList));
3410
+ setIframeTabActiveItem(extend({}, refreshResult.target));
3411
+ if (configs !== null && configs !== void 0 && configs.locationMenu) {
3412
+ onChangeSiderBarMenuActiveItem(siderBarMenus, siderBarTileMenus, id);
3413
+ }
3414
+ return;
3415
+ } else {
3416
+ var menuTarget = siderBarTileMenus.find(function (item) {
3417
+ return valueIsEqual(item.id, id);
3418
+ });
3419
+ var _addOrUpdateIframeTab2 = addOrUpdateIframeTabListByMenuItem(menuTarget, getIframeTabCacheList()),
3420
+ _iframeTabActiveItem = _addOrUpdateIframeTab2.iframeTabActiveItem,
3421
+ _iframeTabListNew = _addOrUpdateIframeTab2.iframeTabListNew;
3422
+ setIframeTabList(_toConsumableArray(_iframeTabListNew));
3423
+ setIframeTabActiveItem(_iframeTabActiveItem);
3424
+ setSiderBarMenuActiveItem(menuTarget);
3425
+ if (configs !== null && configs !== void 0 && configs.locationMenu) {
3426
+ onChangeSiderBarMenuActiveItem(siderBarMenus, siderBarTileMenus, id);
3427
+ }
3428
+ }
3429
+ }
3430
+ };
3431
+ var onDeleteIframeTabItem = function onDeleteIframeTabItem(type, id) {
3432
+ var _iframeTabActiveItemN2;
3433
+ if (type === 'otherAll') {
3434
+ setIframeTabList(iframeTabActiveItem ? [iframeTabActiveItem] : []);
3435
+ return;
3436
+ }
3437
+ var iframeTabList = getIframeTabCacheList();
3438
+ var iframeTabListNew;
3439
+ var iframeTabActiveItemNew;
3440
+ var _siderBarMenus = siderBarMenus;
3441
+ var _siderBarTileMenus = siderBarTileMenus;
3442
+ if (type === 'all') {
3443
+ iframeTabListNew = [iframeTabList[0]];
3444
+ iframeTabActiveItemNew = iframeTabList[0];
3445
+ } else if (type === 'me') {
3446
+ var index = arrayFindIndexByLoosely(iframeTabList, id, 'id');
3447
+ var nextActive = index === 0 ? iframeTabList[1] : iframeTabList[index - 1];
3448
+ iframeTabList.splice(index, 1);
3449
+ iframeTabListNew = iframeTabList;
3450
+ iframeTabActiveItemNew = nextActive;
3451
+ } else if (type === 'other') {
3452
+ var _index = arrayFindIndexByLoosely(iframeTabList, id, 'id');
3453
+ iframeTabList.splice(_index, 1);
3454
+ setIframeTabList(_toConsumableArray(iframeTabList));
3455
+ return;
3456
+ }
3457
+ if (!options.disableTopbarMenu) {
3458
+ var _iframeTabActiveItemN;
3459
+ if ((_iframeTabActiveItemN = iframeTabActiveItemNew) !== null && _iframeTabActiveItemN !== void 0 && _iframeTabActiveItemN.menuId) {
3460
+ var _topMenuActiveItem = getTopMenuItem(iframeTabActiveItemNew.menuId);
3461
+ _siderBarMenus = (_topMenuActiveItem === null || _topMenuActiveItem === void 0 ? void 0 : _topMenuActiveItem.children) || [];
3462
+ _siderBarTileMenus = treeToArray(_siderBarMenus, 'children');
3463
+ setTopMenuActiveItem(_topMenuActiveItem);
3464
+ setSiderBarMenus(_siderBarMenus);
3465
+ } else {
3466
+ _siderBarMenus = [];
3467
+ _siderBarTileMenus = [];
3468
+ setTopMenuActiveItem(undefined);
3469
+ if (unMatchHiddenSiderBar) {
3470
+ setSiderBarMenus(_siderBarMenus);
3471
+ }
3472
+ }
3473
+ }
3474
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3475
+ setIframeTabActiveItem(iframeTabActiveItemNew);
3476
+ onChangeSiderBarMenuActiveItem(_siderBarMenus, _siderBarTileMenus, (_iframeTabActiveItemN2 = iframeTabActiveItemNew) === null || _iframeTabActiveItemN2 === void 0 ? void 0 : _iframeTabActiveItemN2.menuId);
3477
+ };
3478
+
3479
+ /** 关闭当前iframe tab并打开指定iframe tab */
3480
+ var onDeleteCurrentIframeTabItemOpenTargetIframeTab = function onDeleteCurrentIframeTabItemOpenTargetIframeTab(targetId, menuId) {
3481
+ var index = arrayFindIndexByLoosely(iframeTabList, iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id, 'id');
3482
+ iframeTabList.splice(index, 1);
3483
+ if (targetId) {
3484
+ var target = arrayFindByLoosely(iframeTabList, targetId, 'id');
3485
+ if (target) {
3486
+ setIframeTabActiveItem(target);
3487
+ setIframeTabList(_toConsumableArray(iframeTabList));
3488
+ return;
3489
+ } else if (menuId) {
3490
+ var menuTarget = siderBarTileMenus.find(function (item) {
3491
+ return valueIsEqual(item.id, menuId);
3492
+ });
3493
+ var _addOrUpdateIframeTab3 = addOrUpdateIframeTabListByMenuItem(menuTarget, iframeTabList),
3494
+ _iframeTabActiveItem2 = _addOrUpdateIframeTab3.iframeTabActiveItem,
3495
+ iframeTabListNew = _addOrUpdateIframeTab3.iframeTabListNew;
3496
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3497
+ setIframeTabActiveItem(_iframeTabActiveItem2);
3498
+ setSiderBarMenuActiveItem(menuTarget);
3499
+ return;
3500
+ }
3501
+ }
3502
+ setIframeTabList(_toConsumableArray(iframeTabList));
3503
+ onIframeChange(iframeTabList[0].id, 'iframeTabClick');
3504
+ };
3505
+ var onIframeChangeByHttpUrl = function onIframeChangeByHttpUrl(url, data) {
3506
+ var prevIframeTabActiveItem = cloneObject(iframeTabActiveItem);
3507
+ var cahceTabList = getIframeTabCacheList();
3508
+ var _parseIframeTabItemUr = parseIframeTabItemUrlInfo(url),
3509
+ pathSearch = _parseIframeTabItemUr.pathSearch;
3510
+ var iframeTablink = guessIframeTabItemLink(url);
3511
+ var siderbarTargetMenu = parseSiderTargetMenuByPath(tileMenus, url);
3512
+ if (siderbarTargetMenu) {
3513
+ var chainMenuIdList = getTargetMenuParentChain(siderbarTargetMenu.id, menus);
3514
+ if (chainMenuIdList.length > 0) {
3515
+ var parentId = chainMenuIdList[chainMenuIdList.length - 1];
3516
+ var targetTopMenuItem = menus.find(function (item) {
3517
+ return valueIsEqual(item.id, parentId);
3518
+ });
3519
+ setSiderBarMenuActiveItem(siderbarTargetMenu);
3520
+ setSelectedKeys(chainMenuIdList);
3521
+ setOpendKeys(chainMenuIdList);
3522
+ if (!options.disableTopbarMenu) {
3523
+ setSiderBarMenus((targetTopMenuItem === null || targetTopMenuItem === void 0 ? void 0 : targetTopMenuItem.children) || []);
3524
+ setTopMenuActiveItem(targetTopMenuItem);
3525
+ }
3526
+ }
3527
+ var _addOrUpdateIframeTab4 = addOrUpdateIframeTabListByMenuItem(_objectSpread2(_objectSpread2({}, siderbarTargetMenu), {}, {
3528
+ link: iframeTablink,
3529
+ name: data.name,
3530
+ metaTitle: data.metaTitle
3531
+ }), cahceTabList),
3532
+ _iframeTabActiveItem3 = _addOrUpdateIframeTab4.iframeTabActiveItem,
3533
+ iframeTabListNew = _addOrUpdateIframeTab4.iframeTabListNew;
3534
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3535
+ setIframeTabActiveItem(_iframeTabActiveItem3);
3536
+ saveIframeOpenNewTabItemOperateLink({
3537
+ startTabId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.id,
3538
+ startTabMenuId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.menuId,
3539
+ endTabId: _iframeTabActiveItem3.id
3540
+ });
3541
+ } else {
3542
+ setSelectedKeys([]);
3543
+ setOpendKeys([]);
3544
+ if (unMatchHiddenSiderBar) {
3545
+ setSiderBarMenus([]);
3546
+ }
3547
+ setTopMenuActiveItem(undefined);
3548
+ setSiderBarMenuActiveItem(undefined);
3549
+ var target = findIframeTabItemByEqualUrl(iframeTablink, cahceTabList);
3550
+ if (target) {
3551
+ setIframeTabActiveItem(target);
3552
+ saveIframeOpenNewTabItemOperateLink({
3553
+ startTabId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.id,
3554
+ startTabMenuId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.menuId,
3555
+ endTabId: target.id
3556
+ });
3557
+ } else {
3558
+ var _addIframeTabListByMe = addIframeTabListByMenuItem(cahceTabList, {
3559
+ link: iframeTablink,
3560
+ name: getIframeTabName(iframeTablink, (data === null || data === void 0 ? void 0 : data.name) || '未知页面'),
3561
+ metaTitle: options === null || options === void 0 ? void 0 : options.metaTitle,
3562
+ pathSearch: pathSearch
3563
+ }),
3564
+ _iframeTabListNew2 = _addIframeTabListByMe.iframeTabListNew,
3565
+ _iframeTabActiveItem4 = _addIframeTabListByMe.iframeTabActiveItem;
3566
+ setIframeTabList(_toConsumableArray(_iframeTabListNew2));
3567
+ setIframeTabActiveItem(_iframeTabActiveItem4);
3568
+ saveIframeOpenNewTabItemOperateLink({
3569
+ startTabId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.id,
3570
+ startTabMenuId: prevIframeTabActiveItem === null || prevIframeTabActiveItem === void 0 ? void 0 : prevIframeTabActiveItem.menuId,
3571
+ endTabId: _iframeTabActiveItem4.id
3572
+ });
3573
+ }
3574
+ }
3575
+ };
3576
+ var onUpdateIframeTabName = function onUpdateIframeTabName(name) {
3577
+ var target = getIframeTabCacheList().find(function (item) {
3578
+ return valueIsEqual(item.id, iframeTabActiveItem === null || iframeTabActiveItem === void 0 ? void 0 : iframeTabActiveItem.id);
3579
+ });
3580
+ if (target) {
3581
+ target.name = name;
3582
+ setIframeTabList(getIframeTabCacheList());
3583
+ }
3584
+ };
3585
+ var normalModePositionMenu = function normalModePositionMenu(link) {
3586
+ var siderbarTargetMenu = parseSiderTargetMenuByPath(tileMenus, link);
3587
+ if (siderbarTargetMenu) {
3588
+ var chainMenuIdList = getTargetMenuParentChain(siderbarTargetMenu.id, menus);
3589
+ setSelectedKeys(chainMenuIdList);
3590
+ setOpendKeys(chainMenuIdList);
3591
+ setSiderBarMenuActiveItem(siderbarTargetMenu);
3592
+ document.title = siderbarTargetMenu.metaTitle || siderbarTargetMenu.name;
3593
+ } else {
3594
+ if (options.disableTopbarMenu) {
3595
+ setSelectedKeys([]);
3596
+ setOpendKeys([]);
3597
+ setSiderBarMenuActiveItem(undefined);
3598
+ }
3599
+ }
3600
+ };
3601
+ var iframeTopRouteMenuChange = function iframeTopRouteMenuChange(item) {
3602
+ var leafNode = findFirstLeafNode(item);
3603
+ var _addOrUpdateIframeTab5 = addOrUpdateIframeTabListByMenuItem(leafNode, getIframeTabCacheList()),
3604
+ iframeTabActiveItem = _addOrUpdateIframeTab5.iframeTabActiveItem,
3605
+ iframeTabListNew = _addOrUpdateIframeTab5.iframeTabListNew;
3606
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3607
+ setIframeTabActiveItem(iframeTabActiveItem);
3608
+ if (leafNode) {
3609
+ var chainMenuIdList = getTargetMenuParentChain(leafNode.id, menus);
3610
+ setSiderBarMenuActiveItem(leafNode);
3611
+ setSelectedKeys(chainMenuIdList);
3612
+ setOpendKeys(chainMenuIdList);
3613
+ }
3614
+ setSiderBarMenus(item.children || []);
3615
+ setTopMenuActiveItem(item);
3616
+ };
3617
+
3618
+ /**
3619
+ * 通过新iframe tab打开第三方菜单页面
3620
+ */
3621
+ var onOpenNewIframeThirdMenuItem = function onOpenNewIframeThirdMenuItem(data) {
3622
+ var menuItem = data.menuItem;
3623
+ // 判断 iframeTabList 中是否存在于 data.link 完全相同
3624
+ var hasTarget = iframeTabList.find(function (item) {
3625
+ return linkEqual(item.link, data.link);
3626
+ });
3627
+ if (hasTarget) {
3628
+ onIframeChange("".concat(hasTarget.id), 'iframeTabClick');
3629
+ } else {
3630
+ onChangeSiderBarMenuActiveItem(siderBarMenus, siderBarTileMenus, "".concat(menuItem.id));
3631
+ var _addIframeTabListByMe2 = addIframeTabListByMenuItem(iframeTabList, _objectSpread2(_objectSpread2({}, menuItem), {}, {
3632
+ name: data.name,
3633
+ link: data.link
3634
+ })),
3635
+ iframeTabListNew = _addIframeTabListByMe2.iframeTabListNew,
3636
+ _iframeTabActiveItem5 = _addIframeTabListByMe2.iframeTabActiveItem;
3637
+ setIframeTabList(_toConsumableArray(iframeTabListNew));
3638
+ setIframeTabActiveItem(_iframeTabActiveItem5);
3639
+ }
3640
+ };
3641
+ var appProviderValue = _objectSpread2(_objectSpread2({}, options), {}, {
3642
+ hideSidebarMenu: hideSidebarMenu,
3643
+ menus: menus,
3644
+ completeMenus: completeMenus,
3645
+ siderBarMenus: siderBarMenus,
3646
+ siderBarTileMenus: siderBarTileMenus,
3647
+ sidebarWidth: sidebarWidth,
3648
+ componentSize: componentSize,
3649
+ locale: locale,
3650
+ routeList: options.routeList,
3651
+ breads: options.breads || {},
3652
+ logoPath: logoPath,
3653
+ headerThemeConfig: headerThemeConfig,
3654
+ sidebarThemeConfig: sidebarThemeConfig,
3655
+ collapsed: collapsed,
3656
+ onChangeCollapsed: onChangeCollapsed,
3657
+ opendKeys: opendKeys,
3658
+ selectedKeys: selectedKeys,
3659
+ onChangeOpendKeys: onChangeOpendKeys,
3660
+ onChangeSelectedKeys: onChangeSelectedKeys,
3661
+ iframeTabList: iframeTabList,
3662
+ addOrUpdateIframeTab: addOrUpdateIframeTab,
3663
+ iframeTabActiveItem: iframeTabActiveItem,
3664
+ siderBarMenuActiveItem: siderBarMenuActiveItem,
3665
+ onIframeChange: onIframeChange,
3666
+ onDeleteIframeTabItem: onDeleteIframeTabItem,
3667
+ onIframeChangeByHttpUrl: onIframeChangeByHttpUrl,
3668
+ topMenuActiveItem: topMenuActiveItem,
3669
+ onUpdateIframeTabName: onUpdateIframeTabName,
3670
+ normalModePositionMenu: normalModePositionMenu,
3671
+ iframeTopRouteMenuChange: iframeTopRouteMenuChange,
3672
+ onDeleteCurrentIframeTabItemOpenTargetIframeTab: onDeleteCurrentIframeTabItemOpenTargetIframeTab,
3673
+ onOpenNewIframeThirdMenuItem: onOpenNewIframeThirdMenuItem
3674
+ });
3675
+ return /*#__PURE__*/jsxs(LayoutProvider, {
3676
+ value: appProviderValue,
3677
+ children: [options.disableErrorHandling ? null : /*#__PURE__*/jsx(ErrorHandlingRender, {
3678
+ verifySessionExpired: appProviderValue.verifySessionExpired
3679
+ }), /*#__PURE__*/jsx(App, {}), !isIframeMain && /*#__PURE__*/jsx(NormalRoutesTiming, {})]
3680
+ });
3681
+ };
3682
+
3683
+ var changedArray = function changedArray() {
3684
+ var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3685
+ var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
3686
+ return a.length !== b.length || a.some(function (item, index) {
3687
+ return !Object.is(item, b[index]);
3688
+ });
3689
+ };
3690
+ var initialState = {
3691
+ error: null
3692
+ };
3693
+ var ErrorBoundary = /*#__PURE__*/function (_Component) {
3694
+ function ErrorBoundary() {
3695
+ var _this;
3696
+ _classCallCheck(this, ErrorBoundary);
3697
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
3698
+ _args[_key] = arguments[_key];
3699
+ }
3700
+ _this = _callSuper(this, ErrorBoundary, [].concat(_args));
3701
+ _defineProperty(_this, "state", initialState);
3702
+ _defineProperty(_this, "updatedWithError", false);
3703
+ _defineProperty(_this, "resetErrorBoundary", function () {
3704
+ var _this$props$onReset, _this$props;
3705
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3706
+ args[_key2] = arguments[_key2];
3707
+ }
3708
+ (_this$props$onReset = (_this$props = _this.props).onReset) === null || _this$props$onReset === void 0 || _this$props$onReset.call.apply(_this$props$onReset, [_this$props].concat(args));
3709
+ _this.reset();
3710
+ });
3711
+ return _this;
3712
+ }
3713
+ _inherits(ErrorBoundary, _Component);
3714
+ return _createClass(ErrorBoundary, [{
3715
+ key: "reset",
3716
+ value: function reset() {
3717
+ this.updatedWithError = false;
3718
+ this.setState(initialState);
3719
+ }
3720
+ }, {
3721
+ key: "componentDidCatch",
3722
+ value: function componentDidCatch(error, info) {
3723
+ var _this$props$onError, _this$props2;
3724
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 || _this$props$onError.call(_this$props2, error, info);
3725
+ }
3726
+ }, {
3727
+ key: "componentDidMount",
3728
+ value: function componentDidMount() {
3729
+ var error = this.state.error;
3730
+ if (error !== null) {
3731
+ this.updatedWithError = true;
3732
+ }
3733
+ }
3734
+ }, {
3735
+ key: "componentDidUpdate",
3736
+ value: function componentDidUpdate(prevProps) {
3737
+ var error = this.state.error;
3738
+ var resetKeys = this.props.resetKeys;
3739
+
3740
+ // There's an edge case where if the thing that triggered the error
3741
+ // happens to *also* be in the resetKeys array, we'd end up resetting
3742
+ // the error boundary immediately. This would likely trigger a second
3743
+ // error to be thrown.
3744
+ // So we make sure that we don't check the resetKeys on the first call
3745
+ // of cDU after the error is set
3746
+ if (error !== null && !this.updatedWithError) {
3747
+ this.updatedWithError = true;
3748
+ return;
3749
+ }
3750
+ if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
3751
+ var _this$props$onResetKe, _this$props3;
3752
+ (_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) === null || _this$props$onResetKe === void 0 || _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
3753
+ this.reset();
3754
+ }
3755
+ }
3756
+ }, {
3757
+ key: "render",
3758
+ value: function render() {
3759
+ var error = this.state.error;
3760
+ // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)
3761
+ var _this$props4 = this.props,
3762
+ fallbackRender = _this$props4.fallbackRender,
3763
+ FallbackComponent = _this$props4.FallbackComponent,
3764
+ fallback = _this$props4.fallback;
3765
+ if (error !== null) {
3766
+ var _props = {
3767
+ error: error,
3768
+ resetErrorBoundary: this.resetErrorBoundary
3769
+ };
3770
+ if (/*#__PURE__*/isValidElement(fallback)) {
3771
+ return fallback;
3772
+ } else if (typeof fallbackRender === 'function') {
3773
+ return fallbackRender(_props);
3774
+ } else if (FallbackComponent) {
3775
+ return /*#__PURE__*/jsx(FallbackComponent, _objectSpread2({}, _props));
3776
+ } else {
3777
+ throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
3778
+ }
3779
+ }
3780
+ return this.props.children;
3781
+ }
3782
+ }], [{
3783
+ key: "getDerivedStateFromError",
3784
+ value: function getDerivedStateFromError(error) {
3785
+ return {
3786
+ error: error
3787
+ };
3788
+ }
3789
+ }]);
3790
+ }(Component);
3791
+
3792
+ // export function withErrorBoundary<P>(
3793
+ // Component: ComponentType<P>,
3794
+ // errorBoundaryProps: ErrorBoundaryProps,
3795
+ // ): ComponentType<P> {
3796
+ // const Wrapped: ComponentType<P> = (props) => {
3797
+ // return (
3798
+ // <ErrorBoundary {...errorBoundaryProps}>
3799
+ // <Component {...props} />
3800
+ // </ErrorBoundary>
3801
+ // );
3802
+ // };
3803
+
3804
+ // // Format for display in DevTools
3805
+ // const name = Component.displayName || Component.name || 'Unknown';
3806
+ // Wrapped.displayName = `withErrorBoundary(${name})`;
3807
+
3808
+ // return Wrapped;
3809
+ // }
3810
+
3811
+ // export function useErrorHandler<P = Error>(
3812
+ // givenError?: P | null | undefined,
3813
+ // ): Dispatch<SetStateAction<P | null>> {
3814
+ // const [error, setError] = useState<P | null>(null);
3815
+ // if (givenError) throw givenError;
3816
+ // if (error) throw error;
3817
+ // return setError;
3818
+ // }
3819
+
3820
+ function ErrorFallback(_ref) {
3821
+ var error = _ref.error;
3822
+ return /*#__PURE__*/jsx("div", {
3823
+ style: {
3824
+ height: '100%',
3825
+ padding: '8px'
3826
+ },
3827
+ children: /*#__PURE__*/jsxs("div", {
3828
+ style: {
3829
+ backgroundColor: '#fff',
3830
+ height: '100%',
3831
+ padding: '0 8px 8px 8px',
3832
+ overflow: 'hidden'
3833
+ },
3834
+ children: [/*#__PURE__*/jsx(Typography.Title, {
3835
+ level: 2,
3836
+ children: "Something went wrong"
3837
+ }), /*#__PURE__*/jsx(Typography.Paragraph, {
3838
+ children: error.message
3839
+ }), /*#__PURE__*/jsx(Button, {
3840
+ onClick: function onClick() {
3841
+ window.location.reload();
3842
+ },
3843
+ children: "Try again"
3844
+ })]
3845
+ })
3846
+ });
3847
+ }
3848
+
3849
+ var Container = function Container(props) {
3850
+ useEffect(function () {
3851
+ window.addEventListener('message', function (event) {
3852
+ var _event$data;
3853
+ if ((event === null || event === void 0 || (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.flatOssIframeType) === 'reload') {
3854
+ window.location.reload();
3855
+ }
3856
+ });
3857
+ }, []);
3858
+ if (!props.ignoreMenuEmptyJudge && (props.layoutMode === 'iframe-main' || props.layoutMode === 'normal') && props.menus.length === 0) {
3859
+ if (props.MenuEmptyRender) return props.MenuEmptyRender;
3860
+ return /*#__PURE__*/jsx(Result, {
3861
+ status: "error",
3862
+ title: "\u65E0\u83DC\u5355\u6570\u636E",
3863
+ subTitle: '请联系运营人员确定菜单数据配置'
3864
+ });
3865
+ }
3866
+ return /*#__PURE__*/jsx(Fragment, {
3867
+ children: props.children
3868
+ });
3869
+ };
3870
+
3871
+ var IframeMainRegister = function IframeMainRegister() {
3872
+ var iframeApi = useIframe(function (data) {
3873
+ if (data.type === '__refresh-iframe-tab') {
3874
+ iframeApi.broadcastMessages({
3875
+ type: data.type,
3876
+ data: data.data
3877
+ });
3878
+ }
3879
+ });
3880
+ return /*#__PURE__*/jsx(Fragment, {});
3881
+ };
3882
+
3883
+ var defaultState = {
3884
+ isDark: undefined
3885
+ };
3886
+ var ProLayoutModel = {
3887
+ actions: {
3888
+ onSetTheme: function onSetTheme(theme) {
3889
+ return new Promise(function ($return, $error) {
3890
+ return $return(function (state) {
3891
+ state.isDark = theme === 'dark';
3892
+ });
3893
+ });
3894
+ }
3895
+ },
3896
+ state: defaultState
3897
+ };
3898
+ var proLayoutModels = Model({
3899
+ ProLayoutModel: ProLayoutModel
3900
+ });
3901
+
3902
+ var Bootstrap = function Bootstrap(options) {
3903
+ var _options$headerThemeC, _options$headerThemeC2, _options$headerThemeC3, _options$sidebarTheme, _options$sidebarTheme2, _options$sidebarTheme3;
3904
+ var _proLayoutModels$useS = proLayoutModels.useStore('ProLayoutModel'),
3905
+ _proLayoutModels$useS2 = _slicedToArray(_proLayoutModels$useS, 1),
3906
+ state = _proLayoutModels$useS2[0];
3907
+ var isDark = state.isDark === undefined ? options.initDark : state.isDark;
3908
+ var globalValue = getGlobalData();
3909
+ var sidebarWidth = options.sidebarWidth || 220;
3910
+ var componentSize = options.componentSize || 'middle';
3911
+ var locale = options.locale;
3912
+ var logoPath = options.logoPath || '';
3913
+ var isIframeMain = options.layoutMode === 'iframe-main';
3914
+ var isIframeTabItem = options.layoutMode === 'iframe-tab';
3915
+ var headerThemeConfig = {
3916
+ bgColor: '#1890ff',
3917
+ textColor: '#fff',
3918
+ menuColor: '#fff',
3919
+ menuActiveTextColor: '#FFF',
3920
+ menuSelectedBgColor: '#0080e3',
3921
+ menuSelectedTextColor: '#FFF',
3922
+ menuTextFontSize: 14
3923
+ };
3924
+ var sidebarThemeConfig = {
3925
+ bgColor: '#fff',
3926
+ menuActiveBgColor: 'rgba(0,0,0,0.06)',
3927
+ menuActiveTextColor: '#1890ff',
3928
+ menuSelectedBgColor: '#bae0ff',
3929
+ menuColor: 'rgba(0,0,0,.88)',
3930
+ menuSelectedTextColor: '#1890ff',
3931
+ menuSubMenuBgColor: 'rgba(0, 0, 0, 0.02)',
3932
+ inlineIndent: 16,
3933
+ menuItemHeight: 28,
3934
+ menuTextFontSize: 13
3935
+ };
3936
+ var customHeaderThemeConfig = (_options$headerThemeC = options.headerThemeConfig) !== null && _options$headerThemeC !== void 0 && _options$headerThemeC['dark'] || (_options$headerThemeC2 = options.headerThemeConfig) !== null && _options$headerThemeC2 !== void 0 && _options$headerThemeC2['light'] ? (_options$headerThemeC3 = options.headerThemeConfig) === null || _options$headerThemeC3 === void 0 ? void 0 : _options$headerThemeC3[isDark ? 'dark' : 'light'] : options.headerThemeConfig;
3937
+ var headerThemeConfigNew = extend({}, headerThemeConfig, customHeaderThemeConfig);
3938
+ var customSidebarThemeConfig = (_options$sidebarTheme = options.sidebarThemeConfig) !== null && _options$sidebarTheme !== void 0 && _options$sidebarTheme['dark'] || (_options$sidebarTheme2 = options.sidebarThemeConfig) !== null && _options$sidebarTheme2 !== void 0 && _options$sidebarTheme2['light'] ? (_options$sidebarTheme3 = options.sidebarThemeConfig) === null || _options$sidebarTheme3 === void 0 ? void 0 : _options$sidebarTheme3[isDark ? 'dark' : 'light'] : options.sidebarThemeConfig;
3939
+ var sidebarThemeConfigNew = extend({}, sidebarThemeConfig, customSidebarThemeConfig);
3940
+ var iframeTabClickRefresh = isUndefinedOrNull(options.iframeTabClickRefresh) ? true : options.iframeTabClickRefresh;
3941
+ var _useMemo = useMemo(function () {
3942
+ var routeList = function () {
3943
+ if (!globalData.moduleName) {
3944
+ console.error('请在window.GLOBAL中添加属性moduleName(模块名称,例如:moduleName="system/admin")');
3945
+ return options.routeList;
3946
+ }
3947
+ var moduleName = removeSlash(globalData.moduleName, 'before-after');
3948
+ var routeListNew = [];
3949
+ options.routeList.forEach(function (item) {
3950
+ var path = removeSlash(item.path, 'before-after');
3951
+ var redirect = removeSlash(item.redirect || '', 'before-after');
3952
+ if (redirect) {
3953
+ item.redirect = redirect.startsWith(moduleName) ? item.redirect : "/".concat(urlJoin(moduleName, item.redirect || ''));
3954
+ }
3955
+ if (item.path === '/' || path === '') {
3956
+ routeListNew.push(_objectSpread2(_objectSpread2({}, item), {}, {
3957
+ path: "/".concat(urlJoin(moduleName, item.path))
3958
+ }));
3959
+ } else if (path === '*') {
3960
+ routeListNew.push(_objectSpread2(_objectSpread2({}, item), {}, {
3961
+ path: "/*"
3962
+ }));
3963
+ } else if (!path.startsWith(moduleName)) {
3964
+ routeListNew.push(_objectSpread2(_objectSpread2({}, item), {}, {
3965
+ path: "/".concat(urlJoin(moduleName, item.path))
3966
+ }));
3967
+ } else {
3968
+ routeListNew.push(item);
3969
+ }
3970
+ });
3971
+ return routeListNew;
3972
+ }();
3973
+ var breadList = [];
3974
+ routeList.forEach(function (item) {
3975
+ if (item.breadConfig) {
3976
+ if (typeof item.breadConfig === 'string') {
3977
+ breadList.push({
3978
+ path: item.path,
3979
+ breadConfig: {
3980
+ name: item.breadConfig
3981
+ }
3982
+ });
3983
+ return;
3984
+ }
3985
+ if (isArray(item.breadConfig)) {
3986
+ var dataList = item.breadConfig;
3987
+ dataList.forEach(function (innItem) {
3988
+ var mergePath = removeSlash(urlJoin(item.path, innItem.path).replace('/*', '').replace('*', ''), 'before-after');
3989
+ if (typeof innItem.breadConfig === 'string') {
3990
+ breadList.push({
3991
+ path: "/".concat(mergePath),
3992
+ breadConfig: {
3993
+ name: innItem.breadConfig
3994
+ }
3995
+ });
3996
+ return;
3997
+ }
3998
+ breadList.push({
3999
+ path: "/".concat(mergePath),
4000
+ breadConfig: innItem.breadConfig
4001
+ });
4002
+ });
4003
+ return;
4004
+ }
4005
+ breadList.push({
4006
+ path: item.path,
4007
+ breadConfig: item.breadConfig
4008
+ });
4009
+ }
4010
+ });
4011
+ if (getQueryString('debug')) {
4012
+ console.log('bootstrap routeList original', options.routeList);
4013
+ console.log('bootstrap routeList', routeList);
4014
+ console.log('bootstrap breadList', breadList);
4015
+ }
4016
+ return {
4017
+ routeList: routeList,
4018
+ breadList: breadList
4019
+ };
4020
+ }, [options.routeList]),
4021
+ routeList = _useMemo.routeList,
4022
+ breadList = _useMemo.breadList;
4023
+ var _getMenus = getMenus(isIframeMain || isIframeTabItem, options.siderBarMaxMenuLevel, options.disableTopbarMenu),
4024
+ menus = _getMenus.menus,
4025
+ completeMenus = _getMenus.completeMenus;
4026
+ var appProviderValue = _objectSpread2(_objectSpread2({}, options), {}, {
4027
+ sidebarWidth: sidebarWidth,
4028
+ componentSize: componentSize,
4029
+ locale: locale,
4030
+ routeList: routeList,
4031
+ breads: breadList,
4032
+ logoPath: logoPath,
4033
+ headerThemeConfig: headerThemeConfigNew,
4034
+ sidebarThemeConfig: sidebarThemeConfigNew,
4035
+ iframeTabClickRefresh: iframeTabClickRefresh,
4036
+ headerHeight: options.headerHeight === undefined ? 64 : options.headerHeight,
4037
+ menus: menus,
4038
+ completeMenus: completeMenus,
4039
+ dark: isDark
4040
+ });
4041
+
4042
+ // const root = createRoot(document.getElementById('app') as HTMLElement);
4043
+ var layoutMode = appProviderValue.layoutMode;
4044
+ var isNoLayout = ['no-layout', 'iframe-tab'].includes(layoutMode);
4045
+ var ContainerWrapper = options.containerWrapper || Fragment;
4046
+ var configProviderProps = useMemo(function () {
4047
+ var _options$configProvid, _options$configProvid2;
4048
+ 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;
4049
+ var algorithmArray = toArray(algorithm);
4050
+ algorithmArray = [].concat(_toConsumableArray(algorithmArray), [isDark ? theme.darkAlgorithm : null, options.compact ? theme.compactAlgorithm : null]).filter(Boolean);
4051
+ return _objectSpread2(_objectSpread2({}, options.configProviderProps), {}, {
4052
+ theme: _objectSpread2(_objectSpread2({}, (_options$configProvid2 = options.configProviderProps) === null || _options$configProvid2 === void 0 ? void 0 : _options$configProvid2.theme), {}, {
4053
+ algorithm: algorithmArray
4054
+ })
4055
+ });
4056
+ }, [isDark, options.compact, options.configProviderProps]);
4057
+ return /*#__PURE__*/jsx(ConfigProviderWrapper, _objectSpread2(_objectSpread2({
4058
+ locale: locale,
4059
+ componentSize: componentSize,
4060
+ space: {
4061
+ size: componentSize
4062
+ }
4063
+ }, configProviderProps), {}, {
4064
+ children: /*#__PURE__*/jsx(ContainerWrapper, {
4065
+ children: /*#__PURE__*/jsx(BrowserRouter, {
4066
+ basename: globalValue.routeBaseName,
4067
+ children: /*#__PURE__*/jsx(BootstrapCtx, {
4068
+ value: {
4069
+ breads: breadList,
4070
+ breadTitle: appProviderValue.breadTitle,
4071
+ breadcrumbProps: appProviderValue.breadcrumbProps
4072
+ },
4073
+ children: /*#__PURE__*/jsx(AntdAppWrapper, {
4074
+ appProviderValue: appProviderValue,
4075
+ children: /*#__PURE__*/jsx(FbaApp, {
4076
+ children: /*#__PURE__*/jsxs(ErrorBoundary, {
4077
+ onError: options.onError,
4078
+ onReset: options.onErrorReset,
4079
+ FallbackComponent: options.ErrorFallback || ErrorFallback,
4080
+ children: [layoutMode === 'iframe-main' ? /*#__PURE__*/jsx(IframeMainRegister, {}) : null, /*#__PURE__*/jsx(Container, {
4081
+ layoutMode: appProviderValue.layoutMode,
4082
+ MenuEmptyRender: appProviderValue.MenuEmptyRender,
4083
+ menus: menus,
4084
+ ignoreMenuEmptyJudge: appProviderValue.ignoreMenuEmptyJudge,
4085
+ children: isNoLayout ? /*#__PURE__*/jsx(AppNoLayout, {
4086
+ verifySessionExpired: appProviderValue.verifySessionExpired,
4087
+ routeList: routeList,
4088
+ layoutMode: layoutMode,
4089
+ LayoutComponent: appProviderValue.LayoutComponent,
4090
+ breadExtendRender: appProviderValue.breadExtendRender,
4091
+ breads: appProviderValue.breads,
4092
+ hideDefaultBread: appProviderValue.hideDefaultBread,
4093
+ hideHeader: appProviderValue.hideHeader,
4094
+ breadTitle: appProviderValue.breadTitle,
4095
+ disableErrorHandling: appProviderValue.disableErrorHandling,
4096
+ ErrorHandling: appProviderValue.ErrorHandling,
4097
+ iframeTabAloneView: appProviderValue.iframeTabAloneView,
4098
+ layoutPageClassName: appProviderValue.layoutPageClassName
4099
+ }) : /*#__PURE__*/jsx(AppProvider, _objectSpread2({}, appProviderValue))
4100
+ })]
4101
+ })
4102
+ })
4103
+ })
4104
+ })
4105
+ })
4106
+ })
4107
+ }));
4108
+ };
4109
+
4110
+ /**
4111
+ * ```
4112
+ * 1. 外部针对出现 iframe tab标题为未知页面的配置、或者想修改二级页面tab标题的,在main模块中设置
4113
+ * window['_iframeTabConfig'] = {
4114
+ * '/system-get/menu3/detail': {
4115
+ * name: '详情',
4116
+ * },
4117
+ * };
4118
+ * 2. 在后续版本中会废弃`全局拦截model异常处理功能`,废弃ErrorHandling、onSessionExpired、verifySessionExpired三个属性的使用
4119
+ * ```
4120
+ */
4121
+ var bootstrap = function bootstrap(options) {
4122
+ var root = createRoot(document.getElementById('app'));
4123
+ root.render(/*#__PURE__*/jsx(Bootstrap, _objectSpread2({}, options)));
4124
+ };
4125
+
4126
+ export { Bread, HistoryBackButton, LayoutPage, Page, PageWrapper, ProLayoutModel, bootstrap, message, modal, notification, proLayoutModels, useHistoryBack, useIframe, usePageWrapper, useRefreshRegisterIframeTab, useRegisterRefreshCurrentIframeTab };
4127
+ //# sourceMappingURL=index.js.map