mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
feat: 添加项目逻辑
This commit is contained in:
parent
3e2e489e66
commit
1337ca675f
@ -1,11 +1,13 @@
|
|||||||
import LoginRedux from './reducer/Login/Login_redux.js'
|
import LoginRedux from './reducer/Login/Login_redux.js'
|
||||||
import login from './reducer/Login/login.js'
|
import login from './reducer/Login/login.js'
|
||||||
import group from './reducer/group/group.js'
|
import group from './reducer/group/group.js'
|
||||||
|
import project from './reducer/group/project.js'
|
||||||
import Interface from './reducer/Interface/InterfaceReducer.js'
|
import Interface from './reducer/Interface/InterfaceReducer.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
group,
|
group,
|
||||||
login,
|
login,
|
||||||
LoginRedux,
|
LoginRedux,
|
||||||
Interface
|
Interface,
|
||||||
|
project
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,18 @@ const cookies = new Cookies();
|
|||||||
|
|
||||||
const loginActions = (data) => {
|
const loginActions = (data) => {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
axios.get('/user/login', data).then((res) => {
|
axios.post('/user/login', data).then((res) => {
|
||||||
cookies.set(data.email, data.password);
|
if (res.data.data.errcode === 0) {
|
||||||
dispatch({
|
cookies.set(data.email, data.password);
|
||||||
type: LOGIN,
|
dispatch({
|
||||||
payload: {
|
type: LOGIN,
|
||||||
data: res
|
payload: {
|
||||||
}
|
data: res
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('登录失败');
|
||||||
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
@ -30,7 +34,7 @@ const regActions = (data) => {
|
|||||||
username: data.userName
|
username: data.userName
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
axios.get('/user/login', param).then((res) => {
|
axios.post('/user/login', param).then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -15,7 +15,7 @@ const addProject = (data) => {
|
|||||||
return {
|
return {
|
||||||
type: PROJECT_ADD,
|
type: PROJECT_ADD,
|
||||||
// payload 可以返回 Promise,异步请求使用 axios 即可
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
||||||
payload: axios.get('/project/add', param)
|
payload: axios.post('/project/add', param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ const initialState = {
|
|||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case LOGIN: {
|
case LOGIN: {
|
||||||
|
console.log(action);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isLogin: true,
|
isLogin: true,
|
||||||
|
19
client/reducer/group/project.js
Normal file
19
client/reducer/group/project.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
PROJECT_ADD
|
||||||
|
} from '../../constants/action-types';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
groupList: [],
|
||||||
|
currGroup: 'MFE'
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (state = initialState, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case PROJECT_ADD: {
|
||||||
|
console.log(action.payload);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user