mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 09:37:37 +00:00
[web] Add js/ducks/options.js
This commit is contained in:
parent
58af3a6ba4
commit
f95dcfd2e5
32
web/src/js/ducks/options.js
Normal file
32
web/src/js/ducks/options.js
Normal file
@ -0,0 +1,32 @@
|
||||
import { fetchApi } from '../utils'
|
||||
|
||||
export const RECEIVE = 'OPTIONS_RECEIVE'
|
||||
export const UPDATE = 'OPTIONS_UPDATE'
|
||||
export const REQUEST_UPDATE = 'REQUEST_UPDATE'
|
||||
export const UNKNOWN_CMD = 'OPTIONS_UNKNOWN_CMD'
|
||||
|
||||
const defaultState = {
|
||||
|
||||
}
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
|
||||
case RECEIVE:
|
||||
return action.data
|
||||
|
||||
case UPDATE:
|
||||
return {
|
||||
...state,
|
||||
...action.data,
|
||||
}
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
export function update(options) {
|
||||
fetchApi.put('/options', options)
|
||||
return { type: REQUEST_UPDATE }
|
||||
}
|
Loading…
Reference in New Issue
Block a user