Skip to content

Commit

Permalink
fix: middleware ts
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh22222228 committed Dec 20, 2023
1 parent 37096b9 commit a472d4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/store/middlewares.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Middleware, PayloadAction } from '@reduxjs/toolkit'
import { Middleware } from '@reduxjs/toolkit'
import { SET_USER_INFO } from '@/store/userSlice'
import { LOCAL_STORAGE } from '@/constants'
import { RootState } from '@/store/index'

export const authMiddleware: Middleware<{}, RootState> =
(storeApi) => (next) => (action: PayloadAction) => {
() => (next) => (action: unknown) => {
if (SET_USER_INFO.match(action) && !!action.payload.token) {
localStorage.setItem(LOCAL_STORAGE.USER, JSON.stringify(action.payload))
localStorage.setItem(LOCAL_STORAGE.LOGIN_NAME, action.payload.loginName)
Expand Down

1 comment on commit a472d4a

@vercel
Copy link

@vercel vercel bot commented on a472d4a Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.