Skip to content

Commit 4891376

Browse files
committed
router configuration
1 parent f440608 commit 4891376

File tree

6 files changed

+95
-38
lines changed

6 files changed

+95
-38
lines changed

reactjs/src/App.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@ import * as React from "react";
22
import "./App.css";
33

44
import * as abpUserConfiguration from "./services/abpUserConfigurationService";
5-
import { Switch, Route, withRouter } from "react-router-dom";
6-
import Login from "./scenes/Login";
5+
import { withRouter } from "react-router-dom";
6+
import Layout from "./scenes/Layout";
77
class App extends React.Component {
88
componentDidMount() {
99
console.log(abpUserConfiguration.initialize());
1010
}
1111
public render() {
1212
return (
13-
<Switch>
14-
<Route path="/login" component={Login} />
15-
<Route path="/" component={Login} />
16-
{/* <PrivateRouter path="/activity" component={Activity} />
17-
<PublicRouter path="/login" component={Login} />
18-
<PublicRouter path="/forgetPassword" component={ForgetPassword} />
19-
<PrivateRouter path="/profile/:id" component={Profile} />
20-
<PrivateRouter path="/pushNotification" component={PushNotification} />
21-
<PublicRouter path="/" component={Login} />
22-
<PrivateRouter path="/activity/create" component={Profile} /> */}
23-
</Switch>
13+
<Layout />
2414
);
2515
}
2616
}

reactjs/src/scenes/Layout/index.tsx

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,73 @@
11
import * as React from "react";
22
import { Layout, Menu, Icon } from "antd";
33
import "./index.css";
4+
import { Route, Switch, withRouter } from 'react-router';
5+
import Logins from '../Login';
6+
import Users from '../Users';
7+
import Tenants from '../Tenants';
8+
import Rules from '../Rules';
49

510
const { Header, Sider, Content } = Layout;
611

7-
class SiderDemo extends React.Component {
12+
class LayoutComponent extends React.Component<any> {
813
state = {
9-
collapsed: false
14+
collapsed: false,
1015
};
1116

1217
toggle = () => {
1318
this.setState({
14-
collapsed: !this.state.collapsed
19+
collapsed: !this.state.collapsed,
1520
});
16-
};
21+
}
1722

1823
render() {
1924
return (
2025
<Layout>
21-
<Sider trigger={null} collapsible collapsed={this.state.collapsed}>
26+
<Sider
27+
trigger={null}
28+
collapsible
29+
collapsed={this.state.collapsed}
30+
>
2231
<div className="logo" />
23-
<Menu theme="dark" mode="inline" defaultSelectedKeys={["1"]}>
32+
<Menu theme="dark" mode="inline" defaultSelectedKeys={['1']}>
2433
<Menu.Item key="1">
25-
<Icon type="user" />
26-
<span>nav 1</span>
34+
<Icon type="home" />
35+
<span onClick={() => this.props.history.push("/")}>Home</span>
2736
</Menu.Item>
2837
<Menu.Item key="2">
2938
<Icon type="video-camera" />
30-
<span>nav 2</span>
39+
<span onClick={() => this.props.history.push("/tenants")}>Tenants</span>
3140
</Menu.Item>
3241
<Menu.Item key="3">
42+
<Icon type="user" />
43+
<span onClick={() => this.props.history.push("/users")}>Users</span>
44+
</Menu.Item>
45+
<Menu.Item key="4">
3346
<Icon type="upload" />
34-
<span>nav 3</span>
47+
<span onClick={() => this.props.history.push("/rules")}>Rules</span>
3548
</Menu.Item>
3649
</Menu>
3750
</Sider>
3851
<Layout>
39-
<Header style={{ background: "#fff", padding: 0 }}>
52+
<Header style={{ background: '#fff', padding: 0 }}>
4053
<Icon
4154
className="trigger"
42-
type={this.state.collapsed ? "menu-unfold" : "menu-fold"}
55+
type={this.state.collapsed ? 'menu-unfold' : 'menu-fold'}
4356
onClick={this.toggle}
4457
/>
4558
</Header>
46-
<Content
47-
style={{
48-
margin: "24px 16px",
49-
padding: 24,
50-
background: "#fff",
51-
minHeight: 280
52-
}}
53-
>
54-
Content
59+
<Content style={{ margin: '24px 16px', padding: 24, background: '#fff', minHeight: 280 }}>
60+
<Switch>
61+
<Route path="/login" component={Logins} />
62+
<Route path="/users" component={Users} />
63+
<Route path="/tenants" component={Tenants} />
64+
<Route path="/rules" component={Rules} />
65+
</Switch>
5566
</Content>
5667
</Layout>
5768
</Layout>
5869
);
5970
}
6071
}
6172

62-
export default SiderDemo;
73+
export default withRouter<any>(LayoutComponent);

reactjs/src/scenes/Login/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class Login extends React.Component<any, any> {
6666
rules: [
6767
{
6868
required: true,
69-
// tslint:disable-next-line:object-literal-sort-keys
7069
message: "Tenant name is required."
7170
}
7271
]
@@ -80,7 +79,6 @@ class Login extends React.Component<any, any> {
8079
}
8180
placeholder=""
8281
size="large"
83-
// onChange={}
8482
/>
8583
)}
8684
</FormItem>
@@ -94,7 +92,6 @@ class Login extends React.Component<any, any> {
9492
rules: [
9593
{
9694
required: true,
97-
// tslint:disable-next-line:object-literal-sort-keys
9895
message: "User Name is required."
9996
}
10097
]

reactjs/src/scenes/Rules/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from "react";
2+
import { inject, observer } from "mobx-react";
3+
4+
@inject("AuthenticationStores")
5+
@observer
6+
class Rules extends React.Component<any, any> {
7+
constructor(props: any) {
8+
super(props);
9+
}
10+
11+
render() {
12+
return (
13+
<p>Rule Component</p>
14+
)
15+
}
16+
17+
}
18+
19+
20+
export default Rules;

reactjs/src/scenes/Tenants/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from "react";
2+
import { inject, observer } from "mobx-react";
3+
4+
@inject("AuthenticationStores")
5+
@observer
6+
class Tenants extends React.Component<any, any> {
7+
constructor(props: any) {
8+
super(props);
9+
}
10+
11+
render() {
12+
return (
13+
<p>Tenant Component</p>
14+
)
15+
}
16+
17+
}
18+
19+
20+
export default Tenants;

reactjs/src/scenes/Users/index.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from "react";
2+
import { inject, observer } from "mobx-react";
3+
4+
@inject("AuthenticationStores")
5+
@observer
6+
class Users extends React.Component<any, any> {
7+
constructor(props: any) {
8+
super(props);
9+
}
10+
11+
render() {
12+
return (
13+
<p>User Component</p>
14+
)
15+
}
16+
17+
}
18+
19+
export default Users;

0 commit comments

Comments
 (0)