Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//添加搜索记录缓存
if(action.bookName === '' || !action.bookName){
if(state.length === 0){
return historyListArr;
}
return state;
}
if(state.length >= 1){
let has = isInArr(state,[action.bookName]);
if(has){
return state;
}
}
historyListArr.push(action.bookName);
storejs.set('historyListArr',historyListArr);
return historyListArr;
case REMOVE_SEARCH_HISTORY:
if(state.length >= 1 && action !== ''){
//移除缓存记录
historyListArr.splice(historyListArr.indexOf(action.bookName),1);
storejs.set('historyListArr',historyListArr);
let arr = [].concat(state.filter((name) => name !== action.bookName));
return arr;
}
return state;
default:
return state;
}
}
export const readDetail = (state = {}, action) => {
switch (action.type){
case ADD_READ_DETAIL:
action.readObj && storejs.set('readDetail', action.readObj);
return action.readObj.chapter;
default:
return state;
}
}