Skip to content

Commit 81991e8

Browse files
authored
Merge pull request #1 from Reaper622/dev
添加icon与manifest文件,修复Header无法显示当前页的问题
2 parents 6546de3 + d6e343a commit 81991e8

File tree

7 files changed

+69
-19
lines changed

7 files changed

+69
-19
lines changed

public/favicon.ico

61.1 KB
Binary file not shown.

public/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
7+
<link rel="manifest" href="./manifest.json" />
68
<meta http-equiv="X-UA-Compatible" content="ie=edge">
79
<title>Reaper Lee</title>
810
</head>

public/manifest.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "The Blog",
3+
"name": "Reaper Lee's Blog",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}

src/Pages/Archives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Archives extends Component {
4949
render() {
5050
return (
5151
<Layout>
52-
<TheHeader current={'archives'}></TheHeader>
52+
<TheHeader></TheHeader>
5353
<Content>
5454
<Row>
5555
<Col offset={4} span={12} style={{background: '#fff', minHeight: '600px' , padding: '20px 0'}}>

src/Pages/Friend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Friend extends Component {
4141
render() {
4242
return (
4343
<Layout>
44-
<TheHeader current={'friend'}></TheHeader>
44+
<TheHeader></TheHeader>
4545
<Content>
4646
<Row>
4747
<Col offset={4} span={12} style={{background: '#fff', minHeight: '600px' , padding: '20px 50px'}}>

src/Pages/Index.js

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import TheHeader from '@components/Header'
33
import TheFooter from '@components/Footer'
44
import Blog from '@components/Blog'
55
import Axios from 'axios'
6-
import {Layout, Row, Col, Pagination, Spin} from 'antd'
6+
import {Layout, Row, Col, Pagination} from 'antd'
77
import { connect } from 'react-redux'
88
import {loadBlogsByPage} from '../redux/store'
99
import config from '../../config.json'
10+
import { CSSTransition } from 'react-transition-group'
1011

1112
const { Content } = Layout
1213

@@ -18,7 +19,7 @@ class Index extends Component {
1819
constructor(props) {
1920
super(props)
2021
this.state = {
21-
loading: true
22+
loaded: false
2223
}
2324
}
2425

@@ -29,19 +30,18 @@ class Index extends Component {
2930
}
3031

3132
getBlogs(page) {
32-
this.setState({ loading: true})
3333
Axios.get(`${config.server_url}/blog/getblogs/${page}`)
34-
.then(res => {
35-
res.data.blogs.map(blog => {
36-
blog.time = blog.time.split('T')[0]
37-
})
38-
this.setState({ loading: false})
39-
this.props.loadBlogsByPage(res.data)
34+
.then(res => {
35+
res.data.blogs.map(blog => {
36+
blog.time = blog.time.split('T')[0]
4037
})
38+
this.setState({ loaded: true})
39+
this.props.loadBlogsByPage(res.data)
40+
})
4141
}
42-
42+
4343
handlePageChange(page) {
44-
44+
this.setState({ loaded: false})
4545
this.getBlogs(page - 1)
4646
}
4747

@@ -51,11 +51,16 @@ class Index extends Component {
5151
<TheHeader></TheHeader>
5252
<Content>
5353
<Row>
54-
<Col offset={4} span={12} >
55-
<Spin spinning={this.state.loading} style={{minHeight: '1000 px'}}>
56-
{ this.props.blogsToShow ? this.props.blogsToShow.map(blog => <Blog key={blog.id} {...blog} isPriview={true} />) : null}
57-
</Spin>
54+
<CSSTransition
55+
in={this.state.loaded}
56+
timeout={2000}
57+
classNames='fade'
58+
appear={true}
59+
>
60+
<Col offset={4} span={12} style={{minHeight: '600px'}} >
61+
{ this.props.blogsToShow ? this.props.blogsToShow.map(blog => <Blog key={blog.id} {...blog} isPriview={true} />) : <div></div>}
5862
</Col>
63+
</CSSTransition>
5964
</Row>
6065
<Row style={{margin: '20px 0 50px'}}>
6166
<Col offset={4} span={12} style={{padding: '20px 0', background: '#fff', display: 'flex', justifyContent: 'center'}}>
@@ -64,6 +69,34 @@ class Index extends Component {
6469
</Row>
6570
</Content>
6671
<TheFooter></TheFooter>
72+
<style jsx>{`
73+
/* enter 为入场前的瞬间, appear指页面第一次加载前的瞬间(auto) */
74+
.fade-enter, .fade-appear {
75+
opacity: 0;
76+
}
77+
/* enter-active 为入场到入场结束的过程 appear-active 为页面第一次自动执行 */
78+
.fade-enter-active, .fade-appear-active {
79+
opacity: 1;
80+
transition: opacity 1s ease-in;
81+
}
82+
/* 入场动画执行完毕后, 保持状态 */
83+
.fade-enter-done {
84+
opacity: 1;
85+
}
86+
/*出厂前的瞬间 */
87+
.fade-exit {
88+
opacity: 1;
89+
}
90+
/*出场到出场结束的过程 */
91+
.fade-exit-active {
92+
opacity: 0;
93+
transition: opacity 1s ease-in;
94+
}
95+
/*出场动画执行后保持状态 */
96+
.fade-exit-done {
97+
opacity: 0;
98+
}
99+
`}</style>
67100
</Layout>
68101
)
69102
}

src/components/Header.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const LinkMeMore = (
2020
</Menu>
2121
)
2222

23-
function TheLayout({location, history, current}) {
24-
const [tabKey, setTabKey] = useState(current || 'index')
23+
function TheLayout({location, history}) {
24+
const [tabKey, setTabKey] = useState(location.pathname.split('/')[1] || 'index')
2525
const [isAvatarHover, setIsAvatarHover] = useState(false)
2626
const switchTab = useCallback((index) => {
2727
setTabKey(index)

0 commit comments

Comments
 (0)