Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const chaptersList = (state = {}, action) => {
switch (action.type){
case ADD_CHAPTERS_LIST:{
let focusBooks = storejs.get("focusBooks") || [];
focusBooks.push()
return action.chapters;
}
default:
return state;
}
}
export const historyList = (state = [], action = '') => {
var historyListArr = storejs.get("historyListArr") || [];
switch (action.type){
case ADD_SEARCH_HISTORY:
//添加搜索记录缓存
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;
}
}
//添加搜索记录缓存
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;
}
}