33 lines
928 B
TypeScript
33 lines
928 B
TypeScript
import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
|
import { persistStore, persistReducer } from 'redux-persist'
|
|
import storage from "redux-persist/lib/storage";
|
|
import cacheSlice from "./cache";
|
|
import sidebarSlice from "./sidebar";
|
|
import permissionSlice from "./permission";
|
|
import authInfoSlice from "./auth"
|
|
|
|
const persistConfig = {
|
|
key: 'root',
|
|
storage,
|
|
blacklist: ['cache','sidebar'] // 黑名单, 不做终端缓存的内容
|
|
}
|
|
|
|
const reducers = combineReducers({
|
|
cache: cacheSlice,
|
|
sidebar: sidebarSlice,
|
|
permission: permissionSlice,
|
|
auth: authInfoSlice
|
|
})
|
|
|
|
// configureStore创建一个redux数据
|
|
const persistedReducer = persistReducer(persistConfig, reducers)
|
|
const store = configureStore({
|
|
reducer: persistedReducer,
|
|
middleware:(getDefaultMiddleware) => getDefaultMiddleware({
|
|
serializableCheck: false
|
|
})
|
|
})
|
|
|
|
export const persistor = persistStore(store)
|
|
|
|
export default store |