22301014 | bc4616f | 2025-06-03 16:59:44 +0800 | [diff] [blame] | 1 | import { configureStore } from '@reduxjs/toolkit' |
22301014 | 62240ab | 2025-06-07 09:28:16 +0800 | [diff] [blame] | 2 | import authReducer from "../feature/auth/authSlice" |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame^] | 3 | import userReducer from "../feature/user/userSlice" |
22301014 | bc4616f | 2025-06-03 16:59:44 +0800 | [diff] [blame] | 4 | export const store = configureStore({ |
| 5 | reducer: { |
22301014 | 62240ab | 2025-06-07 09:28:16 +0800 | [diff] [blame] | 6 | auth: authReducer, |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame^] | 7 | user: userReducer, |
22301014 | 62240ab | 2025-06-07 09:28:16 +0800 | [diff] [blame] | 8 | }, |
| 9 | middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(), |
22301014 | bc4616f | 2025-06-03 16:59:44 +0800 | [diff] [blame] | 10 | }) |
| 11 | |
| 12 | // 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型 |
| 13 | export type RootState = ReturnType<typeof store.getState> |
| 14 | // 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState} |
| 15 | export type AppDispatch = typeof store.dispatch |