params' default value

This commit is contained in:
CPunisher 2020-05-14 13:55:31 +08:00
parent 403ea01769
commit 1520ecfcf6
1 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@ const initialState = {
} }
export default function appReducer(state = initialState, action) { export default function appReducer(state = initialState, action) {
console.log(state.paramValue)
switch (action.type) { switch (action.type) {
case actionTypes.GENERATE_QR_INFO: { case actionTypes.GENERATE_QR_INFO: {
let text = action.text; let text = action.text;
@ -53,7 +54,13 @@ export default function appReducer(state = initialState, action) {
} }
const newItem = item.slice(); const newItem = item.slice();
newItem[action.paramIndex] = isNaN(action.value) ? action.value : parseInt(action.value); let newValue = action.value;
if (newValue.length <= 0)
newValue = state.paramInfo[action.rendererIndex][action.paramIndex].default;
console.log(newValue)
if (!isNaN(newValue)) newValue = parseInt(newValue);
newItem[action.paramIndex] = newValue;
return newItem; return newItem;
}) })
}); });