|
@@ -19,12 +19,16 @@ export default class extends Page {
|
|
|
this.pageLine = 100;
|
|
|
}
|
|
|
|
|
|
+ initState() {
|
|
|
+ return { article: {}, showJump: false, showMenu: false, currentPage: 0, totalPage: 0 };
|
|
|
+ }
|
|
|
+
|
|
|
init() {
|
|
|
this.lastTime = new Date();
|
|
|
- }
|
|
|
|
|
|
- initState() {
|
|
|
- return { showJump: false, showMenu: false, currentPage: 0, totalPage: 0 };
|
|
|
+ Main.getSentence().then(result => {
|
|
|
+ this.setState({ info: result });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
initData() {
|
|
@@ -42,9 +46,6 @@ export default class extends Page {
|
|
|
}
|
|
|
this.jumpPage(page);
|
|
|
});
|
|
|
- Main.getSentence().then(result => {
|
|
|
- this.setState({ info: result });
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
refreshSentence() {
|
|
@@ -107,9 +108,15 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
nextPage() {
|
|
|
+ const { sentence = {} } = this.state;
|
|
|
const { currentPage, totalPage } = this.state;
|
|
|
if (currentPage < totalPage) {
|
|
|
this.jumpPage(currentPage + 1);
|
|
|
+ } else {
|
|
|
+ const code = !!sentence.code;
|
|
|
+ if (!code) {
|
|
|
+ this.setState({ article: null });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -117,7 +124,7 @@ export default class extends Page {
|
|
|
// 计算哪篇文章
|
|
|
const { target, index, allow } = this.computeArticle(targetPage);
|
|
|
if (!allow) {
|
|
|
- // todo 无法访问:非试用
|
|
|
+ this.setState({ article: null });
|
|
|
return;
|
|
|
}
|
|
|
this.page = targetPage;
|
|
@@ -186,14 +193,20 @@ export default class extends Page {
|
|
|
clearTimeout(this.timeout);
|
|
|
this.timeout = null;
|
|
|
}
|
|
|
- const now = new Date();
|
|
|
- const time = (now.getTime() - this.lastTime.getTime()) / 1000;
|
|
|
- this.lastTime = now;
|
|
|
const progress = ((index + 1) * 100) / target.pages;
|
|
|
- Sentence.updateProgress(target.chapter, target.part, progress, time, current.chapter, current.page);
|
|
|
+ if (target.chapter === current.chapter && target.part === current.part) {
|
|
|
+ Sentence.updateProgress(target.chapter, target.part, progress);
|
|
|
+ } else {
|
|
|
+ const now = new Date();
|
|
|
+ const time = (now.getTime() - this.lastTime.getTime()) / 1000;
|
|
|
+ this.lastTime = now;
|
|
|
+ Sentence.updateProgress(target.chapter, target.part, progress, time, current.chapter, current.part);
|
|
|
+ }
|
|
|
+
|
|
|
this.timeout = setTimeout(() => {
|
|
|
// 最长5分钟阅读时间
|
|
|
Sentence.updateProgress(0, 0, 0, 5 * 60, target.chapter, target.part);
|
|
|
+ this.lastTime = null;
|
|
|
}, 5 * 60 * 1000);
|
|
|
}
|
|
|
|
|
@@ -234,8 +247,7 @@ export default class extends Page {
|
|
|
})}
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- );
|
|
|
+ </div>);
|
|
|
}
|
|
|
|
|
|
renderMenu() {
|
|
@@ -276,8 +288,7 @@ export default class extends Page {
|
|
|
{chapter.title}
|
|
|
<div className="page">{chapter.startPage}</div>
|
|
|
</div>
|
|
|
- </Tooltip>
|
|
|
- );
|
|
|
+ </Tooltip>);
|
|
|
const list = [_item];
|
|
|
if (chapter.value) {
|
|
|
(articleMap[chapter.value] || []).forEach(article => {
|
|
@@ -298,8 +309,7 @@ export default class extends Page {
|
|
|
{article.title}
|
|
|
<div className="page">{article.startPage}</div>
|
|
|
</div>
|
|
|
- </Tooltip>
|
|
|
- );
|
|
|
+ </Tooltip>);
|
|
|
list.push(item);
|
|
|
});
|
|
|
}
|