chore: detection installation type

This commit is contained in:
hstyi
2025-06-26 15:32:23 +08:00
committed by hstyi
parent 7ba8e177b1
commit e25bd485ac
3 changed files with 61 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
package app.termora
enum class AppLayout {
/**
* Windows
*/
Zip,
Exe,
/**
* macOS
*/
App,
/**
* Linux
*/
TarGz,
AppImage,
Deb,
}

View File

@@ -121,6 +121,30 @@ object Application {
return version
}
fun getLayout(): AppLayout {
if (SystemInfo.isMacOS) return AppLayout.App
val layout = System.getProperty("jpackage.app-layout")
if (SystemInfo.isLinux) {
if ("deb" == layout) {
return AppLayout.Deb
} else if ("tar.gz" == layout) {
return AppLayout.TarGz
}
}
if (SystemInfo.isWindows) {
if ("exe" == layout) {
return AppLayout.Exe
} else if ("zip" == layout) {
return AppLayout.Zip
}
}
return if (SystemInfo.isWindows) AppLayout.Exe else AppLayout.AppImage
}
/**
* 未知版本通常是开发版本
*/