mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
7295a5ed89
commit
96f8d3bd97
@ -29,7 +29,10 @@ footer, header, hgroup, menu, nav, section {
|
|||||||
body {
|
body {
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),url("../../images/bg.jpg") no-repeat center center fixed;
|
background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),url("../../images/bg.jpg") no-repeat center center fixed;
|
||||||
background-size: 100%;
|
-webkit-background-size: cover;
|
||||||
|
-moz-background-size: cover;
|
||||||
|
-o-background-size: cover;
|
||||||
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol, ul {
|
ol, ul {
|
||||||
|
@ -245,6 +245,14 @@ data class Book(
|
|||||||
return config.delTag and tag == tag
|
return config.delTag and tag == tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addDelTag(tag: Long) {
|
||||||
|
config.delTag = config.delTag and tag
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeDelTag(tag: Long) {
|
||||||
|
config.delTag = config.delTag and tag.inv()
|
||||||
|
}
|
||||||
|
|
||||||
fun getFolderName(): String {
|
fun getFolderName(): String {
|
||||||
folderName?.let {
|
folderName?.let {
|
||||||
return it
|
return it
|
||||||
|
@ -67,6 +67,10 @@ class EpubFile(var book: Book) {
|
|||||||
override fun upBookInfo(book: Book) {
|
override fun upBookInfo(book: Book) {
|
||||||
return getEFile(book).upBookInfo()
|
return getEFile(book).upBookInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
eFile = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var mCharset: Charset = Charset.defaultCharset()
|
private var mCharset: Charset = Charset.defaultCharset()
|
||||||
@ -182,11 +186,11 @@ class EpubFile(var book: Book) {
|
|||||||
}
|
}
|
||||||
it.attr("src", absSrc)
|
it.attr("src", absSrc)
|
||||||
}
|
}
|
||||||
var html = elements.outerHtml()
|
|
||||||
val tag = Book.rubyTag
|
val tag = Book.rubyTag
|
||||||
if (book.getDelTag(tag)) {
|
if (book.getDelTag(tag)) {
|
||||||
html = html.replace("<ruby>\\s?([\\u4e00-\\u9fa5])\\s?.*?</ruby>".toRegex(), "$1")
|
elements.select("rp, rt").remove()
|
||||||
}
|
}
|
||||||
|
val html = elements.outerHtml()
|
||||||
return HtmlFormatter.formatKeepImg(html)
|
return HtmlFormatter.formatKeepImg(html)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,12 +246,7 @@ class EpubFile(var book: Book) {
|
|||||||
val tag = Book.hTag
|
val tag = Book.hTag
|
||||||
if (book.getDelTag(tag)) {
|
if (book.getDelTag(tag)) {
|
||||||
bodyElement.run {
|
bodyElement.run {
|
||||||
getElementsByTag("h1").remove()
|
select("h1, h2, h3, h4, h5, h6").remove()
|
||||||
getElementsByTag("h2").remove()
|
|
||||||
getElementsByTag("h3").remove()
|
|
||||||
getElementsByTag("h4").remove()
|
|
||||||
getElementsByTag("h5").remove()
|
|
||||||
getElementsByTag("h6").remove()
|
|
||||||
//getElementsMatchingOwnText(chapter.title)?.remove()
|
//getElementsMatchingOwnText(chapter.title)?.remove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ class TextFile(private val book: Book) {
|
|||||||
companion object {
|
companion object {
|
||||||
private val padRegex = "^[\\n\\s]+".toRegex()
|
private val padRegex = "^[\\n\\s]+".toRegex()
|
||||||
private const val bufferSize = 8 * 1024 * 1024
|
private const val bufferSize = 8 * 1024 * 1024
|
||||||
|
private var bufferStart = -1
|
||||||
|
private var bufferEnd = -1
|
||||||
var txtBuffer: ByteArray? = null
|
var txtBuffer: ByteArray? = null
|
||||||
var bufferStart = -1
|
|
||||||
var bufferEnd = -1
|
|
||||||
var bookUrl = ""
|
var bookUrl = ""
|
||||||
|
|
||||||
@Throws(FileNotFoundException::class)
|
@Throws(FileNotFoundException::class)
|
||||||
|
@ -40,6 +40,7 @@ import io.legado.app.lib.theme.accentColor
|
|||||||
import io.legado.app.model.ReadAloud
|
import io.legado.app.model.ReadAloud
|
||||||
import io.legado.app.model.ReadBook
|
import io.legado.app.model.ReadBook
|
||||||
import io.legado.app.model.analyzeRule.AnalyzeRule
|
import io.legado.app.model.analyzeRule.AnalyzeRule
|
||||||
|
import io.legado.app.model.localBook.EpubFile
|
||||||
import io.legado.app.receiver.TimeBatteryReceiver
|
import io.legado.app.receiver.TimeBatteryReceiver
|
||||||
import io.legado.app.service.BaseReadAloudService
|
import io.legado.app.service.BaseReadAloudService
|
||||||
import io.legado.app.ui.about.AppLogDialog
|
import io.legado.app.ui.about.AppLogDialog
|
||||||
@ -332,6 +333,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
R.id.menu_group_on_line -> item.isVisible = onLine
|
R.id.menu_group_on_line -> item.isVisible = onLine
|
||||||
R.id.menu_group_local -> item.isVisible = !onLine
|
R.id.menu_group_local -> item.isVisible = !onLine
|
||||||
R.id.menu_group_text -> item.isVisible = book.isLocalTxt
|
R.id.menu_group_text -> item.isVisible = book.isLocalTxt
|
||||||
|
R.id.menu_group_epub -> item.isVisible = book.isEpub
|
||||||
else -> when (item.itemId) {
|
else -> when (item.itemId) {
|
||||||
R.id.menu_enable_replace -> item.isChecked = book.getUseReplaceRule()
|
R.id.menu_enable_replace -> item.isChecked = book.getUseReplaceRule()
|
||||||
R.id.menu_re_segment -> item.isChecked = book.getReSegment()
|
R.id.menu_re_segment -> item.isChecked = book.getReSegment()
|
||||||
@ -341,6 +343,8 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_reverse_content -> item.isVisible = onLine
|
R.id.menu_reverse_content -> item.isVisible = onLine
|
||||||
|
R.id.menu_del_ruby_tag -> item.isChecked = book.getDelTag(Book.rubyTag)
|
||||||
|
R.id.menu_del_h_tag -> item.isChecked = book.getDelTag(Book.hTag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,9 +409,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
upContent()
|
upContent()
|
||||||
} else {
|
} else {
|
||||||
ReadBook.book?.let {
|
ReadBook.book?.let {
|
||||||
ReadBook.clearTextChapter()
|
refreshContentDur(it)
|
||||||
binding.readView.upContent()
|
|
||||||
viewModel.refreshContentAll(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,6 +420,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
R.id.menu_update_toc -> ReadBook.book?.let {
|
R.id.menu_update_toc -> ReadBook.book?.let {
|
||||||
if (it.isEpub) {
|
if (it.isEpub) {
|
||||||
BookHelp.clearCache(it)
|
BookHelp.clearCache(it)
|
||||||
|
EpubFile.clear()
|
||||||
}
|
}
|
||||||
loadChapterList(it)
|
loadChapterList(it)
|
||||||
}
|
}
|
||||||
@ -425,16 +428,36 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
R.id.menu_enable_replace -> changeReplaceRuleState()
|
R.id.menu_enable_replace -> changeReplaceRuleState()
|
||||||
R.id.menu_re_segment -> ReadBook.book?.let {
|
R.id.menu_re_segment -> ReadBook.book?.let {
|
||||||
it.setReSegment(!it.getReSegment())
|
it.setReSegment(!it.getReSegment())
|
||||||
menu?.findItem(R.id.menu_re_segment)?.isChecked = it.getReSegment()
|
item.isChecked = it.getReSegment()
|
||||||
ReadBook.loadContent(false)
|
ReadBook.loadContent(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_enable_review -> {
|
R.id.menu_enable_review -> {
|
||||||
AppConfig.enableReview = !AppConfig.enableReview
|
AppConfig.enableReview = !AppConfig.enableReview
|
||||||
menu?.findItem(R.id.menu_enable_review)?.isChecked = AppConfig.enableReview
|
item.isChecked = AppConfig.enableReview
|
||||||
ReadBook.loadContent(false)
|
ReadBook.loadContent(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
R.id.menu_del_ruby_tag -> ReadBook.book?.let {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
if (item.isChecked) {
|
||||||
|
it.addDelTag(Book.rubyTag)
|
||||||
|
} else {
|
||||||
|
it.removeDelTag(Book.rubyTag)
|
||||||
|
}
|
||||||
|
refreshContentDur(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.menu_del_h_tag -> ReadBook.book?.let {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
if (item.isChecked) {
|
||||||
|
it.addDelTag(Book.hTag)
|
||||||
|
} else {
|
||||||
|
it.removeDelTag(Book.hTag)
|
||||||
|
}
|
||||||
|
refreshContentDur(it)
|
||||||
|
}
|
||||||
|
|
||||||
R.id.menu_page_anim -> showPageAnimConfig {
|
R.id.menu_page_anim -> showPageAnimConfig {
|
||||||
binding.readView.upPageAnim()
|
binding.readView.upPageAnim()
|
||||||
ReadBook.loadContent(false)
|
ReadBook.loadContent(false)
|
||||||
@ -491,6 +514,12 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
return super.onCompatOptionsItemSelected(item)
|
return super.onCompatOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun refreshContentDur(book: Book) {
|
||||||
|
ReadBook.curTextChapter = null
|
||||||
|
binding.readView.upContent()
|
||||||
|
viewModel.refreshContentDur(book)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
return onCompatOptionsItemSelected(item)
|
return onCompatOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_same_title_removed"
|
android:id="@+id/menu_same_title_removed"
|
||||||
android:title="@string/same_title_removed"
|
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
|
android:title="@string/same_title_removed"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@ -98,6 +98,24 @@
|
|||||||
android:visible="false"
|
android:visible="false"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<group android:id="@+id/menu_group_epub">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_del_ruby_tag"
|
||||||
|
android:checkable="true"
|
||||||
|
android:checked="false"
|
||||||
|
android:title="@string/del_ruby_tag"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_del_h_tag"
|
||||||
|
android:checkable="true"
|
||||||
|
android:checked="false"
|
||||||
|
android:title="@string/del_h_tag"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_image_style"
|
android:id="@+id/menu_image_style"
|
||||||
android:title="@string/image_style"
|
android:title="@string/image_style"
|
||||||
|
@ -1134,4 +1134,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1137,4 +1137,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1137,4 +1137,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1133,4 +1133,6 @@ Còn </string>
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1134,4 +1134,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1136,4 +1136,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1136,4 +1136,6 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
|
<string name="del_h_tag">删除h标签</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1137,4 +1137,6 @@
|
|||||||
<string name="preview_image_by_click">Click to preview image</string>
|
<string name="preview_image_by_click">Click to preview image</string>
|
||||||
<string name="default_home_page">Default HomePage</string>
|
<string name="default_home_page">Default HomePage</string>
|
||||||
<string name="screen_portrait_reversed">Portrait Reversed</string>
|
<string name="screen_portrait_reversed">Portrait Reversed</string>
|
||||||
|
<string name="del_ruby_tag">Delete ruby tag</string>
|
||||||
|
<string name="del_h_tag">Delete h tag</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -69,6 +69,7 @@ const gotoChapter = (note) => {
|
|||||||
currentChapterIndex.value = chapterIndex;
|
currentChapterIndex.value = chapterIndex;
|
||||||
store.setPopCataVisible(false);
|
store.setPopCataVisible(false);
|
||||||
store.setContentLoading(true);
|
store.setContentLoading(true);
|
||||||
|
store.saveBookProgress();
|
||||||
emit("getContent", chapterIndex);
|
emit("getContent", chapterIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ import jump from "@/plugins/jump";
|
|||||||
import settings from "@/config/themeConfig";
|
import settings from "@/config/themeConfig";
|
||||||
import API from "@api";
|
import API from "@api";
|
||||||
import { useLoading } from "@/hooks/loading";
|
import { useLoading } from "@/hooks/loading";
|
||||||
|
import { useThrottleFn } from "@vueuse/shared";
|
||||||
|
|
||||||
const content = ref();
|
const content = ref();
|
||||||
// loading spinner
|
// loading spinner
|
||||||
@ -299,8 +300,13 @@ const toChapterPos = (pos) => {
|
|||||||
chapterRef.value[0].scrollToReadedLength(pos);
|
chapterRef.value[0].scrollToReadedLength(pos);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 60秒保存一次进度
|
||||||
|
const saveBookProgressThrottle = useThrottleFn(() => store.saveBookProgress(), 60000)
|
||||||
|
|
||||||
const onReadedLengthChange = (index, pos) => {
|
const onReadedLengthChange = (index, pos) => {
|
||||||
saveReadingBookProgressToBrowser(index, pos);
|
saveReadingBookProgressToBrowser(index, pos);
|
||||||
|
saveBookProgressThrottle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文档标题
|
// 文档标题
|
||||||
@ -354,6 +360,7 @@ const toNextChapter = () => {
|
|||||||
type: "info",
|
type: "info",
|
||||||
});
|
});
|
||||||
getContent(index);
|
getContent(index);
|
||||||
|
store.saveBookProgress();
|
||||||
} else {
|
} else {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "本章是最后一章",
|
message: "本章是最后一章",
|
||||||
@ -370,6 +377,7 @@ const toPreChapter = () => {
|
|||||||
type: "info",
|
type: "info",
|
||||||
});
|
});
|
||||||
getContent(index);
|
getContent(index);
|
||||||
|
store.saveBookProgress();
|
||||||
} else {
|
} else {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "本章是第一章",
|
message: "本章是第一章",
|
||||||
@ -392,6 +400,7 @@ const loadMore = () => {
|
|||||||
let index = chapterData.value.slice(-1)[0].index;
|
let index = chapterData.value.slice(-1)[0].index;
|
||||||
if (catalog.value.length - 1 > index) {
|
if (catalog.value.length - 1 > index) {
|
||||||
getContent(index + 1, false);
|
getContent(index + 1, false);
|
||||||
|
store.saveBookProgress(); // 保存的是上一章的进度,不是预载的本章进度
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// IntersectionObserver回调 底部加载
|
// IntersectionObserver回调 底部加载
|
||||||
|
Loading…
Reference in New Issue
Block a user