Spd.js
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react'
import ElementGroup from '../components/ElementGroup'
import Header from '../components/Header'
import AlertContainer from 'react-alert'
import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery'
export default class Spd extends React.Component {
componentDidMount() {
EventEmitter.subscribe('alert', function(info){
this.showAlert(info)
}.bind(this))
}
componentWillUnmount() {
EventEmitter.unSubscribe('alert')
}
componentWillMount() {
this.alertOptions = {
offset: 14,
position: 'top right',
theme: 'dark',
time: 5000,
transition: 'scale'
}
}
showAlert(info) {
this.msg.show(info, {
time: 2000,
type: 'success',
icon: <img src="/images/success.png" />
})
}
render() {
return (
<div id="app">
<AlertContainer ref={a => this.msg = a} {...this.alertOptions} />
<div className="row">
<Header />
</div>
<div className="row">
<div className="col-md-2 sidebar" id='sidebar'>
<h3 className='sidebar-header'>元件</h3>
<ElementGroup />
</div>
<div id="dropzone" className="col-md-10 dropzone">
{this.props.children}
</div>
</div>
</div>
)
}
}