This commit is contained in:
2026-03-20 17:55:27 +09:00
parent 7ce24cc631
commit d804c7061b
8 changed files with 220 additions and 11 deletions
+40 -2
View File
@@ -14,9 +14,12 @@ import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.window.Tray
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberTrayState
import androidx.compose.ui.window.rememberWindowState
import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
@@ -75,14 +78,47 @@ fun getLlamaBinPath(): String {
}
}
fun main() = application {
SystemSleepPreventer.start()
val trayState = rememberTrayState()
var isWindowOpen by remember { mutableStateOf(true) } // 창의 표시 상태 관리
LaunchedEffect(Unit) {
SystemSleepPreventer.start()
AutoTradingManager.startBackgroundScheduler()
}
LaunchedEffect(AutoTradingManager.shouldShowFullWindow) {
if (AutoTradingManager.shouldShowFullWindow) {
isWindowOpen = true
// 신호를 처리했으므로 다시 초기화 (트레이에서 수동으로 닫았을 때 다시 뜰 수 있게 함)
AutoTradingManager.shouldShowFullWindow = false
}
}
// 트레이 아이콘 설정
Tray(
state = trayState,
icon = painterResource("neko.png"), // resources 폴더에 아이콘 파일 필요
tooltip = "KIS AI 자동매매",
onAction = { isWindowOpen = true }, // 트레이 아이콘 더블클릭 시 창 열기
menu = {
Item("앱 열기", onClick = { isWindowOpen = true })
Separator()
Item("종료", onClick = {
// 종료 전 리소스 정리 호출
AutoTradingManager.stopDiscovery()
exitApplication()
})
}
)
// 앱 실행 시 필요한 바이너리 경로 (실행 파일 위치)
val binPath = getLlamaBinPath()
val windowState = rememberWindowState(
placement = WindowPlacement.Floating
)
Window(onCloseRequest = ::exitApplication, title = "KIS AI 자동매매", state = windowState) {
if (isWindowOpen) {
Window(onCloseRequest = { isWindowOpen = false }, title = "KIS AI 자동매매", state = windowState) {
var currentScreen by remember { mutableStateOf(AppScreen.Settings) }
var isLoaded by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
@@ -142,6 +178,7 @@ fun main() = application {
AutoTradingManager.onMarketClosed = {
println("프로그램 초기화 실행됨")
currentScreen = AppScreen.Settings
isWindowOpen = false
}
SettingsScreen(
onAuthSuccess = {
@@ -178,4 +215,5 @@ fun main() = application {
}
}
}
}
}