Browse Source

improved apps interface

Skylsmoi 7 years ago
parent
commit
9f3c72176e
2 changed files with 13 additions and 8 deletions
  1. 11 8
      src/container/Thread.jsx
  2. 2 0
      src/index.js

+ 11 - 8
src/container/Thread.jsx View File

54
     document.addEventListener('appCustomEvent', this.customEventReducer)
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
   async componentDidMount () {
68
   async componentDidMount () {
58
     const { workspace, content, appConfig } = this.state
69
     const { workspace, content, appConfig } = this.state
59
     if (content.id === '-1') return // debug case
70
     if (content.id === '-1') return // debug case
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
   handleClickBtnCloseApp = () => {
84
   handleClickBtnCloseApp = () => {
82
     this.setState({ isVisible: false })
85
     this.setState({ isVisible: false })
83
   }
86
   }

+ 2 - 0
src/index.js View File

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