Compare commits

...

5 Commits

Author SHA1 Message Date
dependabot[bot]
53608b508b
Merge 6aa0d9a239 into 5acfe9be68 2024-06-10 23:27:25 +08:00
Horis
5acfe9be68 优化 2024-06-09 19:26:29 +08:00
Horis
e081b4b470 优化 2024-06-09 12:34:53 +08:00
Horis
2f2ba9a751 优化 2024-06-09 11:50:36 +08:00
dependabot[bot]
6aa0d9a239
Bump eslint from 8.57.0 to 9.4.0 in /modules/web
Bumps [eslint](https://github.com/eslint/eslint) from 8.57.0 to 9.4.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.57.0...v9.4.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 04:55:19 +00:00
6 changed files with 30 additions and 9 deletions

View File

@ -27,6 +27,15 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio
return Coroutine.async(scope, context, start, executeContext, block)
}
fun <T> executeLazy(
scope: CoroutineScope = viewModelScope,
context: CoroutineContext = Dispatchers.IO,
executeContext: CoroutineContext = Dispatchers.Main,
block: suspend CoroutineScope.() -> T
): Coroutine<T> {
return Coroutine.async(scope, context, CoroutineStart.LAZY, executeContext, block)
}
fun <R> submit(
scope: CoroutineScope = viewModelScope,
context: CoroutineContext = Dispatchers.IO,

View File

@ -188,6 +188,7 @@ class ContentProcessor private constructor(
mContent = mContent.replace('\u00A0', ' ')
}
val contents = arrayListOf<String>()
val paragraphIndent = ReadBookConfig.paragraphIndent
mContent.split("\n").forEach { str ->
val paragraph = str.trim {
it.code <= 0x20 || it == ' '
@ -196,10 +197,14 @@ class ContentProcessor private constructor(
if (contents.isEmpty() && includeTitle) {
contents.add(paragraph)
} else {
contents.add("${ReadBookConfig.paragraphIndent}$paragraph")
contents.add("$paragraphIndent$paragraph")
}
}
}
if (contents.isEmpty()) {
contents.add("${paragraphIndent}加载正文失败")
contents.add("${paragraphIndent}内容处理后为空")
}
return BookContent(sameTitleRemoved, contents, effectiveReplaceRules)
}

View File

@ -170,7 +170,11 @@ class RemoteBookActivity : BaseImportBookActivity<RemoteBookViewModel>(),
private fun upPath() {
binding.tvGoBack.isEnabled = viewModel.dirList.isNotEmpty()
var path = "books" + File.separator
var path = if (viewModel.isDefaultWebdav) {
"books" + File.separator
} else {
File.separator
}
viewModel.dirList.forEach {
path = path + it.filename + File.separator
}

View File

@ -90,14 +90,17 @@ class RemoteBookViewModel(application: Application) : BaseViewModel(application)
}.flowOn(Dispatchers.IO)
private var remoteBookWebDav: RemoteBookWebDav? = null
var isDefaultWebdav = false
fun initData(onSuccess: () -> Unit) {
execute {
isDefaultWebdav = false
appDb.serverDao.get(AppConfig.remoteServerId)?.getWebDavConfig()?.let {
val authorization = Authorization(it)
remoteBookWebDav = RemoteBookWebDav(it.url, authorization, AppConfig.remoteServerId)
return@execute
}
isDefaultWebdav = true
remoteBookWebDav = AppWebDav.defaultBookWebDav
?: throw NoStackTraceException("webDav没有配置")
}.onError {
@ -108,7 +111,7 @@ class RemoteBookViewModel(application: Application) : BaseViewModel(application)
}
fun loadRemoteBookList(path: String?, loadCallback: (loading: Boolean) -> Unit) {
execute {
executeLazy {
val bookWebDav = remoteBookWebDav
?: throw NoStackTraceException("没有配置webDav")
dataCallback?.clear()
@ -122,7 +125,7 @@ class RemoteBookViewModel(application: Application) : BaseViewModel(application)
loadCallback.invoke(true)
}.onFinally {
loadCallback.invoke(false)
}
}.start()
}
fun addToBookshelf(remoteBooks: HashSet<RemoteBook>, finally: () -> Unit) {

View File

@ -154,8 +154,8 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) {
*/
private fun calcNextPageOffset(): Int {
val visibleHeight = ChapterProvider.visibleHeight
val book = ReadBook.book!!
if (book.isImage) {
val book = ReadBook.book
if (book == null || book.isImage) {
return -visibleHeight
}
val visiblePage = readView.getCurVisiblePage()
@ -170,8 +170,8 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) {
private fun calcPrevPageOffset(): Int {
val visibleHeight = ChapterProvider.visibleHeight
val book = ReadBook.book!!
if (book.isImage) {
val book = ReadBook.book
if (book == null || book.isImage) {
return visibleHeight
}
val visiblePage = readView.getCurVisiblePage()

View File

@ -27,7 +27,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"eslint": "^8.40.0",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-vue": "^9.12.0",