Commit eaae6004 by bert

初步实现登录

parent 9374c39f
...@@ -56,19 +56,6 @@ class Header extends React.Component { ...@@ -56,19 +56,6 @@ class Header extends React.Component {
* 因为在导航前加入了标记,所以这里判断时也需要加入 `sub` 标记 * 因为在导航前加入了标记,所以这里判断时也需要加入 `sub` 标记
* *
*/ */
switch (item.key) {
case 'myMain':
// 获取我的发布数据
// 获取边栏菜单数据
break;
case 'submanage':
// 获取case管理数据
// 获取边栏菜单数据
break;
case 'sub' + 'index.html':
window.open("/index.html");
break;
}
/** /**
* 默认情况更改 `面包屑` 信息 * 默认情况更改 `面包屑` 信息
......
/**
* 1、处理 `Ag` 参数
* 2、appId、token、ts 加密传输
* 3、提供AgUrl
*/
import md5 from 'md5';
// const appID = window.globalConfig.appid;
// const token = window.globalConfig.token;
// const ts = new Date().getTime().toString().substring(0,10);
// const agUrl = window.globalConfig.url;
const agConf = ''//{
// appID : appID,
// token : token,
// ts : ts,
// sign : md5(appID + ts + token + 'false'),
// agUrl : agUrl
// }
export default agConf
\ No newline at end of file
/**
*
*/
export default {
operator : window.globalConfig.operator,
operatorId : window.globalConfig.operatorId,
rootTree : window.globalConfig.rootTree,
avatarUrl : window.globalConfig.avatarUrl
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { Router, Route, IndexRoute, Link } from 'react-router'; ...@@ -3,6 +3,7 @@ import { Router, Route, IndexRoute, Link } from 'react-router';
import App from '../components/App'; import App from '../components/App';
import Appp from '../views/App'; import Appp from '../views/App';
import Home from '../views/Home'; import Home from '../views/Home';
import Login from '../views/Login';
import Test from '../views/Test'; import Test from '../views/Test';
import NotFound from '../components/NotFound'; import NotFound from '../components/NotFound';
...@@ -10,7 +11,7 @@ const Routes = ({ history }) => ...@@ -10,7 +11,7 @@ const Routes = ({ history }) =>
<Router history={history}> <Router history={history}>
<Route path="/" component={App} /> <Route path="/" component={App} />
<Route path="/actived" component={App} /> <Route path="/actived" component={App} />
<Route path="/completed" component={App} /> <Route path="/login" component={Login} />
<Route component={Appp}> <Route component={Appp}>
<Route path="home" component={Home}/> <Route path="home" component={Home}/>
<Route path="app" component={App}/> <Route path="app" component={App}/>
......
...@@ -3,3 +3,7 @@ import xFetch from './xFetch'; ...@@ -3,3 +3,7 @@ import xFetch from './xFetch';
export async function getAll() { export async function getAll() {
return xFetch('/api/todos'); return xFetch('/api/todos');
} }
export async function getLogin() {
return xFetch('/api/login');
}
\ No newline at end of file
import { createStore, applyMiddleware } from 'redux' import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk' import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger' import createLogger from 'redux-logger'
import promiseMiddleware from './middlewares/promiseMiddleware';
import rootReducer from './reducers' import rootReducer from './reducers'
export default function configureStore(initialState) { export default function configureStore(initialState) {
const store = createStore( const store = createStore(
rootReducer, rootReducer,
initialState, initialState,
applyMiddleware(thunkMiddleware, createLogger()) applyMiddleware(
// applyMiddleware(thunkMiddleware) thunkMiddleware,
createLogger(),
promiseMiddleware({ promiseTypeSuffixes: ['PENDING', 'SUCCESS', 'ERROR'] }),
) )
// applyMiddleware(thunkMiddleware)
)
if (module.hot) { if (module.hot) {
// Enable Webpack hot module replacement for reducers // Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => { module.hot.accept('../reducers', () => {
......
import { isPromise } from '../util';
const defaultTypes = ['PENDING', 'FULFILLED', 'REJECTED'];
export default function promiseMiddleware(config = {}) {
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypes;
return (_ref) => {
const dispatch = _ref.dispatch;
return next => action => {
if (!isPromise(action.payload)) {
return next(action);
}
const { type, payload, meta } = action;
const { promise, data } = payload;
const [ PENDING, FULFILLED, REJECTED ] = (meta || {}).promiseTypeSuffixes || promiseTypeSuffixes;
/**
* Dispatch the first async handler. This tells the
* reducer that an async action has been dispatched.
*/
next({
type: `${type}_${PENDING}`,
...!!data ? { payload: data } : {},
...!!meta ? { meta } : {}
});
const isAction = resolved => resolved && (resolved.meta || resolved.payload);
const isThunk = resolved => typeof resolved === 'function';
const getResolveAction = isError => ({
type: `${type}_${isError ? REJECTED : FULFILLED}`,
...!!meta ? { meta } : {},
...!!isError ? { error: true } : {}
});
/**
* Re-dispatch one of:
* 1. a thunk, bound to a resolved/rejected object containing ?meta and type
* 2. the resolved/rejected object, if it looks like an action, merged into action
* 3. a resolve/rejected action with the resolve/rejected object as a payload
*/
action.payload.promise = promise.then(
(resolved = {}) => {
const resolveAction = getResolveAction();
return dispatch(isThunk(resolved) ? resolved.bind(null, resolveAction) : {
...resolveAction,
...isAction(resolved) ? resolved : {
...!!resolved && { payload: resolved }
}
});
},
(rejected = {}) => {
const resolveAction = getResolveAction(true);
return dispatch(isThunk(rejected) ? rejected.bind(null, resolveAction) : {
...resolveAction,
...isAction(rejected) ? rejected : {
...!!rejected && { payload: rejected }
}
});
},
);
return action;
};
};
}
...@@ -61,48 +61,6 @@ export function getCaseMenu() { ...@@ -61,48 +61,6 @@ export function getCaseMenu() {
} }
/** /**
* 获取cese侧边菜单数据(我的发布、我的case、我的关注)
* 目前添加case侧边菜单不需要数据,所以先传一个空菜单
*
* @export
* @returns
*/
export function getAddCaseLeftMenu() {
return {
type: types.GET_ADD_CASE_LEFT_MENU,
payload: {
leftMenu: emptyMenu
}
}
}
/**
*
* 获取 `我的管理侧边菜单` 的统计数据
* 我的管理统计数据是独立的接口,所以在 `Action` 中开一个独立的动作
*
* 优化:
* 可以通过传参来判断需要访问那个接口
* type = myCase、myTask、myFocu、manage
* 判断type类型获取相应的结果刷新 `State`
*
* @export
* @param {any} param
* @returns
*/
export function getCaseManageMenu(param) {
return {
type: types.GET_MANAGE_LEFT_MENU,
payload: {
promise: api.get('report/all_page', { params: param })
},
params: {
leftMenu: caseMenu
}
}
}
/**
* 侧栏菜单的隐藏显示控制 * 侧栏菜单的隐藏显示控制
* *
* 通过点击切换按钮触发该功能 * 通过点击切换按钮触发该功能
......
...@@ -74,7 +74,7 @@ export default createReducer(initialState, { ...@@ -74,7 +74,7 @@ export default createReducer(initialState, {
}, },
[`${types.GET_LEFT_MENU}`]: (state, data, params) => { [`${types.GET_LEFT_MENU}`]: (state, data, params) => {
return objectAssign({}, state, { leftMenu: params.leftMenu }) return objectAssign({}, state, { leftMenu: params.leftMenu });
}, },
[`${types.INIT_MENU}`]: (state, data, params) => { [`${types.INIT_MENU}`]: (state, data, params) => {
......
...@@ -2,8 +2,7 @@ import {getCookie} from '../../../util'; ...@@ -2,8 +2,7 @@ import {getCookie} from '../../../util';
import types from '../../types'; import types from '../../types';
import reqwest from 'reqwest'; import reqwest from 'reqwest';
// import AG_CONF from '../../../constants/AgCode'; import { getLogin } from '../../../services/todos';
// import OPERATOR_INFO from '../../../constants/OperatorInfo';
/** /**
* 判断 `cookis` 中是否有 `uid` 没有触发没有发现 `uid` 的 `Action` * 判断 `cookis` 中是否有 `uid` 没有触发没有发现 `uid` 的 `Action`
...@@ -35,16 +34,8 @@ export function fetchProfile() { ...@@ -35,16 +34,8 @@ export function fetchProfile() {
export function login(user, password) { export function login(user, password) {
return { return {
type: types.LOGIN, type: types.LOGIN,
// payload: {
// promise: api.put('/login', {
// data: {
// user: user,
// password: password
// }
// })
// }
payload: { payload: {
user: 'admin' promise: getLogin()
} }
} }
} }
......
...@@ -24,10 +24,10 @@ export default createReducer(initialState, { ...@@ -24,10 +24,10 @@ export default createReducer(initialState, {
}, },
[`${types.LOGIN}_SUCCESS`]: (state, data) => { [`${types.LOGIN}_SUCCESS`]: (state, data) => {
console.log('data', data);
return objectAssign({}, state, { return objectAssign({}, state, {
loggingIn : true, loggingIn : true,
user: data.conten.user, user: data.jsonResult.data,
loginErrors: null loginErrors: null
}) })
}, },
......
...@@ -39,6 +39,8 @@ export function createReducer (initialparams, reducerMap) { ...@@ -39,6 +39,8 @@ export function createReducer (initialparams, reducerMap) {
/* /*
TODP:判断 `请求` 返回的 `Code` 显示服务端提示信息。 TODP:判断 `请求` 返回的 `Code` 显示服务端提示信息。
*/ */
// console.log('action', action);
if (!action.error && action.payload && action.payload.code && action.payload.code != '0') { if (!action.error && action.payload && action.payload.code && action.payload.code != '0') {
message.error(action.payload.message); message.error(action.payload.message);
if (params.get('loading')) { if (params.get('loading')) {
......
...@@ -4,7 +4,7 @@ const Panel = Collapse.Panel; ...@@ -4,7 +4,7 @@ const Panel = Collapse.Panel;
// import {Line,Pie,Doughnut} from 'react-chartjs'; // import {Line,Pie,Doughnut} from 'react-chartjs';
import styles from'./index.less' import styles from './index.less'
const chartOption = { const chartOption = {
responsive: true responsive: true
......
...@@ -2,12 +2,12 @@ import React, { PropTypes } from 'react'; ...@@ -2,12 +2,12 @@ import React, { PropTypes } from 'react';
import { Form, Input, Button, Row, Col, notification, Checkbox } from 'antd'; import { Form, Input, Button, Row, Col, notification, Checkbox } from 'antd';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// import { login } from '../../actions/user';
import { login } from '../../store/modules/user/user_action'; import { login } from '../../store/modules/user/user_action';
const FormItem = Form.Item; const FormItem = Form.Item;
import './index.less'; import styles from './index.less'
const propTypes = { const propTypes = {
user: PropTypes.string, user: PropTypes.string,
...@@ -56,7 +56,7 @@ class Login extends React.Component { ...@@ -56,7 +56,7 @@ class Login extends React.Component {
} }
if (user) { if (user) {
this.context.router.replace('/myMain'); this.context.router.replace('/home');
} }
} }
...@@ -74,9 +74,9 @@ class Login extends React.Component { ...@@ -74,9 +74,9 @@ class Login extends React.Component {
render() { render() {
const { getFieldProps } = this.props.form const { getFieldProps } = this.props.form
return ( return (
<Row className="login-row" type="flex" justify="space-around" align="middle"> <Row className={styles["login-row"]} type="flex" justify="space-around" align="middle">
<Col span="9"> <Col span="9">
<Form horizontal onSubmit={this.handleSubmit.bind(this) } className="login-form"> <Form horizontal onSubmit={this.handleSubmit.bind(this) } className={styles["login-form"]}>
<FormItem> <FormItem>
<Row> <Row>
<Col span='8' offset='12'> <Col span='8' offset='12'>
...@@ -93,7 +93,7 @@ class Login extends React.Component { ...@@ -93,7 +93,7 @@ class Login extends React.Component {
</Row> </Row>
</FormItem> </FormItem>
<Row className="check-margin"> <Row className={styles["check-margin"]}>
<Col span='16' offset='12'> <Col span='16' offset='12'>
<Checkbox {...getFieldProps('agreement') }>记住账号密码</Checkbox> <Checkbox {...getFieldProps('agreement') }>记住账号密码</Checkbox>
</Col> </Col>
......
.login-row { .login-row {
height: 100%; height: 100%;
background: url(./login-bg.png) no-repeat; // background: url(./login-bg.png) no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
}
@media (min-width: 768px) {
.login-form { @media (min-width: 768px) {
padding: 70px 8px; .login-form {
} padding: 70px 8px;
}
@media (min-width: 1500px) {
.login-form {
padding: 125px 8px;
}
}
.login-form {
background: url(./input-bg.png) no-repeat;
background-size: 100% 100%;
border-radius: 6px;
} }
.check-margin { }
margin-top: -15px; @media (min-width: 1500px) {
margin-bottom: 8px; .login-form {
padding: 125px 8px;
} }
} }
.login-form {
// background: url(./input-bg.png) no-repeat;
background: #ccc;
background-size: 100% 100%;
border-radius: 6px;
}
.check-margin {
margin-top: -15px;
margin-bottom: 8px;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment