-
Notifications
You must be signed in to change notification settings - Fork 61
/
index.js
117 lines (110 loc) · 2.76 KB
/
index.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
*
* @authors hechuanhua ([email protected])
* @date 2016-06-05 00:58:23
* @version $Id$
*/
import React,{Component} from 'react'
import { render } from 'react-dom'
import thunkMiddleware from 'redux-thunk'
import {Provider,connect} from 'react-redux'
import {combineReducers, createStore, applyMiddleware} from "redux"
import { Router, Route, IndexRoute, Link, IndexLink, browserHistory,hashHistory } from 'react-router'
import * as actions from './js/actions/index'
import stores from './js/reducers/index'
import Index from './js/components/index'
// import Publish from './js/components/publish'
// import About from './js/components/about'
// import Details from './js/components/details'
// import Search from './js/components/search'
//import Page404 from './js/components/page404'
import MobBox from './js/containers/mobBox'
import Nav from './js/containers/nav'
import TipsBox from './js/containers/tipsBox'
import "./less/style.less"
let store=createStore(
stores,
applyMiddleware(thunkMiddleware)
)
const About = {
path: 'about',
getComponent(nextState, cb) {
require.ensure([], (require) => {
return cb(null, require('./js/components/about'))
})
}
}
const Search = {
path: 'search',
getComponent(nextState, cb) {
require.ensure([], (require) => {
return cb(null, require('./js/components/search'))
})
}
}
const Details = {
path: ':name/:date/:title',
getComponent(nextState, cb) {
require.ensure([], (require) => {
return cb(null, require('./js/components/details'))
})
}
}
const Publish = {
path: 'publish',
getComponent(nextState, cb) {
require.ensure([], (require) => {
return cb(null, require('./js/components/publish'))
})
}
}
const Page404 = {
path: '*',
getComponent(nextState, cb) {
require.ensure([], (require) => {
return cb(null, require('./js/components/Page404'))
})
}
}
class App extends Component{
constructor(props) {
super(props)
}
componentDidMount(){
let WinH=document.documentElement.clientHeight
let wrap=document.querySelector('.container')
wrap.style.minHeight=(WinH-270)+"px"
}
render(){
return <div className="page">
<Nav/>
<div className="container content">{this.props.children || <Index/>}</div>
<MobBox />
<Foot/>
<TipsBox/>
</div>
}
}
const Foot=()=>(
<div className="Footer">联系方式:[email protected]</div>
)
const rootRoute = {
component: 'div',
childRoutes: [ {
path: '/',
component: App,
childRoutes: [
Publish,
About,
Search,
Details,
Page404
]
} ]
}
render((
<Provider store={store}>
<Router history={hashHistory} routes={rootRoute} >
</Router>
</Provider>
),document.getElementById("APP"))