|
@@ -1,54 +1,55 @@
|
|
|
// ------------------------------------
|
|
|
// Constants
|
|
|
// ------------------------------------
|
|
|
-export const COUNTER_INCREMENT = 'COUNTER_INCREMENT'
|
|
|
+// export const COUNTER_INCREMENT = 'COUNTER_INCREMENT'\
|
|
|
+//定义各种 action 的状态
|
|
|
+export const CAPTCHA_GET = 'CAPTCHA_GET';
|
|
|
+export const CAPTCHA_END = 'CAPTCHA_END';
|
|
|
|
|
|
// ------------------------------------
|
|
|
// Actions
|
|
|
// ------------------------------------
|
|
|
-export function increment(value = 1) {
|
|
|
- return {
|
|
|
- type: COUNTER_INCREMENT,
|
|
|
- payload: value,
|
|
|
+export function getcaptcha(value = 1) {
|
|
|
+ return{
|
|
|
+ type: CAPTCHA_GET,
|
|
|
+ payload: value
|
|
|
+ }
|
|
|
+}
|
|
|
+export function endcaptcha(value = 0) {
|
|
|
+ return{
|
|
|
+ type: CAPTCHA_END,
|
|
|
+ payload: value
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* This is a thunk, meaning it is a function that immediately
|
|
|
- returns a function for lazy evaluation. It is incredibly useful for
|
|
|
- creating async actions, especially when combined with redux-thunk!
|
|
|
-
|
|
|
- NOTE: This is solely for demonstration purposes. In a real application,
|
|
|
- you'd probably want to dispatch an action of COUNTER_DOUBLE and let the
|
|
|
- reducer take care of this logic. */
|
|
|
-
|
|
|
-export const doubleAsync = () => (
|
|
|
- (dispatch, getState) => (
|
|
|
- new Promise((resolve) => {
|
|
|
- setTimeout(() => {
|
|
|
- dispatch(increment(getState().counter))
|
|
|
- resolve()
|
|
|
- }, 200)
|
|
|
- })
|
|
|
- )
|
|
|
-)
|
|
|
+// export function increment(value = 1) {
|
|
|
+// return {
|
|
|
+// type: COUNTER_INCREMENT,
|
|
|
+// payload: value,
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
export const actions = {
|
|
|
- increment,
|
|
|
- doubleAsync,
|
|
|
+ getcaptcha,
|
|
|
+ endcaptcha
|
|
|
+ // increment,
|
|
|
+ // doubleAsync,
|
|
|
}
|
|
|
|
|
|
// ------------------------------------
|
|
|
// Action Handlers
|
|
|
+// 定义 reduce 的 action 集合
|
|
|
// ------------------------------------
|
|
|
const ACTION_HANDLERS = {
|
|
|
- [COUNTER_INCREMENT]: (state, action) => state + action.payload,
|
|
|
+ [CAPTCHA_GET]: (state, action) => state+action.payload,
|
|
|
+ [CAPTCHA_END]: (state, action) => state+action.payload,
|
|
|
}
|
|
|
|
|
|
// ------------------------------------
|
|
|
// Reducer
|
|
|
// ------------------------------------
|
|
|
const initialState = 0
|
|
|
-export default function counterReducer(state = initialState, action) {
|
|
|
+export default function LoginReducer(state = initialState, action) {
|
|
|
const handler = ACTION_HANDLERS[action.type]
|
|
|
|
|
|
return handler ? handler(state, action) : state
|