router
This commit is contained in:
parent
c54dbd7d33
commit
de9b3ecd68
|
@ -41,7 +41,12 @@ class Application {
|
||||||
this.history = history;
|
this.history = history;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start(): Promise<void> {
|
public static async Run(): Promise<void> {
|
||||||
|
let application = new Application();
|
||||||
|
return application.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async start(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.container = await Platform.getAppContainer(this.config.container.placeholderID);
|
this.container = await Platform.getAppContainer(this.config.container.placeholderID);
|
||||||
this.displayLoading();
|
this.displayLoading();
|
||||||
|
@ -59,7 +64,7 @@ class Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public initContext(): Promise<AppContext> {
|
private initContext(): Promise<AppContext> {
|
||||||
const appContext = new Promise<AppContext>(resolve => {
|
const appContext = new Promise<AppContext>(resolve => {
|
||||||
const context = AppContext.getContext();
|
const context = AppContext.getContext();
|
||||||
resolve(context);
|
resolve(context);
|
||||||
|
@ -68,7 +73,7 @@ class Application {
|
||||||
return appContext;
|
return appContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public initRpcClient(): Promise<WebSocketRPC> {
|
private initRpcClient(): Promise<WebSocketRPC> {
|
||||||
const rpcClient = new Promise<WebSocketRPC>((resolve, reject) => {
|
const rpcClient = new Promise<WebSocketRPC>((resolve, reject) => {
|
||||||
let client = new WebSocketRPC(this.config.rpc.url);
|
let client = new WebSocketRPC(this.config.rpc.url);
|
||||||
client.initialize()
|
client.initialize()
|
||||||
|
@ -83,7 +88,7 @@ class Application {
|
||||||
return rpcClient;
|
return rpcClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public initSagaEffect(): Promise<void> {
|
private initSagaEffect(): Promise<void> {
|
||||||
const rpcClient = new Promise<void>(resolve => {
|
const rpcClient = new Promise<void>(resolve => {
|
||||||
this.sagaMiddleware.run(sagas);
|
this.sagaMiddleware.run(sagas);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -139,6 +144,4 @@ class Application {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let application = new Application();
|
Application.Run();
|
||||||
application.start();
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ import { Route, Switch } from 'react-router-dom';
|
||||||
|
|
||||||
import AccountLayout from './layout/AccountLayout';
|
import AccountLayout from './layout/AccountLayout';
|
||||||
import AppLayout from './layout/AppLayout';
|
import AppLayout from './layout/AppLayout';
|
||||||
|
import ErrorLayout from './layout/ErrorLayout';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import TempLayout from './layout/TempLayout';
|
import TempLayout from './layout/TempLayout';
|
||||||
|
|
||||||
|
@ -20,6 +23,7 @@ class App extends React.Component<Props, State> {
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
|
<Route path='/error' component={ErrorLayout}/>
|
||||||
<Route path='/temp' component={TempLayout}/>
|
<Route path='/temp' component={TempLayout}/>
|
||||||
<Route path='/account' component={AccountLayout}/>
|
<Route path='/account' component={AccountLayout}/>
|
||||||
<Route path='/' component={AppLayout}/>
|
<Route path='/' component={AppLayout}/>
|
||||||
|
|
27
src/ts/@overflow/app/views/error/Error404.tsx
Normal file
27
src/ts/@overflow/app/views/error/Error404.tsx
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom';
|
||||||
|
|
||||||
|
export interface Props extends RouteComponentProps<any> {
|
||||||
|
}
|
||||||
|
export interface State {
|
||||||
|
}
|
||||||
|
|
||||||
|
class Error404 extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
public constructor(props?: Props, context?: State) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
URL is not exist.
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default Error404;
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { RouteComponentProps, RouteProps, Route } from 'react-router-dom';
|
import { Redirect, RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom';
|
||||||
import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react';
|
import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react';
|
||||||
import { Header } from './Header';
|
import { Header } from './Header';
|
||||||
import { Footer } from './Footer';
|
import { Footer } from './Footer';
|
||||||
|
@ -34,8 +34,10 @@ export class AppLayout extends React.Component<Props, State> {
|
||||||
<LeftMenu />
|
<LeftMenu />
|
||||||
<Segment vertical style={{ margin: '0 0 0 210px', padding: '0' }}>
|
<Segment vertical style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||||
<Header />
|
<Header />
|
||||||
<Route path={`${this.props.match.url}`} component={Home}/>
|
<Switch>
|
||||||
|
<Route exact={true} path={`${this.props.match.url}`} component={Home}/>
|
||||||
|
<Redirect to='/error/404' />
|
||||||
|
</Switch>
|
||||||
<Footer />
|
<Footer />
|
||||||
</Segment>
|
</Segment>
|
||||||
</Container >
|
</Container >
|
||||||
|
|
29
src/ts/@overflow/app/views/layout/ErrorLayout.tsx
Normal file
29
src/ts/@overflow/app/views/layout/ErrorLayout.tsx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom';
|
||||||
|
|
||||||
|
import Error404 from '../error/Error404';
|
||||||
|
|
||||||
|
export interface Props extends RouteComponentProps<any> {
|
||||||
|
}
|
||||||
|
export interface State {
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorLayout extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
public constructor(props?: Props, context?: State) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<Switch>
|
||||||
|
<Route path={`${this.props.match.url}/404`} component={Error404}/>
|
||||||
|
</Switch>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default ErrorLayout;
|
Loading…
Reference in New Issue
Block a user