Procházet zdrojové kódy

improved apps interface

Skylsmoi před 6 roky
rodič
revize
9f3c72176e
2 změnil soubory, kde provedl 13 přidání a 8 odebrání
  1. 11 8
      src/container/Thread.jsx
  2. 2 0
      src/index.js

+ 11 - 8
src/container/Thread.jsx Zobrazit soubor

@@ -54,6 +54,17 @@ class Thread extends React.Component {
54 54
     document.addEventListener('appCustomEvent', this.customEventReducer)
55 55
   }
56 56
 
57
+  customEventReducer = ({ detail: action }) => { // action: { type: '', data: {} }
58
+    switch (action.type) {
59
+      case 'Thread_showApp':
60
+        this.setState({isVisible: true})
61
+        break
62
+      case 'Thread_hideApp':
63
+        this.setState({isVisible: false})
64
+        break
65
+    }
66
+  }
67
+
57 68
   async componentDidMount () {
58 69
     const { workspace, content, appConfig } = this.state
59 70
     if (content.id === '-1') return // debug case
@@ -70,14 +81,6 @@ class Thread extends React.Component {
70 81
     })
71 82
   }
72 83
 
73
-  customEventReducer = ({detail}) => {
74
-    switch (detail.type) {
75
-      case 'Thread_showMsg': // unused for now, for testing purpose
76
-        this.setState({inputText: detail.content})
77
-        break
78
-    }
79
-  }
80
-
81 84
   handleClickBtnCloseApp = () => {
82 85
     this.setState({ isVisible: false })
83 86
   }

+ 2 - 0
src/index.js Zobrazit soubor

@@ -5,6 +5,8 @@ import Thread from './container/Thread.jsx'
5 5
 require('./css/index.styl')
6 6
 
7 7
 const appInterface = {
8
+  name: 'Thread',
9
+  isRendered: false,
8 10
   renderApp: (domId, data) => {
9 11
     return ReactDOM.render(
10 12
       <Thread file={data} />