Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!chapterList) {
chapterList = this.state.chapterList;
}
if (chapter.content) {
this.setState({
book,
chapter,
chapterList
});
this.scrollToTop();
this.drawer.closeDrawer();
// 自动缓存后5章
this.onCache(5);
} else {
Toast.loading("正在下载内容...", 0);
this.props.dispatch(
createAction("book/searchContent")({
chapter,
callback: content => {
Toast.hide();
if (content) {
chapter.content = content;
chapterList.find(item => item.id === chapter.id).content = content;
this.setState({
book,
chapter,
chapterList
});
this.scrollToTop();
this.drawer.closeDrawer();
// 自动缓存后5章
onToRead = () => {
const { book } = this.state
if (!book.url) {
Toast.loading('初次阅读,正在加载章节列表...', 0)
this.props.dispatch(
createAction('book/searchBookUrl')({
book,
onSuccess: () => {
Toast.hide()
this.props.dispatch(
NavigationActions.navigate({
routeName: 'Read',
params: { id: book.id },
})
)
},
onError: () => {
Toast.fail('缺乏资源,无法阅读', 1)
},
})
onRowClick = (item) => {
const {dispatch} = this.props;
Toast.loading("加载中...", 0);
dispatch(createAction("book/replaceChapters")({
book: this.book,
dlWay: this.state.dlWay,
origin: item,
...this.afterCallback()
}));
};
onItemClick = item => {
if (!item.url) {
Toast.loading("初次阅读,正在加载章节列表...", 0);
this.props.dispatch(
createAction("book/searchBookUrl")({
book: item,
onSuccess: () => {
Toast.hide();
this.props.dispatch(
NavigationActions.navigate({
routeName: "Read",
params: { id: item.id }
})
);
},
onError: () => {
Modal.alert("此来源缺少数据", "是否切换下载源?", [
{ text: "不用", style: "cancel" },
{