♻️ refactor api code

This commit is contained in:
felinae98
2022-12-23 21:47:28 +08:00
parent 410cac1af3
commit 0ebbdd2c0d
5 changed files with 189 additions and 193 deletions
@@ -30,15 +30,15 @@ export const login = createAsyncThunk(
);
const setLoginReducer: CaseReducer<AuthStatus, PayloadAction<TokenResp>> = (state, action) => {
if (action.payload.status === 200) {
state.login = true;
state.id = action.payload.id;
state.userType = action.payload.type;
state.token = action.payload.token;
} else {
state.login = false;
state.failed = true;
}
state.login = true;
state.id = action.payload.id;
state.userType = action.payload.type;
state.token = action.payload.token;
};
export const setLoginFailedReducer: CaseReducer<AuthStatus> = (state) => {
state.login = false;
state.failed = true;
};
export const setLogoutReducer: CaseReducer<AuthStatus> = (state) => {
+1 -2
View File
@@ -1,5 +1,4 @@
export interface TokenResp {
status: number;
token: string;
type: string;
id: number;
@@ -44,7 +43,7 @@ export interface SubscribeResp {
}
export interface StatusResp {
status: number;
ok: boolean;
msg: string;
}