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

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,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IAppRouteProps } from './interface';
3
3
  declare class AppRoute extends React.PureComponent<IAppRouteProps, any> {
4
+ static defaultProps: IAppRouteProps;
4
5
  private isRender;
5
6
  constructor(props: IAppRouteProps);
6
7
  shouldComponentUpdate(props: IAppRouteProps): boolean;
@@ -1,7 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
3
  import _cache from "@cloud-app-dev/utils/es/cache";
4
- import _useUnmount from "ahooks/es/useUnmount";
5
4
  import _useMount from "ahooks/es/useMount";
6
5
 
7
6
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -25,21 +24,16 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
25
24
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
25
 
27
26
  import React from 'react';
28
- import { Route } from 'react-router-dom';
27
+ import { Route, Routes } from 'react-router-dom';
29
28
  var _global = window;
30
29
 
31
30
  function RenderSingleRoute(_ref) {
32
- var onMount = _ref.onMount,
33
- onUnmount = _ref.onUnmount;
31
+ var onMount = _ref.onMount;
34
32
 
35
33
  _useMount(function () {
36
34
  return onMount();
37
35
  });
38
36
 
39
- _useUnmount(function () {
40
- return onUnmount();
41
- });
42
-
43
37
  return /*#__PURE__*/React.createElement(React.Fragment, null);
44
38
  }
45
39
 
@@ -57,7 +51,7 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
57
51
 
58
52
  _this.isRender = false;
59
53
  _this.state = {
60
- isMatch: false
54
+ mathIndex: -1
61
55
  };
62
56
  return _this;
63
57
  }
@@ -81,29 +75,22 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
81
75
  value: function render() {
82
76
  var _this2 = this;
83
77
 
84
- var _this$props = this.props,
85
- element = _this$props.element,
86
- path = _this$props.path;
87
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Route, {
88
- path: path,
89
- element: /*#__PURE__*/React.createElement(RenderSingleRoute, {
90
- onMount: function onMount() {
91
- return _this2.setState({
92
- isMatch: true
93
- });
94
- },
95
- onUnmount: function onUnmount() {
96
- return _this2.setState({
97
- isMatch: false
98
- });
99
- }
100
- })
101
- }), this.state.isMatch && element, /*#__PURE__*/React.createElement(RenderSingleRoute, {
78
+ var routes = this.props.routes;
79
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Routes, null, routes.map(function (item, index) {
80
+ return /*#__PURE__*/React.createElement(Route, {
81
+ path: item.path,
82
+ key: item.path,
83
+ element: /*#__PURE__*/React.createElement(RenderSingleRoute, {
84
+ onMount: function onMount() {
85
+ return _this2.setState({
86
+ mathIndex: index
87
+ });
88
+ }
89
+ })
90
+ });
91
+ })), this.state.matchIndex > -1 && routes[this.state.matchIndex].element, /*#__PURE__*/React.createElement(RenderSingleRoute, {
102
92
  onMount: function onMount() {
103
93
  return _this2.isRender = true;
104
- },
105
- onUnmount: function onUnmount() {
106
- return _this2.isRender = false;
107
94
  }
108
95
  }));
109
96
  }
@@ -112,4 +99,7 @@ var AppRoute = /*#__PURE__*/function (_React$PureComponent) {
112
99
  return AppRoute;
113
100
  }(React.PureComponent);
114
101
 
102
+ AppRoute.defaultProps = {
103
+ routes: []
104
+ };
115
105
  export default AppRoute;
@@ -1,7 +1,7 @@
1
1
  import * as H from 'history';
2
2
  import { RouteProps } from 'react-router-dom';
3
3
 
4
- export interface IAppRouteProps extends RouteProps, IAppRouteType {
4
+ export interface IAppRouteProps {
5
5
  routes?: RouteProps[];
6
6
  tabId?: string;
7
7
  currentId?: string;
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.13",
5
+ "version": "2.0.0-alpha.14",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",