Skip to content

Commit 29a063a

Browse files
authored
Merge pull request #119 from qqxs/develop
update
2 parents 2d4cb48 + 02ab35a commit 29a063a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/store/features/counter-slice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { type RootState } from '..';
66

77
export interface CounterState {
88
value: number;
9-
status: 'idle' | 'loading' | 'failed';
9+
status: Response.ResponseStatus;
1010
}
1111

1212
const initialState: CounterState = {
1313
value: 0,
14-
status: 'idle',
14+
status: 'loading',
1515
};
1616

1717
// The function below is called a thunk and allows us to perform async logic. It
@@ -53,7 +53,7 @@ export const counterSlice = createSlice({
5353
// state.status = 'loading'
5454
// })
5555
// .addCase(incrementAsync.fulfilled, (state, action) => {
56-
// state.status = 'idle'
56+
// state.status = 'succeeded'
5757
// state.value += action.payload
5858
// })
5959
// .addCase(incrementAsync.rejected, state => {

typings/response.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ declare namespace Response {
1010
error?: string[];
1111
}
1212

13+
/**
14+
* 状态码
15+
*/
16+
export type ResponseStatus = 'succeeded' | 'loading' | 'failed';
17+
1318
/** Redux state , 每项state的value */
1419
export interface ReduxState<T> {
15-
status: keyof typeof ResponseStatus; // RE
20+
status: ResponseStatus; // RE
1621
result: T;
1722
error?: string;
1823
}

0 commit comments

Comments
 (0)