Compare commits

...

5 Commits

Author SHA1 Message Date
dependabot[bot]
fd287cd506
Merge e81bb573a4 into 2aed021e08 2024-05-11 22:48:59 +08:00
Horis
2aed021e08 优化
#3929
2024-05-11 19:26:30 +08:00
Horis
06d486c96c 优化 2024-05-11 06:57:32 +08:00
Horis
a35b7737aa 优化 2024-05-10 14:36:01 +08:00
dependabot[bot]
e81bb573a4
Bump eslint from 8.57.0 to 9.2.0 in /modules/web
Bumps [eslint](https://github.com/eslint/eslint) from 8.57.0 to 9.2.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.2.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-05-06 04:25:14 +00:00
10 changed files with 35 additions and 25 deletions

View File

@ -284,14 +284,6 @@ data class Book(
} }
} }
fun getBookSource(): BookSource? {
return appDb.bookSourceDao.getBookSource(origin)
}
fun isLocalModified(): Boolean {
return isLocal && LocalBook.getLastModified(this).getOrDefault(0L) > latestChapterTime
}
fun toSearchBook() = SearchBook( fun toSearchBook() = SearchBook(
name = name, name = name,
author = author, author = author,

View File

@ -5,17 +5,26 @@ package io.legado.app.help.book
import android.net.Uri import android.net.Uri
import com.script.SimpleBindings import com.script.SimpleBindings
import com.script.rhino.RhinoScriptEngine import com.script.rhino.RhinoScriptEngine
import io.legado.app.constant.* import io.legado.app.constant.AppLog
import io.legado.app.constant.BookSourceType
import io.legado.app.constant.BookType
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.BaseBook import io.legado.app.data.entities.BaseBook
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.exception.NoStackTraceException import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.utils.* import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.FileDoc
import io.legado.app.utils.exists
import io.legado.app.utils.find
import io.legado.app.utils.inputStream
import io.legado.app.utils.isUri
import io.legado.app.utils.toastOnUi
import splitties.init.appCtx import splitties.init.appCtx
import java.io.File import java.io.File
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import kotlin.collections.set
val Book.isAudio: Boolean val Book.isAudio: Boolean
@ -223,6 +232,14 @@ fun Book.sync(oldBook: Book) {
canUpdate = curBook.canUpdate canUpdate = curBook.canUpdate
} }
fun Book.getBookSource(): BookSource? {
return appDb.bookSourceDao.getBookSource(origin)
}
fun Book.isLocalModified(): Boolean {
return isLocal && LocalBook.getLastModified(this).getOrDefault(0L) > latestChapterTime
}
fun Book.isSameNameAuthor(other: Any?): Boolean { fun Book.isSameNameAuthor(other: Any?): Boolean {
if (other is BaseBook) { if (other is BaseBook) {
return name == other.name && author == other.author return name == other.name && author == other.author

View File

@ -11,6 +11,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.book.ContentProcessor import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.getBookSource
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.service.AudioPlayService import io.legado.app.service.AudioPlayService
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent

View File

@ -96,12 +96,11 @@ class WebService : BaseService() {
if (addressList.any()) { if (addressList.any()) {
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) }) notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
hostAddress = notificationList.first() hostAddress = notificationList.first()
startForegroundNotification()
} else { } else {
hostAddress = getString(R.string.network_connection_unavailable) hostAddress = getString(R.string.network_connection_unavailable)
notificationList.add(hostAddress) notificationList.add(hostAddress)
startForegroundNotification()
} }
startForegroundNotification()
postEvent(EventBus.WEB_SERVICE, hostAddress) postEvent(EventBus.WEB_SERVICE, hostAddress)
} }
} }
@ -184,6 +183,7 @@ class WebService : BaseService() {
*/ */
override fun startForegroundNotification() { override fun startForegroundNotification() {
val builder = NotificationCompat.Builder(this, AppConst.channelIdWeb) val builder = NotificationCompat.Builder(this, AppConst.channelIdWeb)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setSmallIcon(R.drawable.ic_web_service_noti) .setSmallIcon(R.drawable.ic_web_service_noti)
.setOngoing(true) .setOngoing(true)
.setContentTitle(getString(R.string.web_service)) .setContentTitle(getString(R.string.web_service))
@ -196,7 +196,6 @@ class WebService : BaseService() {
getString(R.string.cancel), getString(R.string.cancel),
servicePendingIntent<WebService>(IntentAction.stop) servicePendingIntent<WebService>(IntentAction.stop)
) )
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
val notification = builder.build() val notification = builder.build()
startForeground(NotificationId.WebService, notification) startForeground(NotificationId.WebService, notification)
} }

View File

@ -11,6 +11,7 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.book.getBookSource
import io.legado.app.help.book.removeType import io.legado.app.help.book.removeType
import io.legado.app.model.AudioPlay import io.legado.app.model.AudioPlay
import io.legado.app.model.AudioPlay.durChapter import io.legado.app.model.AudioPlay.durChapter

View File

@ -1304,7 +1304,7 @@ class ReadBookActivity : BaseReadBookActivity(),
when (dialogId) { when (dialogId) {
TEXT_COLOR -> { TEXT_COLOR -> {
setCurTextColor(color) setCurTextColor(color)
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 9, 11)) postEvent(EventBus.UP_CONFIG, arrayListOf(2, 6, 9, 11))
} }
BG_COLOR -> { BG_COLOR -> {
@ -1500,9 +1500,9 @@ class ReadBookActivity : BaseReadBookActivity(),
5 -> if (isInitFinish) ReadBook.loadContent(resetPageOffset = false) 5 -> if (isInitFinish) ReadBook.loadContent(resetPageOffset = false)
6 -> readView.upContent(resetPageOffset = false) 6 -> readView.upContent(resetPageOffset = false)
8 -> ChapterProvider.upStyle() 8 -> ChapterProvider.upStyle()
9 -> binding.readView.invalidateTextPage() 9 -> readView.invalidateTextPage()
10 -> ChapterProvider.upLayout() 10 -> ChapterProvider.upLayout()
11 -> binding.readView.submitRenderTask() 11 -> readView.submitRenderTask()
} }
} }
} }
@ -1543,10 +1543,10 @@ class ReadBookActivity : BaseReadBookActivity(),
viewModel.searchResultList = it viewModel.searchResultList = it
} }
observeEvent<Boolean>(EventBus.UPDATE_READ_ACTION_BAR) { observeEvent<Boolean>(EventBus.UPDATE_READ_ACTION_BAR) {
binding.readMenu.reset() readMenu.reset()
} }
observeEvent<Boolean>(EventBus.UP_SEEK_BAR) { observeEvent<Boolean>(EventBus.UP_SEEK_BAR) {
binding.readMenu.upSeekBar() readMenu.upSeekBar()
} }
} }

View File

@ -20,6 +20,7 @@ import io.legado.app.help.AppWebDav
import io.legado.app.help.book.BookHelp import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.ContentProcessor import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocal
import io.legado.app.help.book.isLocalModified
import io.legado.app.help.book.removeType import io.legado.app.help.book.removeType
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine

View File

@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.book.BookContent import io.legado.app.help.book.BookContent
import io.legado.app.help.book.BookHelp import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.getBookSource
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig import io.legado.app.help.config.ReadBookConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine

View File

@ -194,10 +194,10 @@ object NetworkUtils {
enumeration = NetworkInterface.getNetworkInterfaces() enumeration = NetworkInterface.getNetworkInterfaces()
} catch (e: SocketException) { } catch (e: SocketException) {
e.printOnDebug() e.printOnDebug()
return mutableListOf() return emptyList()
} }
var fallbackAddress: MutableList<InetAddress> = mutableListOf() val addressList = mutableListOf<InetAddress>()
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
val nif = enumeration.nextElement() val nif = enumeration.nextElement()
@ -205,13 +205,11 @@ object NetworkUtils {
while (addresses.hasMoreElements()) { while (addresses.hasMoreElements()) {
val address = addresses.nextElement() val address = addresses.nextElement()
if (!address.isLoopbackAddress && isIPv4Address(address.hostAddress)) { if (!address.isLoopbackAddress && isIPv4Address(address.hostAddress)) {
if (nif.name?.startsWith("wlan") == true) { addressList.add(address)
fallbackAddress.add(address)
}
} }
} }
} }
return fallbackAddress return addressList
} }
/** /**

View File

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