Skip to content

Commit f200d6f

Browse files
committed
modify by dk
1 parent 964c100 commit f200d6f

File tree

13 files changed

+123
-79
lines changed

13 files changed

+123
-79
lines changed

reactERP/api/npm-debug.log.4080722869

Whitespace-only changes.

reactERP/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"build": "webpack --progress --colors",
9-
"start": "webpack-dev-server --devtool eval --progress --port 1703 --colors --content-base ./"
9+
"start": "node server"
1010
},
1111
"devDependencies": {},
1212
"author": "DK.Lan",

reactERP/api/route/Account.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var bodyParser = require('body-parser');
2+
var cookieParser = require('cookie-parser');
3+
var session = require('express-session');
4+
5+
var urlencodeParser = bodyParser.urlencoded();
6+
module.exports = {
7+
Register: function(app){
8+
//设置 session
9+
app.use(cookieParser());
10+
app.use(session({
11+
secret: '12345',//用来对session数据进行加密的字符串.这个属性值为必须指定的属性
12+
name: 'testapp', //这里的name值得是cookie的name,默认cookie的name是:connect.sid
13+
cookie: {maxAge: 80000 }, //设置maxAge是80000ms,即80s后session和相应的cookie失效过期
14+
resave: false,
15+
saveUninitialized: true,
16+
}))
17+
18+
app.post('/login', urlencodeParser, function(reqeust, response){
19+
//请求数据库,如果正确,则记录登陆状态
20+
request.session.name = request.body.username;
21+
response.send({state: true});
22+
})
23+
24+
app.post("/register", function(request, response){})
25+
26+
app.get('/setSession', function(request, response){
27+
request.session.username = 'dk';
28+
response.send(request.session.username)
29+
})
30+
31+
app.get('/getSession', function(request, response){
32+
response.send(request.session.username);
33+
})
34+
35+
app.get('/getproduct', function(request, response){
36+
if(!request.session.usernmae){
37+
response.send({statue: false, message: '请先登陆', flag: 0})
38+
}
39+
})
40+
}
41+
}

reactERP/api/route/Index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var Account = require('./Account');
2+
3+
module.exports = {
4+
Register: function(express){
5+
var app = express();
6+
7+
Account.Register(app);
8+
9+
app.listen(888);
10+
}
11+
}

reactERP/api/route/Product.js

Whitespace-only changes.

reactERP/api/route/PurcharsOrder.js

Whitespace-only changes.

reactERP/api/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var express = require('express');
2+
3+
var router = require('./route/Index');
4+
5+
router.Register(express);

reactERP/web/src/app.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ import './libs/font-awesome/css/font-awesome.min.css'
44
import React from 'react';
55
import ReactDOM from 'react-dom';
66
import LoginComponent from './modules/login/LoginComponent';
7-
import {Provider} from 'react-redux';
7+
import {Provider} from 'react-redux'
88
import {createStore, applyMiddleware} from 'redux';
9-
import thunk from 'redux-thunk';
9+
import thunkMiddleware from 'redux-thunk'
1010
import LoginReducer from './modules/login/LoginReducer';
11+
import {ajaxMiddleware} from './utils/ajaxMiddleware';
12+
import { routerMiddleware } from 'react-router-redux';
13+
import {Router, Route, hashHistory, browserHistory} from 'react-router'
1114

12-
const middleware = applyMiddleware(thunk, ajaxMiddleware);
15+
// const middleware = applyMiddleware(thunk, ajaxMiddleware);
16+
// let middleware = applyMiddleware(thunk, ajaxMiddleware, routerMiddleware(browserHistory))
1317

14-
const store = createStore(middleware)
18+
const store = createStore(LoginReducer, {}, applyMiddleware(thunkMiddleware, ajaxMiddleware))
19+
// const store = createStore(LoginReducer);
1520

16-
ReactDOM.render(<Provider store={store}><LoginComponent /></Provider>, document.getElementById('app'));
21+
ReactDOM.render(
22+
<Provider store={store}>
23+
<LoginComponent/>
24+
</Provider>,
25+
document.getElementById('app')
26+
);
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import common from '../../libs/common/common';
2-
3-
export default function login(_username, _password){
1+
export function login(username, password){
42
return {
5-
type: '',
6-
url: common.baseUrl + 'login',
7-
data: {username: _username, _password}
3+
types: ['a', 'b', 'c'],
4+
path: 'login',
5+
method: 'post',
6+
query: {username, password}
87
}
98
}
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
import React, {Component} from 'react';
2-
import LoginAction from './LoginAction';
2+
import loginActions from './LoginAction';
3+
import {connect} from 'react-redux'
34
// import {Input} from 'element-react';
45
// import 'element-theme-default';
56

67
class LoginComponent extends Component{
78
render(){
89
return (
9-
<div class="col-md-12">
10-
<div class="form-group">
11-
<label class="col-sm-2 control-label" for="form-field-1">
10+
<div className="col-md-12">
11+
<div className="form-group">
12+
<label className="col-sm-2 control-label">
1213
用户名
1314
</label>
14-
<div class="col-sm-9">
15-
<input type="text" placeholder="输入用户名" id="form-field-1" class="form-control"/>
15+
<div className="col-sm-9">
16+
<input type="text" placeholder="输入用户名" id="form-field-1" className="form-control"/>
1617
</div>
1718
</div>
18-
<div class="form-group">
19-
<label class="col-sm-2 control-label" for="form-field-1">
19+
<div className="form-group">
20+
<label className="col-sm-2 control-label">
2021
密码
2122
</label>
22-
<div class="col-sm-9">
23-
<input type="text" placeholder="输入密码" id="form-field-1" class="form-control"/>
23+
<div className="col-sm-9">
24+
<input type="text" placeholder="输入密码" id="form-field-1" className="form-control"/>
2425
</div>
2526
</div>
26-
<button type="button" class="btn btn-primary">登录</button>
27+
<button type="button" className="btn btn-primary">登录</button>
28+
<i className="fa fa-fire"></i>
2729
</div>
2830
)
2931
}
3032
}
3133

32-
export default LoginComponent;
34+
const mapStateToProps = state => ({
35+
loading: false,
36+
})
37+
export default connect(mapStateToProps, loginActions)(LoginComponent)

0 commit comments

Comments
 (0)