content.jsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import './content.less';
  4. import LeftTab from './leftTab';
  5. class Content extends Component {
  6. constructor() {
  7. super();
  8. this.state = {
  9. loading: false,
  10. component: 'div',
  11. };
  12. }
  13. componentWillMount() {
  14. if (window.location.hash) {
  15. this.getKey(window.location.hash.substr(1));
  16. } else {
  17. this.getKey("star");
  18. };
  19. }
  20. getKey(key) {
  21. switch (key) {
  22. case 'star':
  23. require.ensure([], () => {
  24. const Star = require('./bigShot/star').default;
  25. this.setState({
  26. component: Star
  27. });
  28. });
  29. break;
  30. case 'lecture':
  31. require.ensure([], () => {
  32. const Lecture = require('./bigShot/lecture').default;
  33. this.setState({
  34. component: Lecture
  35. });
  36. });
  37. break;
  38. case 'banner':
  39. require.ensure([], () => {
  40. const Banner = require('./bannerManage/bannerManage').default;
  41. this.setState({
  42. component: Banner
  43. });
  44. });
  45. break;
  46. };
  47. window.location.hash = key;
  48. }
  49. render() {
  50. return (
  51. <div className="manage-content">
  52. <LeftTab handlekey={this.getKey.bind(this)} />
  53. <div className="content-right">
  54. <this.state.component />
  55. </div>
  56. </div>
  57. )
  58. }
  59. }
  60. export default Content;