-
Notifications
You must be signed in to change notification settings - Fork 445
/
index.js
87 lines (75 loc) · 3.04 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
/**
* 程序的入口, 类似java中的main
*/
import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux'
import {Router, Route, IndexRoute, hashHistory} from 'react-router';
import './utils/index.js'; // 引入各种prototype辅助方法
import store from 'redux/store.js'; // redux store
// 开始引入各种自定义的组件
import App from './components/App';
import Welcome from './components/Welcome';
import Error from './components/Error';
import Hello from './components/Hello';
//import DBTable from './components/DBTable';
// 将DBTable组件做成动态路由, 减小bundle size
// 注意不要再import DBTable了, 不然就没意义了
// 一些比较大/不常用的组件, 都可以考虑做成动态路由
const DBTableContainer = (location, cb) => {
require.ensure([], require => {
cb(null, require('./components/DBTable').default)
}, 'DBTable');
};
// 路由表, 只要menu.js中所有的叶子节点配置了路由就可以了
// 我本来想根据menu.js自动生成路由表, 但那样太不灵活了, 还是自己配置好些
const routes = (
<Provider store={store}>
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Welcome}/>
<Route path="index">
<Route path="option1" tableName="test" getComponent={DBTableContainer}/>
<Route path="option2" tableName="testSms" getComponent={DBTableContainer}/>
<Route path="option3" tableName="testAction" getComponent={DBTableContainer}/>
</Route>
<Route path="daohang">
<Route path="555" component={Hello}/>
<Route path="sanji">
<Route path="666" component={Hello}/>
<Route path="777" component={Hello}/>
<Route path="888" component={Hello}/>
<Route path="999" component={Hello}/>
</Route>
</Route>
<Route path="test">
<Route path="aaa" component={Hello}/>
<Route path="bbb" component={Hello}/>
<Route path="ccc" component={Hello}/>
<Route path="sanjiaaa">
<Route path="666aa" component={Hello}/>
</Route>
<Route path="sanjibbb">
<Route path="666bb" component={Hello}/>
</Route>
</Route>
<Route path="headerMenu5">
<Route path="headerMenu5000000" component={Hello}/>
<Route path="headerMenu51111">
<Route path="headerMenu51111aa" component={Hello}/>
<Route path="headerMenu51111bb" component={Hello}/>
</Route>
<Route path="headerMenu52222">
<Route path="headerMenu52222aa" component={Hello}/>
<Route path="headerMenu52222bb" component={Hello}/>
</Route>
</Route>
<Route path="headerMenu4" component={Hello}/>
<Route path="alone" component={Hello}/>
<Route path="alone2" component={Hello}/>
<Route path="*" component={Error}/>
</Route>
</Router>
</Provider>
);
ReactDOM.render(routes, document.getElementById('root'));