forked from thx/rap2-dolores
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.jsx
167 lines (155 loc) · 6.87 KB
/
routes.jsx
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import React from 'react'
import { Bundle, PropTypes, Switch, Route } from './family'
import { NoMatch, Spin } from './components/utils'
import Header from './components/common/Header'
import Footer from './components/common/Footer'
import Home from './components/home/Home'
import LoginForm from './components/account/LoginForm'
import RegisterForm from './components/account/RegisterForm'
const UserList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/account/UserList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const JoinedRepositoryList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/repository/JoinedRepositoryList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const JoinedRepositoryListWithCreateForm = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/repository/JoinedRepositoryList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} create /> : null}
</Bundle>
)
const AllRepositoryList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/repository/AllRepositoryList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const RepositoryEditor = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/editor/RepositoryEditor')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const RepositoryTester = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/tester/Tester')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const RepositoryChecker = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/checker/Checker')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const JoinedOrganizationList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/organization/JoinedOrganizationList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const AllOrganizationList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/organization/AllOrganizationList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const OrganizationRepositoryList = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/organization/OrganizationRepositoryList')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const Status = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/status/Status')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const API = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/api/API')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
// import Utils from './components/utils/Utils'
const Utils = (props) => (
<Bundle load={cb => require.ensure([], require => cb(require('./components/utils/Utils')))}>
{CustomComponent => CustomComponent ? <CustomComponent {...props} /> : null}
</Bundle>
)
const Routes = ({ match, location }, { store }) => {
let auth = store.getState().auth
if (!auth) return <Spin /> // 渲染整站开屏动画,已经在 src/index 中实现。这里的代码用于支持没有接入 SSO 的情况。
if (!auth.id) { // 引导用户登陆,已经在 src/index 中实现。这里的代码用于支持没有接入 SSO 的情况。
return (
<article>
{/* <Route component={Header}/> */}
<Switch>
<Route path='/account/register' component={RegisterForm} />
<Route component={LoginForm} />
</Switch>
{/* <Footer/> */}
</article>
)
}
return (
<article className='Routes'>
<Route component={Header} />
<div className='body'>
<Switch>
<Route exact path='/' component={Home} />
<Route path='/repository' children={() => (
<Switch>
<Route exact path='/repository' component={JoinedRepositoryList} />
<Route exact path='/repository/joined' component={JoinedRepositoryList} />
<Route exact path='/repository/joined/create' component={JoinedRepositoryListWithCreateForm} />
<Route exact path='/repository/all' component={AllRepositoryList} />
<Route exact path='/repository/editor' component={RepositoryEditor} />
<Route exact path='/repository/tester' component={RepositoryTester} />
<Route exact path='/repository/checker' component={RepositoryChecker} />
<Route component={NoMatch} />
</Switch>
)} />
<Route path='/organization' children={() => (
<Switch>
<Route exact path='/organization' component={JoinedOrganizationList} />
<Route exact path='/organization/joined' component={JoinedOrganizationList} />
<Route exact path='/organization/all' component={AllOrganizationList} />
<Route exact path='/organization/repository' component={OrganizationRepositoryList} />
<Route exact path='/organization/repository/editor' component={RepositoryEditor} />
<Route component={NoMatch} />
</Switch>
)} />
<Route path='/status' children={() => (
<Switch>
<Route path='/status' component={Status} />
<Route component={NoMatch} />
</Switch>
)} />
<Route path='/account' children={() => (
<Switch>
<Route exact path='/account' component={UserList} />
<Route path='/account/users' component={UserList} />
<Route path='/account/login' component={LoginForm} />
<Route path='/account/register' component={RegisterForm} />
<Route component={NoMatch} />
</Switch>
)} />
<Route path='/utils' children={() => (
<div className='container'>
<Route path='/utils' component={Utils} />
</div>
)} />
<Route path='/api' children={() => (
<Switch>
<Route exact path='/api' component={API} />
<Route component={NoMatch} />
</Switch>
)} />
<Route component={NoMatch} />
</Switch>
</div>
<Footer />
<div id='portal' />
</article>
)
}
Routes.contextTypes = {
store: PropTypes.object
}
export default Routes