mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-25 00:01:49 +01:00
add webview
This commit is contained in:
parent
6ddb5db57b
commit
75786a91b0
1
scripts/resources/Tachidesk Webview Launcher.bat
Normal file
1
scripts/resources/Tachidesk Webview Launcher.bat
Normal file
@ -0,0 +1 @@
|
||||
jre\bin\java -Dir.armor.tachidesk.openInWebview=true -jar Tachidesk.jar
|
@ -29,6 +29,7 @@ Copy-Item $jar.FullName "$release_name/Tachidesk.jar"
|
||||
Copy-Item "resources/Tachidesk Launcher-win32.exe" $release_name
|
||||
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
||||
Copy-Item "resources/Tachidesk Debug Launcher.bat" $release_name
|
||||
Copy-Item "resources/Tachidesk Webview Launcher.bat" $release_name
|
||||
|
||||
$zip_name="$release_name.zip"
|
||||
Compress-Archive -CompressionLevel Optimal -DestinationPath $zip_name -Path $release_name -Force -ErrorAction SilentlyContinue
|
||||
|
@ -32,6 +32,7 @@ cp $jar $release_name/Tachidesk.jar
|
||||
cp "resources/Tachidesk Launcher-win32.exe" "$release_name/Tachidesk Launcher.exe"
|
||||
cp "resources/Tachidesk Launcher.bat" $release_name
|
||||
cp "resources/Tachidesk Debug Launcher.bat" $release_name
|
||||
cp "resources/Tachidesk Webview Launcher.bat" $release_name
|
||||
|
||||
zip_name=$release_name.zip
|
||||
zip -9 -r $zip_name $release_name
|
||||
|
@ -29,6 +29,7 @@ Copy-Item $jar.FullName "$release_name/Tachidesk.jar"
|
||||
Copy-Item "resources/Tachidesk Launcher-win64.exe" $release_name
|
||||
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
||||
Copy-Item "resources/Tachidesk Debug Launcher.bat" $release_name
|
||||
Copy-Item "resources/Tachidesk Webview Launcher.bat" $release_name
|
||||
|
||||
$zip_name="$release_name.zip"
|
||||
Compress-Archive -CompressionLevel Optimal -DestinationPath $zip_name -Path $release_name -Force -ErrorAction SilentlyContinue
|
||||
|
@ -32,6 +32,7 @@ cp $jar $release_name/Tachidesk.jar
|
||||
cp "resources/Tachidesk Launcher-win64.exe" "$release_name/Tachidesk Launcher.exe"
|
||||
cp "resources/Tachidesk Launcher.bat" $release_name
|
||||
cp "resources/Tachidesk Debug Launcher.bat" $release_name
|
||||
cp "resources/Tachidesk Webview Launcher.bat" $release_name
|
||||
|
||||
zip_name=$release_name.zip
|
||||
zip -9 -r $zip_name $release_name
|
||||
|
@ -65,6 +65,9 @@ dependencies {
|
||||
implementation(project(":AndroidCompat"))
|
||||
implementation(project(":AndroidCompat:Config"))
|
||||
|
||||
// webview
|
||||
implementation(files("lib/WebView.jar"))
|
||||
|
||||
// uncomment to test extensions directly
|
||||
// implementation(fileTree("lib/"))
|
||||
|
||||
|
1
server/lib/README.md
Normal file
1
server/lib/README.md
Normal file
@ -0,0 +1 @@
|
||||
WebView.jar is taken from https://github.com/shannah/webviewjar
|
BIN
server/lib/WebView.jar
Normal file
BIN
server/lib/WebView.jar
Normal file
Binary file not shown.
@ -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.openInBrowser
|
||||
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
@ -87,9 +87,13 @@ 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)
|
||||
|
@ -10,7 +10,7 @@ package ir.armor.tachidesk.server
|
||||
import eu.kanade.tachiyomi.App
|
||||
import ir.armor.tachidesk.model.database.databaseUp
|
||||
import ir.armor.tachidesk.server.util.AppMutex.handleAppMutex
|
||||
import ir.armor.tachidesk.server.util.systemTray
|
||||
import ir.armor.tachidesk.server.util.SystemTray.systemTray
|
||||
import mu.KotlinLogging
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.bind
|
||||
|
@ -13,6 +13,7 @@ import ir.armor.tachidesk.server.serverConfig
|
||||
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.Clear
|
||||
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.OtherApplicationRunning
|
||||
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.TachideskInstanceRunning
|
||||
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||
import mu.KotlinLogging
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request.Builder
|
||||
|
@ -0,0 +1,49 @@
|
||||
package ir.armor.tachidesk.server.util
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 dorkbox.util.Desktop
|
||||
import ir.armor.tachidesk.server.serverConfig
|
||||
|
||||
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 fun createWebView() = WebView()
|
||||
.size(800, 600)
|
||||
.title("Tachidesk")
|
||||
.resizable(true)
|
||||
.url(appBaseUrl)
|
||||
.also {
|
||||
WebView::class.java.getDeclaredField("fullscreen").setBoolean(it, true)
|
||||
}.also {
|
||||
webViewInstances.add(it)
|
||||
}
|
||||
|
||||
fun openInBrowser() {
|
||||
|
||||
val openInWebView = System.getProperty("ir.armor.tachidesk.openInWebview")?.toBoolean()
|
||||
|
||||
if (openInWebView == true) {
|
||||
try {
|
||||
createWebView().show()
|
||||
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Desktop.browseURL(appBaseUrl)
|
||||
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,21 +10,13 @@ package ir.armor.tachidesk.server.util
|
||||
import dorkbox.systemTray.MenuItem
|
||||
import dorkbox.systemTray.SystemTray
|
||||
import dorkbox.util.CacheUtil
|
||||
import dorkbox.util.Desktop
|
||||
import ir.armor.tachidesk.server.BuildConfig
|
||||
import ir.armor.tachidesk.server.ServerConfig
|
||||
import ir.armor.tachidesk.server.serverConfig
|
||||
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||
import ir.armor.tachidesk.server.util.ExitCode.Success
|
||||
|
||||
fun openInBrowser() {
|
||||
val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
|
||||
try {
|
||||
Desktop.browseURL("http://$appIP:${serverConfig.port}")
|
||||
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
object SystemTray {
|
||||
fun systemTray(): SystemTray? {
|
||||
try {
|
||||
// ref: https://github.com/dorkbox/SystemTray/blob/master/test/dorkbox/TestTray.java
|
||||
@ -63,3 +55,4 @@ fun systemTray(): SystemTray? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user