mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-25 08:11:50 +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-win32.exe" $release_name
|
||||||
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
||||||
Copy-Item "resources/Tachidesk Debug 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"
|
$zip_name="$release_name.zip"
|
||||||
Compress-Archive -CompressionLevel Optimal -DestinationPath $zip_name -Path $release_name -Force -ErrorAction SilentlyContinue
|
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-win32.exe" "$release_name/Tachidesk Launcher.exe"
|
||||||
cp "resources/Tachidesk Launcher.bat" $release_name
|
cp "resources/Tachidesk Launcher.bat" $release_name
|
||||||
cp "resources/Tachidesk Debug 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_name=$release_name.zip
|
||||||
zip -9 -r $zip_name $release_name
|
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-win64.exe" $release_name
|
||||||
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
Copy-Item "resources/Tachidesk Launcher.bat" $release_name
|
||||||
Copy-Item "resources/Tachidesk Debug 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"
|
$zip_name="$release_name.zip"
|
||||||
Compress-Archive -CompressionLevel Optimal -DestinationPath $zip_name -Path $release_name -Force -ErrorAction SilentlyContinue
|
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-win64.exe" "$release_name/Tachidesk Launcher.exe"
|
||||||
cp "resources/Tachidesk Launcher.bat" $release_name
|
cp "resources/Tachidesk Launcher.bat" $release_name
|
||||||
cp "resources/Tachidesk Debug 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_name=$release_name.zip
|
||||||
zip -9 -r $zip_name $release_name
|
zip -9 -r $zip_name $release_name
|
||||||
|
@ -65,6 +65,9 @@ dependencies {
|
|||||||
implementation(project(":AndroidCompat"))
|
implementation(project(":AndroidCompat"))
|
||||||
implementation(project(":AndroidCompat:Config"))
|
implementation(project(":AndroidCompat:Config"))
|
||||||
|
|
||||||
|
// webview
|
||||||
|
implementation(files("lib/WebView.jar"))
|
||||||
|
|
||||||
// uncomment to test extensions directly
|
// uncomment to test extensions directly
|
||||||
// implementation(fileTree("lib/"))
|
// 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.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.openInBrowser
|
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
@ -87,8 +87,12 @@ object JavalinSetup {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {
|
app.events { event ->
|
||||||
openInBrowser()
|
event.serverStarted {
|
||||||
|
if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {
|
||||||
|
openInBrowser()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.exception(NullPointerException::class.java) { e, ctx ->
|
app.exception(NullPointerException::class.java) { e, ctx ->
|
||||||
|
@ -10,7 +10,7 @@ package ir.armor.tachidesk.server
|
|||||||
import eu.kanade.tachiyomi.App
|
import eu.kanade.tachiyomi.App
|
||||||
import ir.armor.tachidesk.model.database.databaseUp
|
import ir.armor.tachidesk.model.database.databaseUp
|
||||||
import ir.armor.tachidesk.server.util.AppMutex.handleAppMutex
|
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 mu.KotlinLogging
|
||||||
import org.kodein.di.DI
|
import org.kodein.di.DI
|
||||||
import org.kodein.di.bind
|
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.Clear
|
||||||
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.OtherApplicationRunning
|
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.OtherApplicationRunning
|
||||||
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.TachideskInstanceRunning
|
import ir.armor.tachidesk.server.util.AppMutex.AppMutexStat.TachideskInstanceRunning
|
||||||
|
import ir.armor.tachidesk.server.util.Browser.openInBrowser
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request.Builder
|
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,56 +10,49 @@ package ir.armor.tachidesk.server.util
|
|||||||
import dorkbox.systemTray.MenuItem
|
import dorkbox.systemTray.MenuItem
|
||||||
import dorkbox.systemTray.SystemTray
|
import dorkbox.systemTray.SystemTray
|
||||||
import dorkbox.util.CacheUtil
|
import dorkbox.util.CacheUtil
|
||||||
import dorkbox.util.Desktop
|
|
||||||
import ir.armor.tachidesk.server.BuildConfig
|
import ir.armor.tachidesk.server.BuildConfig
|
||||||
import ir.armor.tachidesk.server.ServerConfig
|
import ir.armor.tachidesk.server.ServerConfig
|
||||||
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
|
import ir.armor.tachidesk.server.util.ExitCode.Success
|
||||||
|
|
||||||
fun openInBrowser() {
|
object SystemTray {
|
||||||
val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
|
fun systemTray(): SystemTray? {
|
||||||
try {
|
try {
|
||||||
Desktop.browseURL("http://$appIP:${serverConfig.port}")
|
// ref: https://github.com/dorkbox/SystemTray/blob/master/test/dorkbox/TestTray.java
|
||||||
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
|
SystemTray.DEBUG = serverConfig.debugLogsEnabled
|
||||||
e.printStackTrace()
|
|
||||||
}
|
CacheUtil.clear(BuildConfig.name)
|
||||||
}
|
|
||||||
|
val systemTray = SystemTray.get(BuildConfig.name) ?: return null
|
||||||
fun systemTray(): SystemTray? {
|
val mainMenu = systemTray.menu
|
||||||
try {
|
|
||||||
// ref: https://github.com/dorkbox/SystemTray/blob/master/test/dorkbox/TestTray.java
|
mainMenu.add(
|
||||||
SystemTray.DEBUG = serverConfig.debugLogsEnabled
|
MenuItem(
|
||||||
|
"Open Tachidesk"
|
||||||
CacheUtil.clear(BuildConfig.name)
|
) {
|
||||||
|
openInBrowser()
|
||||||
val systemTray = SystemTray.get(BuildConfig.name) ?: return null
|
}
|
||||||
val mainMenu = systemTray.menu
|
)
|
||||||
|
|
||||||
mainMenu.add(
|
val icon = ServerConfig::class.java.getResource("/icon/faviconlogo.png")
|
||||||
MenuItem(
|
|
||||||
"Open Tachidesk"
|
// systemTray.setTooltip("Tachidesk")
|
||||||
) {
|
systemTray.setImage(icon)
|
||||||
openInBrowser()
|
// systemTray.status = "No Mail"
|
||||||
}
|
|
||||||
)
|
mainMenu.add(
|
||||||
|
MenuItem("Quit") {
|
||||||
val icon = ServerConfig::class.java.getResource("/icon/faviconlogo.png")
|
shutdownApp(Success)
|
||||||
|
}
|
||||||
// systemTray.setTooltip("Tachidesk")
|
)
|
||||||
systemTray.setImage(icon)
|
|
||||||
// systemTray.status = "No Mail"
|
systemTray.installShutdownHook()
|
||||||
|
|
||||||
mainMenu.add(
|
return systemTray
|
||||||
MenuItem("Quit") {
|
} catch (e: Exception) {
|
||||||
shutdownApp(Success)
|
e.printStackTrace()
|
||||||
}
|
return null
|
||||||
)
|
}
|
||||||
|
|
||||||
systemTray.installShutdownHook()
|
|
||||||
|
|
||||||
return systemTray
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user