From de9b3ecd68d7da3fc7beb4f5c96f63b53dde0206 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 21 Jul 2017 17:10:06 +0900 Subject: [PATCH] router --- src/ts/@overflow/app/index.tsx | 17 ++++++----- src/ts/@overflow/app/views/App.tsx | 4 +++ src/ts/@overflow/app/views/error/Error404.tsx | 27 +++++++++++++++++ .../@overflow/app/views/layout/AppLayout.tsx | 8 +++-- .../app/views/layout/ErrorLayout.tsx | 29 +++++++++++++++++++ 5 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 src/ts/@overflow/app/views/error/Error404.tsx create mode 100644 src/ts/@overflow/app/views/layout/ErrorLayout.tsx diff --git a/src/ts/@overflow/app/index.tsx b/src/ts/@overflow/app/index.tsx index 9e66e88..7e28aec 100644 --- a/src/ts/@overflow/app/index.tsx +++ b/src/ts/@overflow/app/index.tsx @@ -41,7 +41,12 @@ class Application { this.history = history; } - public async start(): Promise { + public static async Run(): Promise { + let application = new Application(); + return application.start(); + } + + private async start(): Promise { try { this.container = await Platform.getAppContainer(this.config.container.placeholderID); this.displayLoading(); @@ -59,7 +64,7 @@ class Application { } } - public initContext(): Promise { + private initContext(): Promise { const appContext = new Promise(resolve => { const context = AppContext.getContext(); resolve(context); @@ -68,7 +73,7 @@ class Application { return appContext; } - public initRpcClient(): Promise { + private initRpcClient(): Promise { const rpcClient = new Promise((resolve, reject) => { let client = new WebSocketRPC(this.config.rpc.url); client.initialize() @@ -83,7 +88,7 @@ class Application { return rpcClient; } - public initSagaEffect(): Promise { + private initSagaEffect(): Promise { const rpcClient = new Promise(resolve => { this.sagaMiddleware.run(sagas); resolve(); @@ -139,6 +144,4 @@ class Application { } -let application = new Application(); -application.start(); - +Application.Run(); diff --git a/src/ts/@overflow/app/views/App.tsx b/src/ts/@overflow/app/views/App.tsx index fffbcb1..6805834 100644 --- a/src/ts/@overflow/app/views/App.tsx +++ b/src/ts/@overflow/app/views/App.tsx @@ -3,6 +3,9 @@ import { Route, Switch } from 'react-router-dom'; import AccountLayout from './layout/AccountLayout'; import AppLayout from './layout/AppLayout'; +import ErrorLayout from './layout/ErrorLayout'; + + import TempLayout from './layout/TempLayout'; @@ -20,6 +23,7 @@ class App extends React.Component { public render(): JSX.Element { return ( + diff --git a/src/ts/@overflow/app/views/error/Error404.tsx b/src/ts/@overflow/app/views/error/Error404.tsx new file mode 100644 index 0000000..90c05d1 --- /dev/null +++ b/src/ts/@overflow/app/views/error/Error404.tsx @@ -0,0 +1,27 @@ +import * as React from 'react'; +import { RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom'; + +export interface Props extends RouteComponentProps { +} +export interface State { +} + +class Error404 extends React.Component { + + public constructor(props?: Props, context?: State) { + super(props, context); + + } + + public render(): JSX.Element { + return ( +
+ URL is not exist. +
+ ); + } + +} + + +export default Error404; diff --git a/src/ts/@overflow/app/views/layout/AppLayout.tsx b/src/ts/@overflow/app/views/layout/AppLayout.tsx index d996b3e..8059018 100644 --- a/src/ts/@overflow/app/views/layout/AppLayout.tsx +++ b/src/ts/@overflow/app/views/layout/AppLayout.tsx @@ -1,5 +1,5 @@ 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 { Header } from './Header'; import { Footer } from './Footer'; @@ -34,8 +34,10 @@ export class AppLayout extends React.Component {
- - + + + +