Преглед изворни кода

use debug instead console.log.

windsome.feng пре 7 година
родитељ
комит
1e52acdfbd
4 измењених фајлова са 34 додато и 28 уклоњено
  1. 1 1
      src/App.js
  2. 13 11
      src/Map.js
  3. 10 8
      src/Marker.js
  4. 10 8
      src/MassMarks.js

+ 1 - 1
src/App.js

@@ -88,7 +88,7 @@ class MarkerTest extends Component {
         </div>
         <div style={{margin:2}}>
           <input style={{margin:2, padding:2}} type='button' onClick={() => {
-            if (this.state.carEntity) this.state.carEntity.moveAlong(this.state.lineArr, 500);
+            if (this.state.carEntity) this.state.carEntity.moveAlong(this.state.lineArr, 1500);
           }} value='开始' />
           <input style={{margin:2, padding:2}} type='button' onClick={() => {
             if (this.state.carEntity) this.state.carEntity.pauseMove();

+ 13 - 11
src/Map.js

@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
 import { loadMap, createMap, updateMap } from './api';
 
 const __com__ = 'Map';
+//const debug = console.log;
+const debug = () => {};
 
 export class Map extends Component {
   static propTypes = {
@@ -22,15 +24,15 @@ export class Map extends Component {
     super();
     this.refElement = null;
     this._entity = null;
-    console.log(__com__, 'component constructor', this.refElement, this._entity);
+    debug(__com__, 'component constructor', this.refElement, this._entity);
   }
 
   componentWillMount() {
-    console.log(__com__, 'componentWillMount', this.refElement, this._entity);
+    debug(__com__, 'componentWillMount', this.refElement, this._entity);
   }
 
   componentDidMount() {
-    console.log(__com__, 'componentDidMount', this.refElement, this._entity);
+    debug(__com__, 'componentDidMount', this.refElement, this._entity);
     let { AMap, refMap, options, events } = this.props;
     this._entity = createMap(AMap, this.refElement, options, events);
     if (this._entity) {
@@ -40,15 +42,15 @@ export class Map extends Component {
   }
 
   componentWillReceiveProps(nextProps) {
-    console.log(__com__, 'componentWillReceiveProps', this.refElement, this._entity);
+    debug(__com__, 'componentWillReceiveProps', this.refElement, this._entity);
   }
 
   componentWillUpdate() {
-    console.log(__com__, 'componentWillUpdate', this.refElement, this._entity);
+    debug(__com__, 'componentWillUpdate', this.refElement, this._entity);
   }
 
   componentDidUpdate(prevProps) {
-    console.log(__com__, 'componentDidUpdate', this.refElement, this._entity);
+    debug(__com__, 'componentDidUpdate', this.refElement, this._entity);
     let { AMap, refMap, options, events } = this.props;
     if (!this._entity) {
       this._entity = createMap(AMap, this.refElement, options, events);
@@ -70,7 +72,7 @@ export class Map extends Component {
   }
 
   componentWillUnmount() {
-    console.log(__com__, 'componentWillUnmount', this.refElement, this._entity);
+    debug(__com__, 'componentWillUnmount', this.refElement, this._entity);
     if (this._entity) {
       let { refMap } = this.props;
       //   this._entity.clearMap();
@@ -90,21 +92,21 @@ export class Map extends Component {
          * 2. DOM 元素
          */
         if (cType.preventAmap || typeof cType === 'string') {
-          console.log(__com__, 'component renderChildren orig');
+          debug(__com__, 'component renderChildren orig');
           return child;
         }
-        console.log(__com__, 'component renderChildren add __map__');
+        debug(__com__, 'component renderChildren add __map__');
         return React.cloneElement(child, {
           __map__
         });
       }
-      console.log(__com__, 'component renderChildren null');
+      debug(__com__, 'component renderChildren null');
       return child;
     });
   }
 
   render() {
-    console.log(__com__, 'component render', this.refElement, this._entity);
+    debug(__com__, 'component render', this.refElement, this._entity);
     let {
       AMap,
       options,

+ 10 - 8
src/Marker.js

@@ -2,6 +2,8 @@ import React, { Component, PureComponent } from 'react';
 import PropTypes from 'prop-types';
 import { createMarker, updateMarker } from './api';
 const __component__ = 'Marker';
+//const debug = console.log;
+const debug = () => {};
 
 export class Marker extends Component {
   static propTypes = {
@@ -22,15 +24,15 @@ export class Marker extends Component {
     super();
     this.refElement = null;
     this._entity = null;
-    console.log(__component__, 'constructor', this._entity);
+    debug(__component__, 'constructor', this._entity);
   }
 
   componentWillMount() {
-    console.log(__component__, 'componentWillMount', this.props.children, this._entity);
+    debug(__component__, 'componentWillMount', this.props.children, this._entity);
   }
 
   componentDidMount() {
-    console.log(__component__, 'componentDidMount', this.props.children, this._entity);
+    debug(__component__, 'componentDidMount', this.props.children, this._entity);
     let { AMap, __map__, options, events, children } = this.props;
     //let opts = { ...(options || {}), map: __map__, content: children };
     let opts = { ...(options || {}), map: __map__ };
@@ -41,15 +43,15 @@ export class Marker extends Component {
   }
 
   componentWillReceiveProps(nextProps) {
-    console.log(__component__, 'componentWillReceiveProps', this.props.children, this._entity);
+    debug(__component__, 'componentWillReceiveProps', this.props.children, this._entity);
   }
 
   componentWillUpdate() {
-    console.log(__component__, 'componentWillUpdate', this.props.children, this._entity);
+    debug(__component__, 'componentWillUpdate', this.props.children, this._entity);
   }
 
   componentDidUpdate(prevProps) {
-    console.log(__component__, 'componentDidUpdate', this.props.children, this._entity);
+    debug(__component__, 'componentDidUpdate', this.props.children, this._entity);
     let { AMap, __map__, options, events, children } = this.props;
     //let opts = { ...(options || {}), map: __map__, content: children };
     let opts = { ...(options || {}), map: __map__ };
@@ -71,7 +73,7 @@ export class Marker extends Component {
   }
 
   componentWillUnmount() {
-    console.log(__component__, 'componentWillUnmount', this.props.children, this._entity);
+    debug(__component__, 'componentWillUnmount', this.props.children, this._entity);
     if (this._entity) {
       //   this._entity.clearMap();
       this._entity.setMap(null);
@@ -82,7 +84,7 @@ export class Marker extends Component {
   }
 
   render() {
-    console.log(__component__, 'render', this.props.children, this._entity);
+    debug(__component__, 'render', this.props.children, this._entity);
     let {
       AMap,
       options,

+ 10 - 8
src/MassMarks.js

@@ -2,6 +2,8 @@ import React, { Component, PureComponent } from 'react';
 import PropTypes from 'prop-types';
 import { createMassMarks, updateMassMarks } from './api';
 const __com__ = 'MassMarks';
+//const debug = console.log;
+const debug = () => {};
 
 export class MassMarks extends Component {
   static propTypes = {
@@ -15,15 +17,15 @@ export class MassMarks extends Component {
     super();
     this.refElement = null;
     this._entity = null;
-    console.log(__com__, 'constructor', this._entity);
+    debug(__com__, 'constructor', this._entity);
   }
 
   componentWillMount() {
-    console.log(__com__, 'componentWillMount', this.props.children, this._entity);
+    debug(__com__, 'componentWillMount', this.props.children, this._entity);
   }
 
   componentDidMount() {
-    console.log(__com__, 'componentDidMount', this.props.children, this._entity);
+    debug(__com__, 'componentDidMount', this.props.children, this._entity);
     let { AMap, __map__, options, events, children } = this.props;
     //let opts = { ...(options || {}), map: __map__, content: children };
     let opts = { ...(options || {}), map: __map__ };
@@ -31,15 +33,15 @@ export class MassMarks extends Component {
   }
 
   componentWillReceiveProps(nextProps) {
-    console.log(__com__, 'componentWillReceiveProps', this.props.children, this._entity);
+    debug(__com__, 'componentWillReceiveProps', this.props.children, this._entity);
   }
 
   componentWillUpdate() {
-    console.log(__com__, 'componentWillUpdate', this.props.children, this._entity);
+    debug(__com__, 'componentWillUpdate', this.props.children, this._entity);
   }
 
   componentDidUpdate(prevProps) {
-    console.log(__com__, 'componentDidUpdate', this.props.children, this._entity);
+    debug(__com__, 'componentDidUpdate', this.props.children, this._entity);
     let { AMap, __map__, options, events, children } = this.props;
     //let opts = { ...(options || {}), map: __map__, content: children };
     let opts = { ...(options || {}), map: __map__ };
@@ -57,7 +59,7 @@ export class MassMarks extends Component {
   }
 
   componentWillUnmount() {
-    console.log(__com__, 'componentWillUnmount', this.props.children, this._entity);
+    debug(__com__, 'componentWillUnmount', this.props.children, this._entity);
     if (this._entity) {
       //   this._entity.clearMap();
       this._entity.setMap(null);
@@ -68,7 +70,7 @@ export class MassMarks extends Component {
   }
 
   render() {
-    console.log(__com__, 'render', this.props.children, this._entity);
+    debug(__com__, 'render', this.props.children, this._entity);
     let {
       AMap,
       options,