content.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import './content.less';
  4. import LeftTab from '../leftTab';
  5. import { getMenu } from '../publicMenu.js'
  6. class Content extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. loading: false,
  11. component: <div />,
  12. };
  13. }
  14. componentWillMount() {
  15. var ids = window.location.href.indexOf('rid=');
  16. var idk = window.location.href.substr(ids + 4);
  17. var rid = idk.split('#');
  18. let menu = getMenu(rid);
  19. let curry;
  20. if (menu[0].subMenus.length > 0) {
  21. curry = menu[0].subMenus[0].url.split('#');
  22. } else {
  23. curry = menu[0].url.split('#');
  24. };
  25. if (window.location.hash) {
  26. this.getKey(window.location.hash.substr(1));
  27. } else {
  28. this.getKey(curry[1]);
  29. };
  30. }
  31. getKey(key) {
  32. switch (key) {
  33. case 'standard':
  34. require.ensure([], () => {
  35. const Standard = require('./stList/index').default;
  36. this.setState({
  37. component: <Standard />
  38. });
  39. });
  40. break;
  41. default:
  42. require.ensure([], () => {
  43. const Module = require('../module').default;
  44. this.setState({
  45. component: <Module />
  46. });
  47. });
  48. };
  49. window.location.hash = key;
  50. }
  51. render() {
  52. return (
  53. <div className="manage-content">
  54. <LeftTab handlekey={this.getKey.bind(this)} />
  55. <div className="content-right">
  56. {this.state.component}
  57. </div>
  58. </div>
  59. )
  60. }
  61. }
  62. export default Content;