@cloud-app-dev/vidc 2.0.0-alpha.14 → 2.0.0-alpha.15

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.
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IAppRouteProps } from './interface';
3
- declare class AppRoute extends React.PureComponent<IAppRouteProps, any> {
3
+ declare class AppRoute extends React.Component<IAppRouteProps, any> {
4
4
  static defaultProps: IAppRouteProps;
5
- private isRender;
6
5
  constructor(props: IAppRouteProps);
7
6
  shouldComponentUpdate(props: IAppRouteProps): boolean;
8
7
  componentWillUnmount(): void;
@@ -23,6 +23,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
23
23
 
24
24
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
25
 
26
+ import { __rest } from "tslib";
26
27
  import React from 'react';
27
28
  import { Route, Routes } from 'react-router-dom';
28
29
  var _global = window;
@@ -37,8 +38,8 @@ function RenderSingleRoute(_ref) {
37
38
  return /*#__PURE__*/React.createElement(React.Fragment, null);
38
39
  }
39
40
 
40
- var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
41
- _inherits(AppRoute, _React$PureComponent);
41
+ var AppRoute = /*#__PURE__*/function (_React$Component) {
42
+ _inherits(AppRoute, _React$Component);
42
43
 
43
44
  var _super = _createSuper(AppRoute);
44
45
 
@@ -47,11 +48,9 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
47
48
 
48
49
  _classCallCheck(this, AppRoute);
49
50
 
50
- _this = _super.call(this, props); //可能存在路由创建但是没有render 导致UI无法渲染
51
-
52
- _this.isRender = false;
51
+ _this = _super.call(this, props);
53
52
  _this.state = {
54
- mathIndex: -1
53
+ matchIndex: -1
55
54
  };
56
55
  return _this;
57
56
  }
@@ -59,11 +58,14 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
59
58
  _createClass(AppRoute, [{
60
59
  key: "shouldComponentUpdate",
61
60
  value: function shouldComponentUpdate(props) {
62
- if (!_global._IS_RUN_MICRO_BASIC || !this.isRender || _global._IS_ALLOW_ROUTE_RENDER) {
63
- return true;
61
+ var tabId = props.currentId || _cache.getCache('currentTabKey', 'session');
62
+
63
+ if (_global._IS_RUN_MICRO_BASIC && tabId !== props.tabId) {
64
+ // 页签变化拦截
65
+ return false;
64
66
  }
65
67
 
66
- return (props.currentId || _cache.getCache('currentTabKey', 'session')) === props.tabId;
68
+ return true;
67
69
  }
68
70
  }, {
69
71
  key: "componentWillUnmount",
@@ -75,7 +77,14 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
75
77
  value: function render() {
76
78
  var _this2 = this;
77
79
 
78
- var routes = this.props.routes;
80
+ var matchIndex = this.state.matchIndex;
81
+
82
+ var _a = this.props,
83
+ _a$routes = _a.routes,
84
+ routes = _a$routes === void 0 ? [] : _a$routes,
85
+ props = __rest(_a, ["routes"]);
86
+
87
+ var component = matchIndex > -1 ? routes[matchIndex].element : undefined;
79
88
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Routes, null, routes.map(function (item, index) {
80
89
  return /*#__PURE__*/React.createElement(Route, {
81
90
  path: item.path,
@@ -83,21 +92,17 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
83
92
  element: /*#__PURE__*/React.createElement(RenderSingleRoute, {
84
93
  onMount: function onMount() {
85
94
  return _this2.setState({
86
- mathIndex: index
95
+ matchIndex: index
87
96
  });
88
97
  }
89
98
  })
90
99
  });
91
- })), this.state.matchIndex > -1 && routes[this.state.matchIndex].element, /*#__PURE__*/React.createElement(RenderSingleRoute, {
92
- onMount: function onMount() {
93
- return _this2.isRender = true;
94
- }
95
- }));
100
+ })), component && /*#__PURE__*/React.cloneElement(component, props));
96
101
  }
97
102
  }]);
98
103
 
99
104
  return AppRoute;
100
- }(React.PureComponent);
105
+ }(React.Component);
101
106
 
102
107
  AppRoute.defaultProps = {
103
108
  routes: []
@@ -108,7 +108,6 @@ function LoaderApp(_ref) {
108
108
  var props = Object.assign(Object.assign({}, appProps), {
109
109
  container: domRef.current
110
110
  });
111
- console.debug('执行更新!', appProps);
112
111
  loadedAppRef.current.update && loadedAppRef.current.update(props);
113
112
  }
114
113
  }, [appProps.currentId, appProps.tabId, appProps.updateTime]);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "2.0.0-alpha.14",
5
+ "version": "2.0.0-alpha.15",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",