structure config
This commit is contained in:
1 parent
71408e5328
commit
4cf6073fbe
3 files changed
+13
-6
No files matched your search
@@ -28,7 +28,7 @@ fun main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val config = remember { loadConfig() }
|
val config = remember { loadConfig() }
|
||||||
val client = remember { AnyTypeApi(apiKey = config.apiKey, spaceId = config.spaceId) }
|
val client = remember { AnyTypeApi(baseUrl = config.connection.baseUrl, apiKey = config.connection.apiKey, spaceId = config.spaceId) }
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
HotkeyManager.start(onHotkey = { isVisible = !isVisible })
|
HotkeyManager.start(onHotkey = { isVisible = !isVisible })
|
||||||
|
|||||||
+11
-5
@@ -5,14 +5,20 @@ import kotlinx.serialization.Serializable
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AppConfig(
|
data class Connection(
|
||||||
val apiKey: String = "",
|
val apiKey: String = "",
|
||||||
|
val baseUrl: String = "http://localhost:31009",
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Configuration(
|
||||||
|
val connection: Connection = Connection(),
|
||||||
val spaceId: String = "",
|
val spaceId: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
fun loadConfig(): AppConfig {
|
fun loadConfig(): Configuration {
|
||||||
val yaml = Yaml.default
|
val yaml = Yaml.default
|
||||||
val serializer = AppConfig.serializer()
|
val serializer = Configuration.serializer()
|
||||||
|
|
||||||
// External files take precedence (production use)
|
// External files take precedence (production use)
|
||||||
val externalLocations = listOf(
|
val externalLocations = listOf(
|
||||||
@@ -24,9 +30,9 @@ fun loadConfig(): AppConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: classpath resource (development)
|
// Fallback: classpath resource (development)
|
||||||
AppConfig::class.java.getResourceAsStream("/anytask.yaml")?.let {
|
Configuration::class.java.getResourceAsStream("/anytask.yaml")?.let {
|
||||||
return yaml.decodeFromString(serializer, it.bufferedReader().readText())
|
return yaml.decodeFromString(serializer, it.bufferedReader().readText())
|
||||||
}
|
}
|
||||||
|
|
||||||
return AppConfig()
|
return Configuration()
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
|
connection:
|
||||||
apiKey: 2tkMSzFegWwzsQ+n9SpGwVjychEkCESWjV1/ftytXG4=
|
apiKey: 2tkMSzFegWwzsQ+n9SpGwVjychEkCESWjV1/ftytXG4=
|
||||||
spaceId: bafyreiafzvfsrurvx4gvr2wwysgp5uugujzmbdg5hxnjlahfmx3ww6kxfy.172mmtcppmjtt
|
spaceId: bafyreiafzvfsrurvx4gvr2wwysgp5uugujzmbdg5hxnjlahfmx3ww6kxfy.172mmtcppmjtt
|
||||||