mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-03-09 10:35:51 +01:00
webview starts!
This commit is contained in:
parent
75786a91b0
commit
a458a696db
@ -78,6 +78,7 @@ dependencies {
|
||||
val MainClass = "ir.armor.tachidesk.MainKt"
|
||||
application {
|
||||
mainClass.set(MainClass)
|
||||
applicationDefaultJvmArgs = listOf("-Dir.armor.tachidesk.openInWebview=true")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -33,7 +33,7 @@ import ir.armor.tachidesk.impl.extension.Extension.uninstallExtension
|
||||
import ir.armor.tachidesk.impl.extension.Extension.updateExtension
|
||||
import ir.armor.tachidesk.impl.extension.ExtensionsList.getExtensionList
|
||||
import ir.armor.tachidesk.server.impl_internal.About.getAbout
|
||||
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||
import ir.armor.tachidesk.server.util.Browser
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
@ -78,6 +78,13 @@ object JavalinSetup {
|
||||
hasWebUiBundled = false
|
||||
}
|
||||
config.enableCorsForAllOrigins()
|
||||
}.events { event ->
|
||||
event.serverStarted {
|
||||
println("started")
|
||||
if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {
|
||||
Browser.openInBrowser()
|
||||
}
|
||||
}
|
||||
}.start(serverConfig.ip, serverConfig.port)
|
||||
|
||||
// when JVM is prompted to shutdown, stop javalin gracefully
|
||||
@ -87,14 +94,6 @@ object JavalinSetup {
|
||||
}
|
||||
)
|
||||
|
||||
app.events { event ->
|
||||
event.serverStarted {
|
||||
if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {
|
||||
openInBrowser()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.exception(NullPointerException::class.java) { e, ctx ->
|
||||
logger.error("NullPointerException while handling the request", e)
|
||||
ctx.status(404)
|
||||
|
@ -7,7 +7,7 @@ package ir.armor.tachidesk.server.util
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import ca.weblite.webview.WebView
|
||||
import ca.weblite.webview.WebViewCLIClient
|
||||
import dorkbox.util.Desktop
|
||||
import ir.armor.tachidesk.server.serverConfig
|
||||
|
||||
@ -15,16 +15,16 @@ object Browser {
|
||||
private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
|
||||
private val appBaseUrl = "http://$appIP:${serverConfig.port}"
|
||||
|
||||
private val webViewInstances = mutableListOf<WebView>()
|
||||
private val webViewInstances = mutableListOf<Any>()
|
||||
|
||||
private fun createWebView() = WebView()
|
||||
private fun createWebView() =
|
||||
WebViewCLIClient.Builder()
|
||||
.size(800, 600)
|
||||
.title("Tachidesk")
|
||||
.resizable(true)
|
||||
.url(appBaseUrl)
|
||||
.build()
|
||||
.also {
|
||||
WebView::class.java.getDeclaredField("fullscreen").setBoolean(it, true)
|
||||
}.also {
|
||||
webViewInstances.add(it)
|
||||
}
|
||||
|
||||
@ -34,7 +34,9 @@ object Browser {
|
||||
|
||||
if (openInWebView == true) {
|
||||
try {
|
||||
createWebView().show()
|
||||
Thread {
|
||||
createWebView()
|
||||
}.start()
|
||||
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user