import React, { Component } from 'react';
import '../content.less';
import './content.less';
import LeftTab from './leftTab';


class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: 'div',
        };
    }
    componentWillMount() {
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
            this.getKey("star");
        };
    }
    getKey(key) {
        switch (key) {
            case 'star':
                require.ensure([], () => {
                    const Star = require('./bigShot/star').default;
                    this.setState({
                        component: Star
                    });
                });
                break;
            case 'lecture':
                require.ensure([], () => {
                    const Lecture = require('./bigShot/lecture').default;
                    this.setState({
                        component: Lecture
                    });
                });
                break;
            case 'banner':
                require.ensure([], () => {
                    const Banner = require('./bannerManage/bannerManage').default;
                    this.setState({
                        component: Banner
                    });
                });
                break;
            case 'flash':
                require.ensure([], () => {
                    const Flash = require('./news/flash').default;
                    this.setState({
                        component: Flash
                    });
                });
                break;
            case 'nationalPolicy':
                require.ensure([], () => {
                    const NationalPolicy = require('./news/nationalPolicy').default;
                    this.setState({
                        component: NationalPolicy
                    });
                });
                break;
            case 'localPolicy':
                require.ensure([], () => {
                    const LocalPolicy = require('./news/localPolicy').default;
                    this.setState({
                        component: LocalPolicy
                    });
                });
                break;
            case 'contact':
                require.ensure([], () => {
                    const Contact = require('./news/contact').default;
                    this.setState({
                        component: Contact
                    });
                });
                break;
        };
        window.location.hash = key;
    }
    render() {
        return (
            <div className="manage-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                    <this.state.component />
                </div>
            </div>
        )
    }
}

export default Content;
