mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
Modal
This commit is contained in:
parent
132fe872b6
commit
e5bc0d258f
17 changed files with 301 additions and 65 deletions
|
@ -1,42 +1,49 @@
|
|||
import { createStore, applyMiddleware, combineReducers, compose, Store } from 'redux';
|
||||
import { createStore, applyMiddleware, combineReducers, compose, Store } from "redux";
|
||||
|
||||
import { persistStore, persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import { connectRouter } from 'connected-react-router'
|
||||
import userReducer from '~/redux/user/reducer';
|
||||
import userSaga from '~/redux/user/sagas';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { persistStore, persistReducer } from "redux-persist";
|
||||
import storage from "redux-persist/lib/storage";
|
||||
import createSagaMiddleware from "redux-saga";
|
||||
import { connectRouter, RouterState } from "connected-react-router";
|
||||
import { createBrowserHistory } from "history";
|
||||
import { PersistConfig, Persistor } from "redux-persist/es/types";
|
||||
import { routerMiddleware } from 'connected-react-router'
|
||||
import { routerMiddleware } from "connected-react-router";
|
||||
|
||||
import userReducer, { IUserState } from "~/redux/user/reducer";
|
||||
import userSaga from "~/redux/user/sagas";
|
||||
|
||||
import modalReducer, { IModalState } from "~/redux/modal/reducer";
|
||||
import { IState } from "~/redux/store";
|
||||
|
||||
const userPersistConfig: PersistConfig = {
|
||||
key: 'user',
|
||||
whitelist: ['profile'],
|
||||
storage,
|
||||
key: "user",
|
||||
whitelist: ["profile"],
|
||||
storage
|
||||
};
|
||||
|
||||
export interface IState {
|
||||
user: IUserState;
|
||||
modal: IModalState;
|
||||
router: RouterState;
|
||||
}
|
||||
|
||||
export const sagaMiddleware = createSagaMiddleware();
|
||||
export const history = createBrowserHistory();
|
||||
|
||||
const composeEnhancers =
|
||||
typeof window === 'object' &&
|
||||
(<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
typeof window === "object" && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
: compose;
|
||||
|
||||
export const store = createStore(
|
||||
combineReducers({
|
||||
user: persistReducer(userPersistConfig, userReducer),
|
||||
router: connectRouter(history),
|
||||
modal: modalReducer,
|
||||
router: connectRouter(history)
|
||||
}),
|
||||
composeEnhancers(applyMiddleware(
|
||||
routerMiddleware(history),
|
||||
sagaMiddleware
|
||||
))
|
||||
composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
|
||||
);
|
||||
|
||||
export function configureStore(): { store: Store<any>, persistor: Persistor } {
|
||||
export function configureStore(): { store: Store<any>; persistor: Persistor } {
|
||||
sagaMiddleware.run(userSaga);
|
||||
|
||||
const persistor = persistStore(store);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue