mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 10:00:08 +08:00
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { combineReducers, configureStore } from '@reduxjs/toolkit'
|
|
import { useDispatch, useSelector, useStore } from 'react-redux'
|
|
import { FLUSH, PAUSE, PERSIST, persistReducer, persistStore, PURGE, REGISTER, REHYDRATE } from 'redux-persist'
|
|
import storage from 'redux-persist/lib/storage'
|
|
|
|
import agents from './agents'
|
|
import assistants from './assistants'
|
|
import llm from './llm'
|
|
import migrate from './migrate'
|
|
import runtime from './runtime'
|
|
import settings from './settings'
|
|
|
|
const rootReducer = combineReducers({
|
|
assistants,
|
|
settings,
|
|
llm,
|
|
agents,
|
|
runtime
|
|
})
|
|
|
|
const persistedReducer = persistReducer(
|
|
{
|
|
key: 'cherry-studio',
|
|
storage,
|
|
version: 33,
|
|
blacklist: ['runtime'],
|
|
migrate
|
|
},
|
|
rootReducer
|
|
)
|
|
|
|
const store = configureStore({
|
|
// @ts-ignore store type is unknown
|
|
reducer: persistedReducer as typeof rootReducer,
|
|
middleware: (getDefaultMiddleware) => {
|
|
return getDefaultMiddleware({
|
|
serializableCheck: {
|
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
|
|
}
|
|
})
|
|
},
|
|
devTools: true
|
|
})
|
|
|
|
export type RootState = ReturnType<typeof rootReducer>
|
|
export type AppDispatch = typeof store.dispatch
|
|
|
|
export const persistor = persistStore(store)
|
|
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
|
|
export const useAppSelector = useSelector.withTypes<RootState>()
|
|
export const useAppStore = useStore.withTypes<typeof store>()
|
|
|
|
export default store
|