@@ -2,10 +2,11 @@ import React, { Component } from 'react'
22import TheHeader from '@components/Header/Header'
33import TheFooter from '@components/Footer/Footer'
44import Blog from '@components/Blog/Blog'
5+ import SideMenu from '@components/SideMenu/SideMenu'
56import Axios from 'axios'
67import { Layout , Row , Col , Pagination } from 'antd'
78import { connect } from 'react-redux'
8- import { loadBlogsByPage } from '../../redux/store'
9+ import { loadBlogsByPage , loadHotArticles } from '../../redux/store'
910import config from '../../../config.json'
1011import { CSSTransition } from 'react-transition-group'
1112
@@ -15,7 +16,7 @@ const { Content } = Layout
1516
1617@connect (
1718 state => state ,
18- { loadBlogsByPage }
19+ { loadBlogsByPage, loadHotArticles }
1920)
2021class Index extends Component {
2122 constructor ( props ) {
@@ -27,6 +28,7 @@ class Index extends Component {
2728
2829 componentDidMount ( ) {
2930 this . getBlogs ( 0 )
31+ this . getHotArticles ( )
3032 }
3133
3234 getBlogs ( page ) {
@@ -40,6 +42,13 @@ class Index extends Component {
4042 } )
4143 }
4244
45+ getHotArticles ( ) {
46+ Axios . get ( `${ config . server_url } /blog/gethotarticle` )
47+ . then ( res => {
48+ this . props . loadHotArticles ( res . data )
49+ } )
50+ }
51+
4352 handlePageChange ( page ) {
4453 this . setState ( { loaded : false } )
4554 this . getBlogs ( page - 1 )
@@ -61,6 +70,9 @@ class Index extends Component {
6170 { this . props . blogsToShow ? this . props . blogsToShow . map ( blog => < Blog key = { blog . id } { ...blog } isPriview = { true } /> ) : < div > </ div > }
6271 </ Col >
6372 </ CSSTransition >
73+ < Col xs = { { span : 0 } } xl = { { offset : 1 , span : 5 } } xxl = { { offset : 1 , span : 5 } } >
74+ { this . props . hotArticles ? < SideMenu hotArticles = { this . props . hotArticles } /> : null }
75+ </ Col >
6476 </ Row >
6577 < Row style = { { margin : '20px 0 50px' } } >
6678 < Col xs = { { span : 24 } } xl = { { offset : 4 , span : 12 } } xxl = { { offset : 4 , span : 12 } } style = { { padding : '20px 0' , background : '#fff' , display : 'flex' , justifyContent : 'center' } } >
0 commit comments