Skip to content

Commit f2195aa

Browse files
authored
Merge pull request #2 from Reaper622/dev
图标添加与动态加载
2 parents 81991e8 + 55915ff commit f2195aa

File tree

8 files changed

+53
-23
lines changed

8 files changed

+53
-23
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"react-hot-loader/babel",
88
"styled-components",
99
["@babel/plugin-proposal-decorators", { "legacy": true }],
10+
"@babel/plugin-syntax-dynamic-import"
1011
]
1112
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A system to build your own blog site.
66

77
修改一个配置文件,即可搭建出你自己的博客平台。
88

9-
线上演示地址: [reaperlee.cn](www.reaperlee.cn)
9+
线上演示地址: [reaperlee.cn](http://www.reaperlee.cn)
1010

1111

1212

config.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
"avatar": "https://avatars2.githubusercontent.com/u/33087372?s=460&v=4",
88
"intro": "The world's best FE developer",
99
"path": "https://github.com/LumiereXyloto"
10-
},
11-
{
12-
"name": "Lumiere Xyloto2",
13-
"avatar": "https://avatars2.githubusercontent.com/u/33087372?s=460&v=4",
14-
"intro": "The world's best FE developer",
15-
"path": "https://github.com/LumiereXyloto"
16-
},
17-
{
18-
"name": "Lumiere Xyloto3",
19-
"avatar": "https://avatars2.githubusercontent.com/u/33087372?s=460&v=4",
20-
"intro": "The world's best FE developer",
21-
"path": "https://github.com/LumiereXyloto"
2210
}
2311
],
2412
"server_url": "http://127.0.0.1:4000"

config/webpack.common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ const commonConfig = {
7777
threadPool: happyThreadPool
7878
}),
7979
new HtmlWebpackPlugin({
80-
template: 'public/index.html'
80+
template: 'public/index.html',
81+
favicon: 'public/favicon.ico'
8182
}),
8283
// 拷贝的静态资源不做打包处理
8384
new CopyWebpackPlugin([{

package-lock.json

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
},
2424
"homepage": "https://gitlab.com/Reaper622/react-cli-singlepage#README",
2525
"dependencies": {
26+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
2627
"@babel/polyfill": "^7.4.4",
2728
"animate.css": "^3.7.2",
2829
"antd": "^3.23.2",
@@ -39,6 +40,7 @@
3940
"ramda": "^0.26.1",
4041
"react": "^16.8.6",
4142
"react-dom": "^16.8.6",
43+
"react-loadable": "^5.5.0",
4244
"react-redux": "^7.1.1",
4345
"react-router-dom": "^5.0.1",
4446
"react-transition-group": "^4.3.0",

src/components/PageLoading.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react'
12
import { Spin } from 'antd'
23

34
export default () => (
@@ -10,7 +11,7 @@ export default () => (
1011
top: 0;
1112
right: 0;
1213
bottom: 0;
13-
background: rgba(255,255,255,0.3);
14+
background: rgba(255,255,255,0.2);
1415
z-index: 10001;
1516
display: flex;
1617
align-items: center;

src/index.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
22
import ReactDOM from 'react-dom'
33
import {BrowserRouter, HashRouter, Route, Switch} from 'react-router-dom'
44
import {createStore, applyMiddleware, compose} from 'redux'
5+
import Loadable from 'react-loadable'
56
import thunk from 'redux-thunk'
67
import { Provider } from 'react-redux'
78
import { reducer } from './redux/store'
@@ -14,10 +15,31 @@ import 'animate.css/animate.min.css'
1415
import PageLoading from '@components/PageLoading'
1516

1617
// 页面
17-
import Index from './Pages/Index'
18+
// import Index from './Pages/Index'
1819
import Article from './Pages/Articles'
19-
import Archives from './Pages/Archives'
20-
import Friend from './Pages/Friend'
20+
// import Archives from './Pages/Archives'
21+
// import Friend from './Pages/Friend'
22+
// 动态路由加载,提升用户感受
23+
const AsyncIndex = Loadable({
24+
loading: PageLoading ,
25+
timeout: 1000,
26+
loader: () => import('./Pages/Index')
27+
})
28+
// const AsyncArticle = Loadable({
29+
// loading: PageLoading ,
30+
// timeout: 1000,
31+
// loader: () => import('./Pages/Articles')
32+
// })
33+
const AsyncArchives = Loadable({
34+
loading: PageLoading ,
35+
timeout: 1000,
36+
loader: () => import('./Pages/Archives')
37+
})
38+
const AsyncFriend = Loadable({
39+
loading: PageLoading ,
40+
timeout: 1000,
41+
loader: () => import('./Pages/Friend')
42+
})
2143

2244
const store = createStore(reducer, compose(
2345
applyMiddleware(thunk),
@@ -32,10 +54,10 @@ class App extends Component {
3254
<BrowserRouter>
3355
{/* <HashRouter> */}
3456
<Switch>
35-
<Route path='/' exact component={Index} />
57+
<Route path='/' exact component={AsyncIndex} />
3658
<Route path='/articles/:id' component={Article} />
37-
<Route path='/archives' component={Archives} />
38-
<Route path='/friend' component={Friend} />
59+
<Route path='/archives' component={AsyncArchives} />
60+
<Route path='/friend' component={AsyncFriend} />
3961
</Switch>
4062
{/* </HashRouter> */}
4163
</BrowserRouter>

0 commit comments

Comments
 (0)