Skip to content

Commit 79541cc

Browse files
authored
Merge pull request #13 from monkeyInShell/feature-add-homepame
Feature add homepame
2 parents 6c0d8c4 + e59a066 commit 79541cc

File tree

22 files changed

+131
-13252
lines changed

22 files changed

+131
-13252
lines changed

Diff for: .babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"syntax-dynamic-import"//不解析动态加载标识符 import() node环境无作用,得另想办法
1212
],
1313
"env": {
14+
//这个配置只针对服务端的客户端代码
1415
"node": {
1516
"plugins": [[
1617
"babel-plugin-transform-require-ignore",

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.git/
44
node_modules/
55
dist/
6+
package-lock.json

Diff for: README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# server-side-render
2-
## for development
1+
# 服务端渲染同构框架
2+
3+
## 本地开发
34
> npm run start
4-
## for production
5+
6+
## 生产打包
57
> npm run build
6-
### start production server
78
8-
> node bin/www.js

Diff for: bin/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 启动文件
2+
3+
* www
4+
5+
> 服务器入口文件,里面针对开发环境node端的babel编译做了配置

Diff for: bin/www

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
if (process.env.NODE_ENV === 'local') {
3-
//node运行时生效,同样也会去读.babelrc,plugins不会覆盖,会concat生效
4-
//webpack生效的配置是.babelrc
3+
//由于运行时不会设置BABEL_ENV = node,单独为node运行时设置插件处理
4+
//这里如果统一设置BABEL_ENV = node,导致webpack内babel运行时也会去读取env: node的配置
55
require('babel-register')({
66
'plugins': [
77
[

Diff for: client/pages/example/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ReactDom from 'react-dom'
77
import {BrowserRouter} from 'react-router-dom'
88
import App from './App'
99
ReactDom.hydrate(
10-
<BrowserRouter basename='/components'>
10+
<BrowserRouter basename='/p/components'>
1111
<App/>
1212
</BrowserRouter>
1313
, document.getElementById('bd'))

Diff for: client/pages/integration/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const App = (props) => {
1212
return (
1313
<Fragment>
1414
<div>
15-
<Link to='/home'>首页</Link>
15+
<Link to='/home'>个人主页</Link>
1616
</div>
1717
<div>
1818
<Link to='/center'>用户中心</Link>

Diff for: client/pages/integration/Center/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import connect from '../../tools/connect'
77

88
class Center extends Component {
99
render () {
10-
return (<div>欢迎来到个人中心</div>)
10+
return (<div>{this.props.title}</div>)
1111
}
1212
}
1313
export default connect({

Diff for: client/pages/integration/Home/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import React, {Component} from 'react'
55
import connect from '../../tools/connect'
66
import * as actions from '../redux/action'
77
class Home extends Component {
8-
constructor(options) {
9-
super(options)
10-
}
118
componentDidMount() {
129
setTimeout(() => {
13-
this.props.actions.home('我是首页')
10+
this.props.actions.home('个人主页内容展示')
1411
//通过action出发路由跳转
1512
//this.props.actions.jump('center')
1613
}, 2000)

Diff for: client/pages/integration/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import App from './App'
88
import storeFactory, {historyConf} from '../tools/store/forBrowser'
99
import reducers from './store/'
1010
const history = historyConf({
11-
basename: '/integration'
11+
basename: '/p/integration'
1212
})
1313
const store = storeFactory(reducers, history)
1414

Diff for: client/pages/integration/redux/reducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function center (state = {title: '欢迎来到个人中心'}, action) {
1010
}
1111
}
1212

13-
export function home (state = {title: '默认首页'}, action) {
13+
export function home (state = {title: '个人首页内容'}, action) {
1414
switch (action.type) {
1515
case 'home_title':
1616
return Object.assign({}, state, {title: action.data})

0 commit comments

Comments
 (0)