File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ import { type RootState } from '..';
66
77export interface CounterState {
88 value : number ;
9- status : 'idle' | 'loading' | 'failed' ;
9+ status : Response . ResponseStatus ;
1010}
1111
1212const 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 => {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments