2022-12-01 18:10:18 +08:00

30 lines
901 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { applyMiddleware, compose, createStore } from 'redux'
import thunkMiddleware from 'redux-thunk'
import rootReducer from '@/reducers'
const composeEnhancers
= typeof window === 'object'
&& (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extensions options like name, actionsBlacklist, actionsCreators, serialize...
})
: compose
const middlewares = [
thunkMiddleware,
]
if (process.env.NODE_ENV === 'development' && process.env.TARO_ENV !== 'quickapp') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
middlewares.push(require('redux-logger').createLogger())
}
const enhancer = composeEnhancers(
applyMiddleware(...middlewares),
)
export default function configStore() {
const store = createStore(rootReducer, enhancer)
return store
}