-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 修复登录按钮需要按两次才能进入页面 - 修复未登录不正常跳转登录页面
- Loading branch information
Showing
7 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { PayloadAction } from '@reduxjs/toolkit'; | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import type { UseInfoType } from '@/server/useInfo'; | ||
|
||
interface UserSlice { | ||
userInfo?: UseInfoType; | ||
power?: UseInfoType['power']; | ||
} | ||
|
||
const initialState: UserSlice = {}; | ||
|
||
export const UserSlice = createSlice({ | ||
name: 'userInfo', | ||
initialState, | ||
reducers: { | ||
setUserInfo: (state, action: PayloadAction<UseInfoType>) => { | ||
console.log(action.payload); | ||
state.userInfo = action.payload; | ||
state.power = action.payload.power; | ||
}, | ||
setPower: (state, action: PayloadAction<UseInfoType['power']>) => { | ||
state.power = action.payload; | ||
if (state.userInfo) { | ||
state.userInfo.power = action.payload; | ||
} | ||
}, | ||
setSignOut: (state) => { | ||
delete state.userInfo; | ||
delete state.power; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setUserInfo, setPower, setSignOut } = UserSlice.actions; | ||
|
||
export default UserSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters