diff --git a/src/main/kotlin/utils/OpenBrowser.kt b/src/main/kotlin/utils/OpenBrowser.kt index 11bf117..1dd164f 100644 --- a/src/main/kotlin/utils/OpenBrowser.kt +++ b/src/main/kotlin/utils/OpenBrowser.kt @@ -8,19 +8,19 @@ import java.io.IOException import java.net.URI import java.util.* -fun openBrowser(uri: URI) { +private fun openBrowser(uri: URI) { val osName by lazy(LazyThreadSafetyMode.NONE) { System.getProperty("os.name").lowercase(Locale.getDefault()) } val desktop = Desktop.getDesktop() when { Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE) -> desktop.browse(uri) - "mac" in osName -> Runtime.getRuntime().exec("open $uri") + "mac" in osName -> Runtime.getRuntime().exec(arrayOf("open",uri.toString())) "nix" in osName || "nux" in osName -> { try { - Runtime.getRuntime().exec("xdg-open $uri") + Runtime.getRuntime().exec(arrayOf("xdg-open",uri.toString())) } catch (_: IOException) { // xdg-open 不存在 if (File("/run/current-system/sw/bin/xdg-open").exists()) { // nixos - Runtime.getRuntime().exec("/run/current-system/sw/bin/kde-open $uri") + Runtime.getRuntime().exec(arrayOf("/run/current-system/sw/bin/kde-open",uri.toString())) } else { val clipboard = Toolkit.getDefaultToolkit().systemClipboard val content = StringSelection(uri.toString())