mirror of
https://github.com/gotson/komga.git
synced 2025-12-06 08:32:25 +01:00
fix(komga-tray): open komga menu does not use custom port
Closes: #1468
This commit is contained in:
parent
bcafbd8150
commit
edc1223490
3 changed files with 28 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ import androidx.compose.ui.res.loadSvgPainter
|
|||
import androidx.compose.ui.window.Tray
|
||||
import androidx.compose.ui.window.application
|
||||
import org.gotson.komga.RB
|
||||
import org.gotson.komga.infrastructure.web.WebServerEffectiveSettings
|
||||
import org.gotson.komga.openExplorer
|
||||
import org.gotson.komga.openUrl
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
|
|
@ -20,15 +21,14 @@ import java.io.File
|
|||
@Profile("!test")
|
||||
@Component
|
||||
class TrayIconRunner(
|
||||
@Value("#{servletContext.contextPath}") servletContextPath: String,
|
||||
@Value("#{komgaProperties.configDir}") komgaConfigDir: String,
|
||||
@Value("\${logging.file.name}") logFileName: String,
|
||||
@Value("\${server.port}") serverPort: Int,
|
||||
serverSettings: WebServerEffectiveSettings,
|
||||
env: Environment,
|
||||
) : ApplicationRunner {
|
||||
val komgaUrl = "http://localhost:$serverPort$servletContextPath"
|
||||
val komgaConfigDir = File(komgaConfigDir)
|
||||
val logFile = File(logFileName)
|
||||
val komgaUrl by lazy { "http://localhost:${serverSettings.effectiveServerPort}${serverSettings.effectiveServletContextPath}" }
|
||||
val komgaConfigDir by lazy { File(komgaConfigDir) }
|
||||
val logFile by lazy { File(logFileName) }
|
||||
val iconFileName = if (env.activeProfiles.contains("mac")) "komga-gray-minimal.svg" else "komga-color.svg"
|
||||
|
||||
@Async
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package org.gotson.komga.infrastructure.web
|
||||
|
||||
import jakarta.servlet.ServletContext
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class WebServerEffectiveSettings(
|
||||
servletContext: ServletContext,
|
||||
) {
|
||||
var effectiveServerPort: Int? = null
|
||||
val effectiveServletContextPath: String = servletContext.contextPath
|
||||
|
||||
@EventListener
|
||||
fun onApplicationEvent(event: ServletWebServerInitializedEvent) {
|
||||
effectiveServerPort = event.webServer.port
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
package org.gotson.komga.interfaces.api.rest
|
||||
|
||||
import jakarta.servlet.ServletContext
|
||||
import jakarta.validation.Valid
|
||||
import org.gotson.komga.domain.model.ROLE_ADMIN
|
||||
import org.gotson.komga.infrastructure.configuration.KomgaSettingsProvider
|
||||
import org.gotson.komga.infrastructure.web.WebServerEffectiveSettings
|
||||
import org.gotson.komga.interfaces.api.rest.dto.SettingMultiSource
|
||||
import org.gotson.komga.interfaces.api.rest.dto.SettingsDto
|
||||
import org.gotson.komga.interfaces.api.rest.dto.SettingsUpdateDto
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDomain
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDto
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
|
|
@ -29,12 +28,8 @@ class SettingsController(
|
|||
private val komgaSettingsProvider: KomgaSettingsProvider,
|
||||
@Value("\${server.port:#{null}}") private val configServerPort: Int?,
|
||||
@Value("\${server.servlet.context-path:#{null}}") private val configServerContextPath: String?,
|
||||
serverProperties: ServerProperties,
|
||||
servletContext: ServletContext,
|
||||
private val serverSettings: WebServerEffectiveSettings,
|
||||
) {
|
||||
private val effectiveServerPort = serverProperties.port
|
||||
private val effectiveServerContextPath = servletContext.contextPath
|
||||
|
||||
@GetMapping
|
||||
fun getSettings(): SettingsDto =
|
||||
SettingsDto(
|
||||
|
|
@ -43,8 +38,8 @@ class SettingsController(
|
|||
komgaSettingsProvider.rememberMeDuration.inWholeDays,
|
||||
komgaSettingsProvider.thumbnailSize.toDto(),
|
||||
komgaSettingsProvider.taskPoolSize,
|
||||
SettingMultiSource(configServerPort, komgaSettingsProvider.serverPort, effectiveServerPort),
|
||||
SettingMultiSource(configServerContextPath, komgaSettingsProvider.serverContextPath, effectiveServerContextPath),
|
||||
SettingMultiSource(configServerPort, komgaSettingsProvider.serverPort, serverSettings.effectiveServerPort),
|
||||
SettingMultiSource(configServerContextPath, komgaSettingsProvider.serverContextPath, serverSettings.effectiveServletContextPath),
|
||||
)
|
||||
|
||||
@PatchMapping
|
||||
|
|
|
|||
Loading…
Reference in a new issue