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