Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState({
book,
chapter,
chapterList
});
this.scrollToTop();
this.drawer.closeDrawer();
// 自动缓存后5章
this.onCache(5);
} else {
this.setState({
book,
chapter,
chapterList
});
Modal.alert("缺少资源", JSON.stringify(chapter, null, 2));
}
}
})
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章
this.onCache(5);
} else {
this.setState({
book,
chapter,
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章
onReset = () => {
Modal.alert(
'还原阅读设置',
'字体大小、纸张模式等还原到默认模式,是否确定?',
[
{ text: '取消' },
{
text: '确定',
onPress: () => {
Storage.remove('readSetup')
},
},
]
)
}
submitExchange = () => {
const { originType, originUrl } = this.state;
if (!originType || !originUrl) {
Modal.alert('请将数据请写完整');
return false;
}
Modal.alert('确定使用此数据源?', '', [
{ text: '再想想' },
{
text: '确定使用',
onPress: () => {
this.setState({ visible: false });
Toast.loading("加载中...", 0);
this.props.dispatch(createAction("book/customizeOrigin")({
book: this.book,
dlWay: this.state.dlWay,
origin: originType,
url: originUrl,
...this.afterCallback()
}))
onError: () => {
Modal.alert("此来源缺少数据", "是否切换下载源?", [
{ text: "不用", style: "cancel" },
{
text: "切换",
onPress: () => {
this.props.dispatch(
NavigationActions.navigate({ routeName: "Switching", params: { book: item, dlWay: "all" } })
);
}
}
]);
}
})
submitExchange = () => {
const { originType, originUrl } = this.state;
if (!originType || !originUrl) {
Modal.alert('请将数据请写完整');
return false;
}
Modal.alert('确定使用此数据源?', '', [
{ text: '再想想' },
{
text: '确定使用',
onPress: () => {
this.setState({ visible: false });
Toast.loading("加载中...", 0);
this.props.dispatch(createAction("book/customizeOrigin")({
book: this.book,
dlWay: this.state.dlWay,
origin: originType,
url: originUrl,
...this.afterCallback()
}))
}
},
]);
onClearData = () => {
Modal.alert(
'清空书架',
'删除书架里的所有书本,包括章节、内容等,是否确定?',
[
{ text: '取消' },
{
text: '确定',
onPress: () => {
this.props.dispatch(createAction('book/clear')({}))
},
},
]
)
}
componentWillUnmount() {
Storage.set(`scrollTop_${this.bookId}`, { top: scrollTop });
Toast.hide();
}
onSuccess: () => {
Toast.hide()
this.props.dispatch(
NavigationActions.navigate({
routeName: 'Read',
params: { id: book.id },
})
)
},
onError: () => {