mirror of
https://github.com/gedoor/legado.git
synced 2024-07-19 01:17:25 +08:00
优化
This commit is contained in:
parent
161a93bf28
commit
324711c384
@ -263,7 +263,7 @@ const getContent = (index, reloadChapter = true, chapterPos = 0) => {
|
|||||||
let data = res.data.data;
|
let data = res.data.data;
|
||||||
let content = data.split(/\n+/);
|
let content = data.split(/\n+/);
|
||||||
updateChapterData({ index, content, title }, reloadChapter);
|
updateChapterData({ index, content, title }, reloadChapter);
|
||||||
toChapterPos(chapterPos);
|
if (reloadChapter) toChapterPos(chapterPos);
|
||||||
} else {
|
} else {
|
||||||
ElMessage({ message: res.data.errorMsg, type: "error" });
|
ElMessage({ message: res.data.errorMsg, type: "error" });
|
||||||
let content = [res.data.errorMsg];
|
let content = [res.data.errorMsg];
|
||||||
@ -291,6 +291,7 @@ const chapter = ref();
|
|||||||
const toChapterPos = (pos) => {
|
const toChapterPos = (pos) => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let wordCount = 0;
|
let wordCount = 0;
|
||||||
|
if (chapter.value.length != 1) return;
|
||||||
for (let element of chapter.value[0].children) {
|
for (let element of chapter.value[0].children) {
|
||||||
wordCount += parseInt(element.getAttribute("wordCount")) + 1;//计算换行符
|
wordCount += parseInt(element.getAttribute("wordCount")) + 1;//计算换行符
|
||||||
if (wordCount - 1 >= pos) {
|
if (wordCount - 1 >= pos) {
|
||||||
|
Loading…
Reference in New Issue
Block a user