@bit-sun/business-component 2.3.9 → 2.3.10-alpha.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.esm.js CHANGED
@@ -15692,6 +15692,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
15692
15692
  _this.allFunc = /*#__PURE__*/createRef('');
15693
15693
  _this.customerMenuRef = /*#__PURE__*/createRef('');
15694
15694
  _this.actionRef = /*#__PURE__*/createRef();
15695
+ _this.handleBeforeUnload = function () {
15696
+ // 储存当前router信息
15697
+ sessionStorage.setItem('@listenRouterState', JSON.stringify(_this.state.listenRouterState));
15698
+ };
15695
15699
  _this.parseQueryString = function (queryString) {
15696
15700
  if (!queryString) {
15697
15701
  return '';
@@ -16095,15 +16099,49 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16095
16099
  },
16096
16100
  currentSubMenuData: [],
16097
16101
  showSubMenu: false,
16098
- isSlider: false
16102
+ isSlider: false,
16103
+ _routerArray: routerArray
16099
16104
  };
16100
16105
  return _this;
16101
16106
  }
16102
16107
  _createClass(BasicLayout, [{
16108
+ key: "componentWillMount",
16109
+ value: function componentWillMount() {
16110
+ var _this2 = this;
16111
+ // 检查页面是否为刷新之后的
16112
+ if (sessionStorage.getItem('@listenRouterState')) {
16113
+ var lastListenRouterState = JSON.parse(sessionStorage.getItem('@listenRouterState')),
16114
+ showListenRouterState = [],
16115
+ nowItem = {};
16116
+ if (lastListenRouterState.length === 1) {
16117
+ sessionStorage.removeItem('@listenRouterState');
16118
+ return;
16119
+ }
16120
+ lastListenRouterState.forEach(function (item) {
16121
+ var _this2$state;
16122
+ nowItem = _this2 === null || _this2 === void 0 ? void 0 : (_this2$state = _this2.state) === null || _this2$state === void 0 ? void 0 : _this2$state._routerArray.find(function (i) {
16123
+ var _item$match;
16124
+ return item.key === i.key || (item === null || item === void 0 ? void 0 : item.match) && (item === null || item === void 0 ? void 0 : (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.path) === i.key;
16125
+ });
16126
+ // 详情页保留问题尚未解决
16127
+ if (nowItem) {
16128
+ showListenRouterState.push(_objectSpread2(_objectSpread2({}, item), {}, {
16129
+ content: nowItem.content,
16130
+ tab: item.tab || _this2.getPageTitle(nowItem.key)
16131
+ }));
16132
+ }
16133
+ });
16134
+ this.setState({
16135
+ listenRouterState: [].concat(showListenRouterState)
16136
+ });
16137
+ sessionStorage.removeItem('@listenRouterState');
16138
+ }
16139
+ }
16140
+ }, {
16103
16141
  key: "componentDidMount",
16104
16142
  value: function componentDidMount() {
16105
16143
  var _window$$wujie,
16106
- _this2 = this,
16144
+ _this3 = this,
16107
16145
  _localStorage$getItem,
16108
16146
  _localStorage$getItem2;
16109
16147
  var _this$props = this.props,
@@ -16153,11 +16191,11 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16153
16191
  // if (window.location.href.indexOf(`/${itemPath}`) === -1) return;
16154
16192
  // }
16155
16193
  if (route.pathname.startsWith("/".concat(itemPath, "/"))) return;
16156
- var _this2$state = _this2.state,
16157
- listenRouterState = _this2$state.listenRouterState,
16158
- listenRouterKey = _this2$state.listenRouterKey,
16159
- customerMatchs = _this2$state.customerMatchs,
16160
- hideMenuArray = _this2$state.hideMenuArray;
16194
+ var _this3$state = _this3.state,
16195
+ listenRouterState = _this3$state.listenRouterState,
16196
+ listenRouterKey = _this3$state.listenRouterKey,
16197
+ customerMatchs = _this3$state.customerMatchs,
16198
+ hideMenuArray = _this3$state.hideMenuArray;
16161
16199
  var newListenRouterState = _toConsumableArray(listenRouterState);
16162
16200
  var newListenRouterKey = _toConsumableArray(listenRouterKey);
16163
16201
  var replaceRouter = routerArray.filter(function (itemRoute) {
@@ -16168,7 +16206,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16168
16206
  // 处理中英文和特殊字符
16169
16207
  currentKey = decodeURIComponent(route.pathname);
16170
16208
  } else {
16171
- currentKey = decodeURIComponent(route.pathname + _this2.parseQueryString(route.search));
16209
+ currentKey = decodeURIComponent(route.pathname + _this3.parseQueryString(route.search));
16172
16210
  }
16173
16211
  if (!istParent) {
16174
16212
  var _window$$wujie2;
@@ -16188,7 +16226,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16188
16226
  replaceRouter = (_routerArray$filter = routerArray.filter(function (itemroute) {
16189
16227
  return itemroute.key === '/404';
16190
16228
  })) === null || _routerArray$filter === void 0 ? void 0 : _routerArray$filter[0];
16191
- _this2.setState({
16229
+ _this3.setState({
16192
16230
  listenRouterState: [].concat(_toConsumableArray(listenRouterState), [_objectSpread2(_objectSpread2({}, replaceRouter), {}, {
16193
16231
  key: currentKey,
16194
16232
  tab: '404'
@@ -16196,7 +16234,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16196
16234
  activeKey: currentKey,
16197
16235
  listenRouterKey: [].concat(_toConsumableArray(listenRouterKey), [currentKey])
16198
16236
  }, function () {
16199
- _this2.checkisNavSlide();
16237
+ _this3.checkisNavSlide();
16200
16238
  });
16201
16239
  } else {
16202
16240
  var match = matchPath(route.pathname, {
@@ -16206,7 +16244,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16206
16244
  query: route.query,
16207
16245
  match: match,
16208
16246
  key: currentKey,
16209
- tab: _this2.getPageTitle(route.pathname) + ''
16247
+ tab: _this3.getPageTitle(route.pathname) + ''
16210
16248
  })]);
16211
16249
  newListenRouterKey = [].concat(_toConsumableArray(listenRouterKey), [currentKey]);
16212
16250
  }
@@ -16244,13 +16282,13 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16244
16282
  localStorage.removeItem('isMenuClick');
16245
16283
  }, 0);
16246
16284
  }
16247
- _this2.setState({
16285
+ _this3.setState({
16248
16286
  //路由监听函数最后执行setState,避免处理hideMenu类型页面自动关闭的逻辑块内获取不到最新state的listenRouterState和listenRouterKey
16249
16287
  activeKey: currentKey,
16250
16288
  listenRouterState: newListenRouterState,
16251
16289
  listenRouterKey: newListenRouterKey
16252
16290
  }, function () {
16253
- _this2.checkisNavSlide();
16291
+ _this3.checkisNavSlide();
16254
16292
  });
16255
16293
  istParent = 0;
16256
16294
  });
@@ -16265,17 +16303,35 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16265
16303
  } else {
16266
16304
  history.push(location);
16267
16305
  }
16306
+ try {
16307
+ window.addEventListener('beforeunload', this.handleBeforeUnload);
16308
+ } catch (error) {
16309
+ console.log("\uD83D\uDE80 => componentDidMount => error:", error);
16310
+ }
16268
16311
  }
16269
16312
  }, {
16270
16313
  key: "componentWillUnmount",
16271
16314
  value: function componentWillUnmount() {
16315
+ window.removeEventListener('beforeunload', this.handleBeforeUnload);
16272
16316
  // eslint-disable-next-line no-unused-expressions
16273
16317
  UN_LISTTEN_DRP && UN_LISTTEN_DRP();
16274
16318
  }
16319
+ }, {
16320
+ key: "getWelcomePage",
16321
+ value: function getWelcomePage() {
16322
+ var homeRouter = routerArray.filter(function (itemroute) {
16323
+ return itemroute.key === '/';
16324
+ })[0];
16325
+ return _objectSpread2(_objectSpread2({}, homeRouter), {}, {
16326
+ key: '/',
16327
+ tab: '欢迎',
16328
+ closable: false
16329
+ });
16330
+ }
16275
16331
  }, {
16276
16332
  key: "render",
16277
16333
  value: function render() {
16278
- var _this3 = this;
16334
+ var _this4 = this;
16279
16335
  var _this$state4 = this.state,
16280
16336
  listenRouterState = _this$state4.listenRouterState,
16281
16337
  activeKey = _this$state4.activeKey,
@@ -16299,7 +16355,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16299
16355
  className: "tab_title_content"
16300
16356
  }, item.tab, item.key !== '/' && /*#__PURE__*/React.createElement(ItemMenu, {
16301
16357
  info: item,
16302
- operateFun: _this3.operateFun,
16358
+ operateFun: _this4.operateFun,
16303
16359
  listenRouterState: listenRouterState
16304
16360
  }));
16305
16361
  };
@@ -16333,7 +16389,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16333
16389
  }, /*#__PURE__*/React.createElement("a", {
16334
16390
  onClick: function onClick() {
16335
16391
  // 关闭全部
16336
- _this3.updateState([_objectSpread2(_objectSpread2({}, _this3.state.homeRouter), {}, {
16392
+ _this4.updateState([_objectSpread2(_objectSpread2({}, _this4.state.homeRouter), {}, {
16337
16393
  key: '/',
16338
16394
  tab: '欢迎',
16339
16395
  closable: false
@@ -16359,7 +16415,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16359
16415
  } else {
16360
16416
  newActiveKey = listenRouterState[1].key;
16361
16417
  }
16362
- _this3.updateState(listenRouterState.filter(function (d) {
16418
+ _this4.updateState(listenRouterState.filter(function (d) {
16363
16419
  return d.key !== activeKey;
16364
16420
  }), listenRouterKey.filter(function (d) {
16365
16421
  return d !== activeKey;
@@ -16386,7 +16442,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16386
16442
  // message.warning('首页不可关闭。');
16387
16443
  // return;
16388
16444
  // }
16389
- _this3.updateState(listenRouterState.filter(function (d, i) {
16445
+ _this4.updateState(listenRouterState.filter(function (d, i) {
16390
16446
  return i >= index || d.key === '/';
16391
16447
  }), listenRouterKey.filter(function (d, i) {
16392
16448
  return i >= index || d === '/';
@@ -16403,7 +16459,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16403
16459
  var index = listenRouterState.findIndex(function (item) {
16404
16460
  return item.key === activeKey;
16405
16461
  });
16406
- _this3.updateState(listenRouterState.filter(function (d, i) {
16462
+ _this4.updateState(listenRouterState.filter(function (d, i) {
16407
16463
  return i <= index || d.key === '/';
16408
16464
  }), listenRouterKey.filter(function (d, i) {
16409
16465
  return i <= index || d === '/';
@@ -16446,7 +16502,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16446
16502
  opacity: this.state.isSlider ? 1 : 0.5
16447
16503
  },
16448
16504
  onClick: function onClick() {
16449
- _this3.setTabNavTransLate(-100);
16505
+ _this4.setTabNavTransLate(-100);
16450
16506
  }
16451
16507
  }, /*#__PURE__*/React.createElement(DoubleLeftOutlined, null))),
16452
16508
  right: /*#__PURE__*/React.createElement("div", {
@@ -16455,7 +16511,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16455
16511
  },
16456
16512
  className: 'tab_right_operate',
16457
16513
  onClick: function onClick() {
16458
- _this3.setTabNavTransLate(100);
16514
+ _this4.setTabNavTransLate(100);
16459
16515
  }
16460
16516
  }, /*#__PURE__*/React.createElement(DoubleRightOutlined, null))
16461
16517
  };
@@ -16469,7 +16525,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16469
16525
  return /*#__PURE__*/React.createElement(CustomerMenuHeader, {
16470
16526
  originRoutes: originRoutes,
16471
16527
  itemPath: itemPath,
16472
- handleClose: _this3.handleClose,
16528
+ handleClose: _this4.handleClose,
16473
16529
  collapsed: collapse
16474
16530
  });
16475
16531
  },
@@ -16478,10 +16534,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16478
16534
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CustomerMenu, {
16479
16535
  originRoutes: originRoutes,
16480
16536
  itemPath: itemPath,
16481
- ref: _this3.customerMenuRef,
16482
- actionRef: _this3.actionRef,
16483
- handleClose: _this3.handleClose,
16484
- isCollapse: _this3.state.collapse
16537
+ ref: _this4.customerMenuRef,
16538
+ actionRef: _this4.actionRef,
16539
+ handleClose: _this4.handleClose,
16540
+ isCollapse: _this4.state.collapse
16485
16541
  }));
16486
16542
  }
16487
16543
  return /*#__PURE__*/React.createElement("div", {
@@ -16489,7 +16545,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16489
16545
  }, /*#__PURE__*/React.createElement("span", {
16490
16546
  className: "collapse_icon",
16491
16547
  onClick: function onClick() {
16492
- _this3.setState({
16548
+ _this4.setState({
16493
16549
  collapse: !collapse
16494
16550
  });
16495
16551
  }
@@ -16502,7 +16558,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16502
16558
  },
16503
16559
  collapsed: collapse,
16504
16560
  onCollapse: function onCollapse(boo) {
16505
- _this3.setState({
16561
+ _this4.setState({
16506
16562
  collapse: boo
16507
16563
  });
16508
16564
  },
@@ -16538,14 +16594,14 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16538
16594
  },
16539
16595
  onMouseEnter: function onMouseEnter() {
16540
16596
  if (menuItemProps.pro_layout_parentKeys && menuItemProps.pro_layout_parentKeys.length) return;
16541
- _this3.setState({
16597
+ _this4.setState({
16542
16598
  currentSubMenuData: menuItemProps.children,
16543
16599
  currentSubPath: menuItemProps.path
16544
16600
  });
16545
- _this3.setShowMenu(true);
16601
+ _this4.setShowMenu(true);
16546
16602
  },
16547
16603
  onMouseLeave: function onMouseLeave() {
16548
- _this3.setShowMenu(false);
16604
+ _this4.setShowMenu(false);
16549
16605
  }
16550
16606
  }, defaultDom, showSubMenu && currentSubPath === menuItemProps.path && !collapse && /*#__PURE__*/React.createElement(CaretLeftOutlined, {
16551
16607
  style: {
@@ -16564,7 +16620,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16564
16620
  }, '');
16565
16621
  },
16566
16622
  postMenuData: function postMenuData(menus) {
16567
- return _toConsumableArray(filterByMenuDate(menus || [], _this3.state.keyWord));
16623
+ return _toConsumableArray(filterByMenuDate(menus || [], _this4.state.keyWord));
16568
16624
  },
16569
16625
  links: [!this.state.collapse ? /*#__PURE__*/React.createElement(AllFunc$1, {
16570
16626
  ref: this.allFunc,
@@ -16638,7 +16694,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16638
16694
  tab: /*#__PURE__*/React.createElement(TabTitle, {
16639
16695
  item: item,
16640
16696
  index: index,
16641
- updateState: _this3.updateState
16697
+ updateState: _this4.updateState
16642
16698
  }),
16643
16699
  style: {
16644
16700
  marginTop: isWeiqianduan ? 0 : 30
@@ -16650,10 +16706,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16650
16706
  })
16651
16707
  }, /*#__PURE__*/React.createElement(WrapperComponent, {
16652
16708
  item: item,
16653
- routerProps: _this3.props,
16654
- getDictionarySource: _this3.getDictionarySource,
16655
- getDictionaryTextByValue: _this3.getDictionaryTextByValue,
16656
- timeFormat: _this3.timeFormat,
16709
+ routerProps: _this4.props,
16710
+ getDictionarySource: _this4.getDictionarySource,
16711
+ getDictionaryTextByValue: _this4.getDictionaryTextByValue,
16712
+ timeFormat: _this4.timeFormat,
16657
16713
  transparentProps: transparentProps
16658
16714
  }));
16659
16715
  })), /*#__PURE__*/React.createElement("div", {
@@ -16678,10 +16734,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16678
16734
  itemPath: itemPath
16679
16735
  }, drawerLeftParams)), /*#__PURE__*/React.createElement("div", {
16680
16736
  onMouseEnter: function onMouseEnter() {
16681
- _this3.setShowMenu(true);
16737
+ _this4.setShowMenu(true);
16682
16738
  },
16683
16739
  onMouseLeave: function onMouseLeave() {
16684
- _this3.setShowMenu(false);
16740
+ _this4.setShowMenu(false);
16685
16741
  },
16686
16742
  className: 'sub_menu_content',
16687
16743
  style: {
package/dist/index.js CHANGED
@@ -15711,6 +15711,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
15711
15711
  _this.allFunc = /*#__PURE__*/React.createRef('');
15712
15712
  _this.customerMenuRef = /*#__PURE__*/React.createRef('');
15713
15713
  _this.actionRef = /*#__PURE__*/React.createRef();
15714
+ _this.handleBeforeUnload = function () {
15715
+ // 储存当前router信息
15716
+ sessionStorage.setItem('@listenRouterState', JSON.stringify(_this.state.listenRouterState));
15717
+ };
15714
15718
  _this.parseQueryString = function (queryString) {
15715
15719
  if (!queryString) {
15716
15720
  return '';
@@ -16114,15 +16118,49 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16114
16118
  },
16115
16119
  currentSubMenuData: [],
16116
16120
  showSubMenu: false,
16117
- isSlider: false
16121
+ isSlider: false,
16122
+ _routerArray: routerArray
16118
16123
  };
16119
16124
  return _this;
16120
16125
  }
16121
16126
  _createClass(BasicLayout, [{
16127
+ key: "componentWillMount",
16128
+ value: function componentWillMount() {
16129
+ var _this2 = this;
16130
+ // 检查页面是否为刷新之后的
16131
+ if (sessionStorage.getItem('@listenRouterState')) {
16132
+ var lastListenRouterState = JSON.parse(sessionStorage.getItem('@listenRouterState')),
16133
+ showListenRouterState = [],
16134
+ nowItem = {};
16135
+ if (lastListenRouterState.length === 1) {
16136
+ sessionStorage.removeItem('@listenRouterState');
16137
+ return;
16138
+ }
16139
+ lastListenRouterState.forEach(function (item) {
16140
+ var _this2$state;
16141
+ nowItem = _this2 === null || _this2 === void 0 ? void 0 : (_this2$state = _this2.state) === null || _this2$state === void 0 ? void 0 : _this2$state._routerArray.find(function (i) {
16142
+ var _item$match;
16143
+ return item.key === i.key || (item === null || item === void 0 ? void 0 : item.match) && (item === null || item === void 0 ? void 0 : (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.path) === i.key;
16144
+ });
16145
+ // 详情页保留问题尚未解决
16146
+ if (nowItem) {
16147
+ showListenRouterState.push(_objectSpread2(_objectSpread2({}, item), {}, {
16148
+ content: nowItem.content,
16149
+ tab: item.tab || _this2.getPageTitle(nowItem.key)
16150
+ }));
16151
+ }
16152
+ });
16153
+ this.setState({
16154
+ listenRouterState: [].concat(showListenRouterState)
16155
+ });
16156
+ sessionStorage.removeItem('@listenRouterState');
16157
+ }
16158
+ }
16159
+ }, {
16122
16160
  key: "componentDidMount",
16123
16161
  value: function componentDidMount() {
16124
16162
  var _window$$wujie,
16125
- _this2 = this,
16163
+ _this3 = this,
16126
16164
  _localStorage$getItem,
16127
16165
  _localStorage$getItem2;
16128
16166
  var _this$props = this.props,
@@ -16172,11 +16210,11 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16172
16210
  // if (window.location.href.indexOf(`/${itemPath}`) === -1) return;
16173
16211
  // }
16174
16212
  if (route.pathname.startsWith("/".concat(itemPath, "/"))) return;
16175
- var _this2$state = _this2.state,
16176
- listenRouterState = _this2$state.listenRouterState,
16177
- listenRouterKey = _this2$state.listenRouterKey,
16178
- customerMatchs = _this2$state.customerMatchs,
16179
- hideMenuArray = _this2$state.hideMenuArray;
16213
+ var _this3$state = _this3.state,
16214
+ listenRouterState = _this3$state.listenRouterState,
16215
+ listenRouterKey = _this3$state.listenRouterKey,
16216
+ customerMatchs = _this3$state.customerMatchs,
16217
+ hideMenuArray = _this3$state.hideMenuArray;
16180
16218
  var newListenRouterState = _toConsumableArray(listenRouterState);
16181
16219
  var newListenRouterKey = _toConsumableArray(listenRouterKey);
16182
16220
  var replaceRouter = routerArray.filter(function (itemRoute) {
@@ -16187,7 +16225,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16187
16225
  // 处理中英文和特殊字符
16188
16226
  currentKey = decodeURIComponent(route.pathname);
16189
16227
  } else {
16190
- currentKey = decodeURIComponent(route.pathname + _this2.parseQueryString(route.search));
16228
+ currentKey = decodeURIComponent(route.pathname + _this3.parseQueryString(route.search));
16191
16229
  }
16192
16230
  if (!istParent) {
16193
16231
  var _window$$wujie2;
@@ -16207,7 +16245,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16207
16245
  replaceRouter = (_routerArray$filter = routerArray.filter(function (itemroute) {
16208
16246
  return itemroute.key === '/404';
16209
16247
  })) === null || _routerArray$filter === void 0 ? void 0 : _routerArray$filter[0];
16210
- _this2.setState({
16248
+ _this3.setState({
16211
16249
  listenRouterState: [].concat(_toConsumableArray(listenRouterState), [_objectSpread2(_objectSpread2({}, replaceRouter), {}, {
16212
16250
  key: currentKey,
16213
16251
  tab: '404'
@@ -16215,7 +16253,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16215
16253
  activeKey: currentKey,
16216
16254
  listenRouterKey: [].concat(_toConsumableArray(listenRouterKey), [currentKey])
16217
16255
  }, function () {
16218
- _this2.checkisNavSlide();
16256
+ _this3.checkisNavSlide();
16219
16257
  });
16220
16258
  } else {
16221
16259
  var match = matchPath(route.pathname, {
@@ -16225,7 +16263,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16225
16263
  query: route.query,
16226
16264
  match: match,
16227
16265
  key: currentKey,
16228
- tab: _this2.getPageTitle(route.pathname) + ''
16266
+ tab: _this3.getPageTitle(route.pathname) + ''
16229
16267
  })]);
16230
16268
  newListenRouterKey = [].concat(_toConsumableArray(listenRouterKey), [currentKey]);
16231
16269
  }
@@ -16263,13 +16301,13 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16263
16301
  localStorage.removeItem('isMenuClick');
16264
16302
  }, 0);
16265
16303
  }
16266
- _this2.setState({
16304
+ _this3.setState({
16267
16305
  //路由监听函数最后执行setState,避免处理hideMenu类型页面自动关闭的逻辑块内获取不到最新state的listenRouterState和listenRouterKey
16268
16306
  activeKey: currentKey,
16269
16307
  listenRouterState: newListenRouterState,
16270
16308
  listenRouterKey: newListenRouterKey
16271
16309
  }, function () {
16272
- _this2.checkisNavSlide();
16310
+ _this3.checkisNavSlide();
16273
16311
  });
16274
16312
  istParent = 0;
16275
16313
  });
@@ -16284,17 +16322,35 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16284
16322
  } else {
16285
16323
  history.push(location);
16286
16324
  }
16325
+ try {
16326
+ window.addEventListener('beforeunload', this.handleBeforeUnload);
16327
+ } catch (error) {
16328
+ console.log("\uD83D\uDE80 => componentDidMount => error:", error);
16329
+ }
16287
16330
  }
16288
16331
  }, {
16289
16332
  key: "componentWillUnmount",
16290
16333
  value: function componentWillUnmount() {
16334
+ window.removeEventListener('beforeunload', this.handleBeforeUnload);
16291
16335
  // eslint-disable-next-line no-unused-expressions
16292
16336
  UN_LISTTEN_DRP && UN_LISTTEN_DRP();
16293
16337
  }
16338
+ }, {
16339
+ key: "getWelcomePage",
16340
+ value: function getWelcomePage() {
16341
+ var homeRouter = routerArray.filter(function (itemroute) {
16342
+ return itemroute.key === '/';
16343
+ })[0];
16344
+ return _objectSpread2(_objectSpread2({}, homeRouter), {}, {
16345
+ key: '/',
16346
+ tab: '欢迎',
16347
+ closable: false
16348
+ });
16349
+ }
16294
16350
  }, {
16295
16351
  key: "render",
16296
16352
  value: function render() {
16297
- var _this3 = this;
16353
+ var _this4 = this;
16298
16354
  var _this$state4 = this.state,
16299
16355
  listenRouterState = _this$state4.listenRouterState,
16300
16356
  activeKey = _this$state4.activeKey,
@@ -16318,7 +16374,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16318
16374
  className: "tab_title_content"
16319
16375
  }, item.tab, item.key !== '/' && /*#__PURE__*/React__default['default'].createElement(ItemMenu, {
16320
16376
  info: item,
16321
- operateFun: _this3.operateFun,
16377
+ operateFun: _this4.operateFun,
16322
16378
  listenRouterState: listenRouterState
16323
16379
  }));
16324
16380
  };
@@ -16352,7 +16408,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16352
16408
  }, /*#__PURE__*/React__default['default'].createElement("a", {
16353
16409
  onClick: function onClick() {
16354
16410
  // 关闭全部
16355
- _this3.updateState([_objectSpread2(_objectSpread2({}, _this3.state.homeRouter), {}, {
16411
+ _this4.updateState([_objectSpread2(_objectSpread2({}, _this4.state.homeRouter), {}, {
16356
16412
  key: '/',
16357
16413
  tab: '欢迎',
16358
16414
  closable: false
@@ -16378,7 +16434,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16378
16434
  } else {
16379
16435
  newActiveKey = listenRouterState[1].key;
16380
16436
  }
16381
- _this3.updateState(listenRouterState.filter(function (d) {
16437
+ _this4.updateState(listenRouterState.filter(function (d) {
16382
16438
  return d.key !== activeKey;
16383
16439
  }), listenRouterKey.filter(function (d) {
16384
16440
  return d !== activeKey;
@@ -16405,7 +16461,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16405
16461
  // message.warning('首页不可关闭。');
16406
16462
  // return;
16407
16463
  // }
16408
- _this3.updateState(listenRouterState.filter(function (d, i) {
16464
+ _this4.updateState(listenRouterState.filter(function (d, i) {
16409
16465
  return i >= index || d.key === '/';
16410
16466
  }), listenRouterKey.filter(function (d, i) {
16411
16467
  return i >= index || d === '/';
@@ -16422,7 +16478,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16422
16478
  var index = listenRouterState.findIndex(function (item) {
16423
16479
  return item.key === activeKey;
16424
16480
  });
16425
- _this3.updateState(listenRouterState.filter(function (d, i) {
16481
+ _this4.updateState(listenRouterState.filter(function (d, i) {
16426
16482
  return i <= index || d.key === '/';
16427
16483
  }), listenRouterKey.filter(function (d, i) {
16428
16484
  return i <= index || d === '/';
@@ -16465,7 +16521,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16465
16521
  opacity: this.state.isSlider ? 1 : 0.5
16466
16522
  },
16467
16523
  onClick: function onClick() {
16468
- _this3.setTabNavTransLate(-100);
16524
+ _this4.setTabNavTransLate(-100);
16469
16525
  }
16470
16526
  }, /*#__PURE__*/React__default['default'].createElement(icons.DoubleLeftOutlined, null))),
16471
16527
  right: /*#__PURE__*/React__default['default'].createElement("div", {
@@ -16474,7 +16530,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16474
16530
  },
16475
16531
  className: 'tab_right_operate',
16476
16532
  onClick: function onClick() {
16477
- _this3.setTabNavTransLate(100);
16533
+ _this4.setTabNavTransLate(100);
16478
16534
  }
16479
16535
  }, /*#__PURE__*/React__default['default'].createElement(icons.DoubleRightOutlined, null))
16480
16536
  };
@@ -16488,7 +16544,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16488
16544
  return /*#__PURE__*/React__default['default'].createElement(CustomerMenuHeader, {
16489
16545
  originRoutes: originRoutes,
16490
16546
  itemPath: itemPath,
16491
- handleClose: _this3.handleClose,
16547
+ handleClose: _this4.handleClose,
16492
16548
  collapsed: collapse
16493
16549
  });
16494
16550
  },
@@ -16497,10 +16553,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16497
16553
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(CustomerMenu, {
16498
16554
  originRoutes: originRoutes,
16499
16555
  itemPath: itemPath,
16500
- ref: _this3.customerMenuRef,
16501
- actionRef: _this3.actionRef,
16502
- handleClose: _this3.handleClose,
16503
- isCollapse: _this3.state.collapse
16556
+ ref: _this4.customerMenuRef,
16557
+ actionRef: _this4.actionRef,
16558
+ handleClose: _this4.handleClose,
16559
+ isCollapse: _this4.state.collapse
16504
16560
  }));
16505
16561
  }
16506
16562
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -16508,7 +16564,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16508
16564
  }, /*#__PURE__*/React__default['default'].createElement("span", {
16509
16565
  className: "collapse_icon",
16510
16566
  onClick: function onClick() {
16511
- _this3.setState({
16567
+ _this4.setState({
16512
16568
  collapse: !collapse
16513
16569
  });
16514
16570
  }
@@ -16521,7 +16577,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16521
16577
  },
16522
16578
  collapsed: collapse,
16523
16579
  onCollapse: function onCollapse(boo) {
16524
- _this3.setState({
16580
+ _this4.setState({
16525
16581
  collapse: boo
16526
16582
  });
16527
16583
  },
@@ -16557,14 +16613,14 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16557
16613
  },
16558
16614
  onMouseEnter: function onMouseEnter() {
16559
16615
  if (menuItemProps.pro_layout_parentKeys && menuItemProps.pro_layout_parentKeys.length) return;
16560
- _this3.setState({
16616
+ _this4.setState({
16561
16617
  currentSubMenuData: menuItemProps.children,
16562
16618
  currentSubPath: menuItemProps.path
16563
16619
  });
16564
- _this3.setShowMenu(true);
16620
+ _this4.setShowMenu(true);
16565
16621
  },
16566
16622
  onMouseLeave: function onMouseLeave() {
16567
- _this3.setShowMenu(false);
16623
+ _this4.setShowMenu(false);
16568
16624
  }
16569
16625
  }, defaultDom, showSubMenu && currentSubPath === menuItemProps.path && !collapse && /*#__PURE__*/React__default['default'].createElement(icons.CaretLeftOutlined, {
16570
16626
  style: {
@@ -16583,7 +16639,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16583
16639
  }, '');
16584
16640
  },
16585
16641
  postMenuData: function postMenuData(menus) {
16586
- return _toConsumableArray(filterByMenuDate(menus || [], _this3.state.keyWord));
16642
+ return _toConsumableArray(filterByMenuDate(menus || [], _this4.state.keyWord));
16587
16643
  },
16588
16644
  links: [!this.state.collapse ? /*#__PURE__*/React__default['default'].createElement(AllFunc$1, {
16589
16645
  ref: this.allFunc,
@@ -16657,7 +16713,7 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16657
16713
  tab: /*#__PURE__*/React__default['default'].createElement(TabTitle, {
16658
16714
  item: item,
16659
16715
  index: index,
16660
- updateState: _this3.updateState
16716
+ updateState: _this4.updateState
16661
16717
  }),
16662
16718
  style: {
16663
16719
  marginTop: isWeiqianduan ? 0 : 30
@@ -16669,10 +16725,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16669
16725
  })
16670
16726
  }, /*#__PURE__*/React__default['default'].createElement(WrapperComponent, {
16671
16727
  item: item,
16672
- routerProps: _this3.props,
16673
- getDictionarySource: _this3.getDictionarySource,
16674
- getDictionaryTextByValue: _this3.getDictionaryTextByValue,
16675
- timeFormat: _this3.timeFormat,
16728
+ routerProps: _this4.props,
16729
+ getDictionarySource: _this4.getDictionarySource,
16730
+ getDictionaryTextByValue: _this4.getDictionaryTextByValue,
16731
+ timeFormat: _this4.timeFormat,
16676
16732
  transparentProps: transparentProps
16677
16733
  }));
16678
16734
  })), /*#__PURE__*/React__default['default'].createElement("div", {
@@ -16697,10 +16753,10 @@ var BasicLayout = /*#__PURE__*/function (_React$PureComponent) {
16697
16753
  itemPath: itemPath
16698
16754
  }, drawerLeftParams)), /*#__PURE__*/React__default['default'].createElement("div", {
16699
16755
  onMouseEnter: function onMouseEnter() {
16700
- _this3.setShowMenu(true);
16756
+ _this4.setShowMenu(true);
16701
16757
  },
16702
16758
  onMouseLeave: function onMouseLeave() {
16703
- _this3.setShowMenu(false);
16759
+ _this4.setShowMenu(false);
16704
16760
  },
16705
16761
  className: 'sub_menu_content',
16706
16762
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "2.3.9",
3
+ "version": "2.3.10-alpha.1",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -324,9 +324,41 @@ class BasicLayout extends React.PureComponent {
324
324
  currentSubMenuData: [],
325
325
  showSubMenu: false,
326
326
  isSlider: false,
327
+ _routerArray: routerArray
327
328
  };
328
329
  }
329
330
 
331
+ componentWillMount() {
332
+ // 检查页面是否为刷新之后的
333
+ if (sessionStorage.getItem('@listenRouterState')) {
334
+ let lastListenRouterState = JSON.parse(sessionStorage.getItem('@listenRouterState')),
335
+ showListenRouterState = [],
336
+ nowItem = {};
337
+ if (lastListenRouterState.length === 1) {
338
+ sessionStorage.removeItem('@listenRouterState');
339
+ return
340
+ }
341
+ lastListenRouterState.forEach((item: any) => {
342
+ nowItem = this?.state?._routerArray.find((i: any) =>
343
+ item.key === i.key ||
344
+ (item?.match && item?.match?.path === i.key)
345
+ );
346
+ // 详情页保留问题尚未解决
347
+ if (nowItem) {
348
+ showListenRouterState.push({
349
+ ...item,
350
+ content: nowItem.content,
351
+ tab: item.tab || this.getPageTitle(nowItem.key)
352
+ })
353
+ }
354
+ });
355
+ this.setState({
356
+ listenRouterState: [ ...showListenRouterState ]
357
+ });
358
+ sessionStorage.removeItem('@listenRouterState');
359
+ }
360
+ }
361
+
330
362
  componentDidMount() {
331
363
  const {
332
364
  history,
@@ -521,13 +553,32 @@ class BasicLayout extends React.PureComponent {
521
553
  } else {
522
554
  history.push(location);
523
555
  }
556
+
557
+ try {
558
+ window.addEventListener('beforeunload', this.handleBeforeUnload);
559
+ } catch (error) {
560
+ console.log(`🚀 => componentDidMount => error:`, error)
561
+ }
524
562
  }
525
563
 
526
564
  componentWillUnmount() {
565
+ window.removeEventListener('beforeunload', this.handleBeforeUnload);
527
566
  // eslint-disable-next-line no-unused-expressions
528
567
  UN_LISTTEN_DRP && UN_LISTTEN_DRP();
529
568
  }
530
569
 
570
+ handleBeforeUnload = () => {
571
+ // 储存当前router信息
572
+ sessionStorage.setItem('@listenRouterState', JSON.stringify(this.state.listenRouterState))
573
+ }
574
+
575
+ getWelcomePage() {
576
+ const homeRouter = routerArray.filter(
577
+ (itemroute) => itemroute.key === '/',
578
+ )[0];
579
+ return { ...homeRouter, key: '/', tab: '欢迎', closable: false }
580
+ }
581
+
531
582
  parseQueryString = (queryString) => {
532
583
  if (!queryString) {
533
584
  return '';