mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
Merge branch 'dev' of http://gitlab.corp.qunar.com/mfe/yapi into dev
This commit is contained in:
commit
98566dbf64
@ -1,19 +0,0 @@
|
||||
import login from './reducer/Login/login.js'
|
||||
import group from './reducer/group/group.js'
|
||||
import project from './reducer/group/project.js'
|
||||
import Interface from './reducer/Interface/InterfaceReducer.js'
|
||||
import news from './reducer/news/news.js'
|
||||
import addInterface from './reducer/addInterface/addInterface.js'
|
||||
import user from './reducer/user/user.js'
|
||||
import menu from './reducer/menu/menu.js'
|
||||
|
||||
export default {
|
||||
group,
|
||||
login,
|
||||
Interface,
|
||||
user,
|
||||
project,
|
||||
news,
|
||||
addInterface,
|
||||
menu
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
import React, { Component } from 'react'
|
||||
|
||||
export {
|
||||
React,
|
||||
Component
|
||||
}
|
15
client/containers/DevTools/DevTools.js
Normal file
15
client/containers/DevTools/DevTools.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import { createDevTools } from 'redux-devtools';
|
||||
import LogMonitor from 'redux-devtools-log-monitor';
|
||||
import DockMonitor from 'redux-devtools-dock-monitor';
|
||||
const DockMonitorD = DockMonitor.default // 这里有 bug 不知道为啥非要使用 default
|
||||
|
||||
export default createDevTools(
|
||||
<DockMonitorD
|
||||
toggleVisibilityKey="ctrl-h"
|
||||
changePositionKey="ctrl-q"
|
||||
defaultIsVisible={false}
|
||||
>
|
||||
<LogMonitor.default />
|
||||
</DockMonitorD>
|
||||
);
|
@ -5,6 +5,7 @@ import ProjectGroups from './ProjectGroups/ProjectGroups.js'
|
||||
import Interface from './Interface/Interface.js'
|
||||
import News from './News/News.js'
|
||||
import AddInterface from './AddInterface/AddInterface.js'
|
||||
import DevTools from './DevTools/DevTools.js'
|
||||
|
||||
export {
|
||||
Header,
|
||||
@ -13,5 +14,6 @@ export {
|
||||
ProjectGroups,
|
||||
Interface,
|
||||
AddInterface,
|
||||
News
|
||||
News,
|
||||
DevTools
|
||||
}
|
||||
|
@ -1,22 +1,32 @@
|
||||
import React from 'react'
|
||||
import 'babel-polyfill'
|
||||
import thunkMiddleware from 'redux-thunk'
|
||||
import promiseMiddleware from 'redux-promise';
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './Application'
|
||||
import { createStore, combineReducers, applyMiddleware } from 'redux'
|
||||
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import ReduxContainer from './ReduxContainer.js'
|
||||
import ReduxContainer from './reducer'
|
||||
import { DevTools } from './containers';
|
||||
|
||||
const enhancer = compose(
|
||||
// Middleware you want to use in development:
|
||||
applyMiddleware(
|
||||
thunkMiddleware.default,
|
||||
promiseMiddleware
|
||||
),
|
||||
// Required! Enable Redux DevTools with the monitors you chose
|
||||
DevTools.instrument()
|
||||
);
|
||||
|
||||
// 合并 redux 创建stroe
|
||||
const store = createStore(combineReducers( ReduxContainer ), applyMiddleware(
|
||||
thunkMiddleware.default,
|
||||
promiseMiddleware
|
||||
))
|
||||
const store = createStore(combineReducers( ReduxContainer ), {}, enhancer)
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
<div>
|
||||
<App />
|
||||
<DevTools />
|
||||
</div>
|
||||
</Provider>,
|
||||
document.getElementById('yapi')
|
||||
)
|
||||
|
@ -1,76 +0,0 @@
|
||||
import {
|
||||
LOGIN,
|
||||
LOGIN_OUT,
|
||||
LOGIN_TYPE,
|
||||
GET_LOGIN_STATE,
|
||||
REGISTER
|
||||
} from '../../constants/action-types';
|
||||
|
||||
const LOADING_STATUS = 0;
|
||||
const GUEST_STATUS = 1;
|
||||
const MEMBER_STATUS = 2;
|
||||
|
||||
const initialState = {
|
||||
isLogin: false,
|
||||
userName: null,
|
||||
uid: null,
|
||||
loginState: LOADING_STATUS,
|
||||
loginWrapActiveKey: "1"
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case GET_LOGIN_STATE: {
|
||||
console.log(action.payload.data);
|
||||
return {
|
||||
...state,
|
||||
isLogin: (action.payload.data.errcode == 0),
|
||||
role: action.payload.data.data ? action.payload.data.data.role:null,
|
||||
loginState: (action.payload.data.errcode == 0)?MEMBER_STATUS:GUEST_STATUS,
|
||||
userName: action.payload.data.data ? action.payload.data.data.username : null,
|
||||
uid: action.payload.data.data ? action.payload.data.data._id : null,
|
||||
server_ip: action.payload.data.data ? action.payload.data.data.server_ip:null
|
||||
};
|
||||
}
|
||||
case LOGIN: {
|
||||
if (action.payload.data.errcode === 0) {
|
||||
return {
|
||||
...state,
|
||||
isLogin: true,
|
||||
loginState: MEMBER_STATUS,
|
||||
uid: action.payload.data.data.uid,
|
||||
userName: action.payload.data.data.username,
|
||||
server_ip: action.payload.data.data.server_ip
|
||||
};
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
case LOGIN_OUT: {
|
||||
return{
|
||||
...state,
|
||||
isLogin: false,
|
||||
loginState: GUEST_STATUS,
|
||||
userName: null,
|
||||
uid: null
|
||||
}
|
||||
}
|
||||
case LOGIN_TYPE: {
|
||||
return {
|
||||
...state,
|
||||
loginWrapActiveKey: action.index
|
||||
};
|
||||
}
|
||||
case REGISTER: {
|
||||
return {
|
||||
...state,
|
||||
isLogin: true,
|
||||
loginState: MEMBER_STATUS,
|
||||
uid: action.payload.data.data.uid,
|
||||
userName: action.payload.data.data.username
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
19
client/reducer/index.js
Normal file
19
client/reducer/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
import login from './login/login.js'
|
||||
import group from './group/group.js'
|
||||
import project from './group/project.js'
|
||||
import Interface from './interface/interface.js'
|
||||
import news from './news/news.js'
|
||||
import addInterface from './addInterface/addInterface.js'
|
||||
import user from './user/user.js'
|
||||
import menu from './menu/menu.js'
|
||||
|
||||
export default {
|
||||
group,
|
||||
login,
|
||||
Interface,
|
||||
user,
|
||||
project,
|
||||
news,
|
||||
addInterface,
|
||||
menu
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
import {
|
||||
FETCH_INTERFACE_DATA,
|
||||
LIST_INTERFACE_CLICK,
|
||||
PROJECT_MEMBER_INTERFACE,
|
||||
DELETE_INTERFACE_DATA,
|
||||
SAVE_INTERFACE_PROJECT_ID,
|
||||
GET_INTERFACE_GROUP_LIST
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
const initialState = {
|
||||
interfaceData: [],
|
||||
modalVisible: false,
|
||||
interfaceName: '',
|
||||
projectId: '',
|
||||
memberList: []
|
||||
}
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_INTERFACE_DATA:
|
||||
return {
|
||||
...state,
|
||||
interfaceData: action.payload
|
||||
}
|
||||
case LIST_INTERFACE_CLICK:
|
||||
return {
|
||||
...state,
|
||||
modalVisible: true
|
||||
}
|
||||
case PROJECT_MEMBER_INTERFACE:
|
||||
return {
|
||||
...state,
|
||||
modalVisible: false
|
||||
}
|
||||
case DELETE_INTERFACE_DATA:
|
||||
return {
|
||||
...state,
|
||||
interfaceData: action.payload
|
||||
}
|
||||
case SAVE_INTERFACE_PROJECT_ID:
|
||||
return {
|
||||
...state,
|
||||
projectId: action.payload
|
||||
}
|
||||
case GET_INTERFACE_GROUP_LIST:
|
||||
return {
|
||||
...state,
|
||||
projectId: action.payload
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
13
package.json
13
package.json
@ -63,13 +63,11 @@
|
||||
"wangeditor": "^3.0.4",
|
||||
"ykit-config-antd": "^0.1.3",
|
||||
"ykit-config-react": "^0.4.4",
|
||||
"axios": "^0.16.2",
|
||||
"babel": "^6.5.2",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.8.0",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-loader": "^6.2.4",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.8.0",
|
||||
"babel-plugin-transform-runtime": "^6.9.0",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
@ -85,15 +83,11 @@
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"express": "^4.15.3",
|
||||
"extract-text-webpack-plugin": "^1.0.1",
|
||||
"fast-sass-loader": "^1.2.5",
|
||||
"fs-extra": "^3.0.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-watch": "^4.3.11",
|
||||
"node-sass": "^4.5.3",
|
||||
|
||||
"ora": "^1.3.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^15.6.1",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-redux": "^5.0.5",
|
||||
@ -106,10 +100,13 @@
|
||||
"validate-commit-msg": "^2.12.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ghooks": "^2.0.0",
|
||||
"nodemon": "^1.11.0",
|
||||
"redux-devtools": "^3.4.0",
|
||||
"redux-devtools-dock-monitor": "^1.1.2",
|
||||
"redux-devtools-log-monitor": "^1.3.0",
|
||||
"webpack": "^2.0.0",
|
||||
"webpack-node-externals": "^1.6.0",
|
||||
"ghooks": "^2.0.0"
|
||||
"webpack-node-externals": "^1.6.0"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
|
Loading…
Reference in New Issue
Block a user