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