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