mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
[web] fix bugs
This commit is contained in:
parent
e11d6600be
commit
c40ff0277b
File diff suppressed because one or more lines are too long
@ -17,8 +17,8 @@ const defaultState = {
|
|||||||
logId: 0,
|
logId: 0,
|
||||||
visible: false,
|
visible: false,
|
||||||
filters: { debug: false, info: true, web: true },
|
filters: { debug: false, info: true, web: true },
|
||||||
list: null,
|
list: undefined,
|
||||||
view: null,
|
view: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function reduce(state = defaultState, action) {
|
export default function reduce(state = defaultState, action) {
|
||||||
|
@ -15,8 +15,8 @@ export const UNKNOWN_CMD = 'FLOWS_UNKNOWN_CMD'
|
|||||||
export const FETCH_ERROR = 'FLOWS_FETCH_ERROR'
|
export const FETCH_ERROR = 'FLOWS_FETCH_ERROR'
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
list: null,
|
list: undefined,
|
||||||
views: null,
|
views: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function reduce(state = defaultState, action) {
|
export default function reduce(state = defaultState, action) {
|
||||||
|
@ -11,22 +11,27 @@ const defaultState = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function reduce(state = defaultState, action) {
|
export default function reduce(state = defaultState, action) {
|
||||||
if (state.pendingActions && action.type !== RECEIVE) {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
pendingActions: [...state.pendingActions, action]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
case SET:
|
case SET:
|
||||||
|
if (state.pendingActions) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
pendingActions: [...state.pendingActions, action]
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: { ...state.data, [action.id]: null, [action.item.id]: action.item }
|
data: { ...state.data, [action.id]: null, [action.item.id]: action.item }
|
||||||
}
|
}
|
||||||
|
|
||||||
case CLEAR:
|
case CLEAR:
|
||||||
|
if (state.pendingActions) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
pendingActions: [...state.pendingActions, action]
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: { ...state.data, [action.id]: null }
|
data: { ...state.data, [action.id]: null }
|
||||||
|
@ -15,21 +15,23 @@ const defaultState = {
|
|||||||
export default function reduce(state = defaultState, action) {
|
export default function reduce(state = defaultState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
case UPDATE_FILTER:
|
case UPDATE_FILTER: {
|
||||||
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data,
|
data,
|
||||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case UPDATE_SORTER:
|
case UPDATE_SORTER: {
|
||||||
const data = state.data.slice().sort(action.sorter)
|
const data = [...state.data].sort(action.sorter)
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data,
|
data,
|
||||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index]))
|
indexOf: _.fromPairs(data.map((item, index) => [item.id, index]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case ADD:
|
case ADD:
|
||||||
if (state.indexOf[action.item.id] != null || !action.filter(action.item)) {
|
if (state.indexOf[action.item.id] != null || !action.filter(action.item)) {
|
||||||
@ -49,7 +51,7 @@ export default function reduce(state = defaultState, action) {
|
|||||||
...sortedRemove(state, action.id),
|
...sortedRemove(state, action.id),
|
||||||
}
|
}
|
||||||
|
|
||||||
case UPDATE:
|
case UPDATE: {
|
||||||
if (state.indexOf[action.item.id] == null) {
|
if (state.indexOf[action.item.id] == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -64,14 +66,16 @@ export default function reduce(state = defaultState, action) {
|
|||||||
...nextState,
|
...nextState,
|
||||||
...sortedInsert(nextState, action.item, action.sorter)
|
...sortedInsert(nextState, action.item, action.sorter)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case RECEIVE:
|
case RECEIVE: {
|
||||||
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data,
|
data,
|
||||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
@ -2,6 +2,11 @@ import { combineReducers } from 'redux'
|
|||||||
import * as viewActions from './utils/view'
|
import * as viewActions from './utils/view'
|
||||||
import main from './views/main.js'
|
import main from './views/main.js'
|
||||||
|
|
||||||
|
export const ADD = 'FLOW_VIEWS_ADD'
|
||||||
|
export const UPDATE = 'FLOW_VIEWS_UPDATE'
|
||||||
|
export const REMOVE = 'FLOW_VIEWS_REMOVE'
|
||||||
|
export const RECEIVE = 'FLOW_VIEWS_RECEIVE'
|
||||||
|
|
||||||
export default combineReducers({
|
export default combineReducers({
|
||||||
main,
|
main,
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import reduceView, * as viewActions from '../utils/list'
|
import reduceView, * as viewActions from '../utils/list'
|
||||||
import * as viewsActions from '../views'
|
import * as viewsActions from '../views'
|
||||||
|
|
||||||
export const UPDATE_FILTER = 'MAIN_VIEW_UPDATE_FILTER'
|
export const UPDATE_FILTER = 'FLOW_VIEWS_MAIN_UPDATE_FILTER'
|
||||||
export const UPDATE_SORTER = 'MAIN_VIEW_UPDATE_SORTER'
|
export const UPDATE_SORTER = 'FLOW_VIEWS_MAIN_UPDATE_SORTER'
|
||||||
export const UPDATE_HIGHLIGHT = 'MAIN_VIEW_UPDATE_HIGHLIGHT'
|
export const UPDATE_HIGHLIGHT = 'FLOW_VIEWS_MAIN_UPDATE_HIGHLIGHT'
|
||||||
export const SELECT = 'MAIN_VIEW_SELECT'
|
export const SELECT = 'FLOW_VIEWS_MAIN_SELECT'
|
||||||
|
|
||||||
const sortKeyFuns = {
|
const sortKeyFuns = {
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ const defaultState = {
|
|||||||
selected: [],
|
selected: [],
|
||||||
filter: null,
|
filter: null,
|
||||||
sorter: { column: null, desc: false },
|
sorter: { column: null, desc: false },
|
||||||
view: null,
|
view: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function reduce(state = defaultState, action) {
|
export default function reduce(state = defaultState, action) {
|
||||||
|
Loading…
Reference in New Issue
Block a user