mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
26 lines
859 B
JavaScript
26 lines
859 B
JavaScript
import { createStore as _createStore, applyMiddleware, compose } from 'redux';
|
|
import thunkMiddleware from 'redux-thunk';
|
|
import promiseMiddleware from 'redux-promise';
|
|
import messageMiddleware from './middleware/messageMiddleware';
|
|
import DevTools from '../containers/DevTools/DevTools'
|
|
import reducer from './modules/reducer';
|
|
|
|
export default function createStore(initialState = {}) {
|
|
const middleware = [thunkMiddleware, promiseMiddleware, messageMiddleware];
|
|
|
|
let finalCreateStore;
|
|
if (ENV_PARAMS.development) {
|
|
finalCreateStore = compose(
|
|
applyMiddleware(...middleware),
|
|
window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument()
|
|
)(_createStore);
|
|
|
|
} else {
|
|
finalCreateStore = applyMiddleware(...middleware)(_createStore);
|
|
}
|
|
|
|
const store = finalCreateStore(reducer, initialState);
|
|
|
|
return store;
|
|
}
|