Commit 0cdbcdba by hfpp2012 yinsigan

组织代码

1 parent 1eaeb789
...@@ -2,10 +2,10 @@ import React from 'react' ...@@ -2,10 +2,10 @@ import React from 'react'
import Element from './Element' import Element from './Element'
import ReactAddonsUpdate from 'react-addons-update' import ReactAddonsUpdate from 'react-addons-update'
import autobind from 'autobind-decorator' import autobind from 'autobind-decorator'
import { observer } from 'mobx-react' import { observer, inject } from 'mobx-react';
@inject(["elementGroupStore"]) @observer
@autobind @autobind
@observer
export default class ElementGroup extends React.Component { export default class ElementGroup extends React.Component {
cloneElement(element) { cloneElement(element) {
this.store().cloneElement(element) this.store().cloneElement(element)
......
...@@ -2,12 +2,11 @@ import React from 'react' ...@@ -2,12 +2,11 @@ import React from 'react'
import ModalRepoForm from './ModalRepoForm' import ModalRepoForm from './ModalRepoForm'
import Loader from 'halogen/PulseLoader' import Loader from 'halogen/PulseLoader'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { observer } from 'mobx-react' import { observer, inject } from 'mobx-react';
import autobind from 'autobind-decorator' import autobind from 'autobind-decorator'
import stores from '../stores'
@autobind @autobind
@observer @inject(["headerStore"]) @observer
export default class Header extends React.Component { export default class Header extends React.Component {
componentDidMount() { componentDidMount() {
this.props.headerStore.loadHeaderData() this.props.headerStore.loadHeaderData()
...@@ -41,7 +40,7 @@ export default class Header extends React.Component { ...@@ -41,7 +40,7 @@ export default class Header extends React.Component {
return ( return (
<div className="text-left top-header"> <div className="text-left top-header">
<ModalRepoForm handleNewRepo={ this.addRepo } modalRepoFormStore={ stores.ModalRepoFormStore } /> <ModalRepoForm handleNewRepo={ this.addRepo } />
<div className='col-md-10'> <div className='col-md-10'>
{ result } { result }
</div> </div>
......
...@@ -3,10 +3,10 @@ import { Modal, Button } from 'react-bootstrap' ...@@ -3,10 +3,10 @@ import { Modal, Button } from 'react-bootstrap'
import EventEmitter from '../libs/eventEmitter' import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery' import $ from 'jquery'
import autobind from 'autobind-decorator' import autobind from 'autobind-decorator'
import { observer } from 'mobx-react' import { observer, inject } from 'mobx-react';
@inject(["modalRepoFormStore"]) @observer
@autobind @autobind
@observer
export default class ModalRepoForm extends React.Component { export default class ModalRepoForm extends React.Component {
store() { store() {
return this.props.modalRepoFormStore return this.props.modalRepoFormStore
...@@ -17,6 +17,7 @@ export default class ModalRepoForm extends React.Component { ...@@ -17,6 +17,7 @@ export default class ModalRepoForm extends React.Component {
} }
open() { open() {
console.log(this);
this.store().open(); this.store().open();
} }
......
...@@ -3,7 +3,6 @@ import ElementGroup from '../components/ElementGroup' ...@@ -3,7 +3,6 @@ import ElementGroup from '../components/ElementGroup'
import Header from '../components/Header' import Header from '../components/Header'
import AlertContainer from 'react-alert' import AlertContainer from 'react-alert'
import EventEmitter from '../libs/eventEmitter' import EventEmitter from '../libs/eventEmitter'
import stores from '../stores'
export default class Spd extends React.Component { export default class Spd extends React.Component {
componentDidMount() { componentDidMount() {
...@@ -39,12 +38,12 @@ export default class Spd extends React.Component { ...@@ -39,12 +38,12 @@ export default class Spd extends React.Component {
<div id="app"> <div id="app">
<AlertContainer ref={a => this.msg = a} {...this.alertOptions} /> <AlertContainer ref={a => this.msg = a} {...this.alertOptions} />
<div className="row"> <div className="row">
<Header headerStore={ stores.HeaderStore } /> <Header />
</div> </div>
<div className="row"> <div className="row">
<div className="col-md-2 sidebar" id='sidebar'> <div className="col-md-2 sidebar" id='sidebar'>
<h3 className='sidebar-header'>元件</h3> <h3 className='sidebar-header'>元件</h3>
<ElementGroup elementGroupStore={ stores.ElementGroupStore } /> <ElementGroup />
</div> </div>
<div id="dropzone" className="col-md-10 dropzone"> <div id="dropzone" className="col-md-10 dropzone">
{this.props.children} {this.props.children}
......
...@@ -8,11 +8,20 @@ import { ...@@ -8,11 +8,20 @@ import {
import RegionalDesign from './components/RegionalDesign' import RegionalDesign from './components/RegionalDesign'
import { Provider } from 'mobx-react'
import elementGroupStore from './stores/ElementGroup'
import headerStore from './stores/Header'
import modalRepoFormStore from './stores/ModalRepoForm'
const stores = { elementGroupStore, headerStore, modalRepoFormStore }
ReactDOM.render( ReactDOM.render(
<Router handler={Spd} history={Router}> <Provider { ...stores }>
<Spd> <Router handler={Spd} history={Router}>
<Route path="/web/regional_design/:id" component={RegionalDesign} /> <Spd>
</Spd> <Route path="/web/regional_design/:id" component={RegionalDesign} />
</Router>, </Spd>
</Router>
</Provider>,
document.getElementById('root') document.getElementById('root')
); );
import ModalRepoFormStore from './ModalRepoForm'
import HeaderStore from './Header'
import ElementGroupStore from './ElementGroup'
const stores = {
ModalRepoFormStore,
HeaderStore,
ElementGroupStore
}
export default stores
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!