2026-01-10 18:16:50 +09:00
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
|
|
import androidx.compose.material.*
|
|
|
|
|
import androidx.compose.runtime.*
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.window.Window
|
|
|
|
|
import androidx.compose.ui.window.application
|
|
|
|
|
import org.jetbrains.exposed.sql.*
|
|
|
|
|
import org.jetbrains.exposed.sql.transactions.transaction
|
|
|
|
|
import model.AppConfig
|
2026-01-13 16:04:25 +09:00
|
|
|
import model.KisSession
|
2026-01-10 18:16:50 +09:00
|
|
|
import network.LlamaServerManager
|
2026-01-21 18:59:55 +09:00
|
|
|
import network.NewsService
|
2026-01-10 18:16:50 +09:00
|
|
|
import org.jetbrains.exposed.sql.selectAll
|
|
|
|
|
import ui.DashboardScreen
|
|
|
|
|
import ui.SettingsScreen
|
|
|
|
|
|
|
|
|
|
// 화면 상태 정의
|
|
|
|
|
enum class AppScreen { Settings, Dashboard }
|
|
|
|
|
|
|
|
|
|
fun main() = application {
|
2026-01-21 18:30:03 +09:00
|
|
|
|
2026-01-13 16:04:25 +09:00
|
|
|
// 앱 실행 시 필요한 바이너리 경로 (실행 파일 위치)
|
2026-01-10 18:16:50 +09:00
|
|
|
val binPath = "./src/main/resources/bin/llama-server"
|
|
|
|
|
|
|
|
|
|
Window(onCloseRequest = ::exitApplication, title = "KIS AI 자동매매") {
|
|
|
|
|
var currentScreen by remember { mutableStateOf(AppScreen.Settings) }
|
2026-01-13 16:04:25 +09:00
|
|
|
var isLoaded by remember { mutableStateOf(false) }
|
|
|
|
|
val scope = rememberCoroutineScope()
|
2026-01-10 18:16:50 +09:00
|
|
|
|
2026-01-13 16:04:25 +09:00
|
|
|
// 1. 앱 시작 시 DB에서 마지막 설정 로드 (KisSession에 주입)
|
2026-01-10 18:16:50 +09:00
|
|
|
LaunchedEffect(Unit) {
|
|
|
|
|
DatabaseFactory.init()
|
2026-01-13 16:04:25 +09:00
|
|
|
transaction {
|
2026-01-10 18:16:50 +09:00
|
|
|
ConfigTable.selectAll().lastOrNull()?.let {
|
2026-01-13 16:04:25 +09:00
|
|
|
KisSession.config = AppConfig(
|
|
|
|
|
realAppKey = it[ConfigTable.realAppKey],
|
|
|
|
|
realSecretKey = it[ConfigTable.realSecretKey],
|
|
|
|
|
realAccountNo = it[ConfigTable.realAccountNo],
|
|
|
|
|
vtsAppKey = it[ConfigTable.vtsAppKey],
|
|
|
|
|
vtsSecretKey = it[ConfigTable.vtsSecretKey],
|
|
|
|
|
vtsAccountNo = it[ConfigTable.vtsAccountNo],
|
2026-01-10 18:16:50 +09:00
|
|
|
isSimulation = it[ConfigTable.isSimulation],
|
2026-01-14 15:42:26 +09:00
|
|
|
htsId = it[ConfigTable.htsId],
|
2026-01-21 18:30:03 +09:00
|
|
|
modelPath = it[ConfigTable.modelPath],
|
|
|
|
|
embedModelPath = it[ConfigTable.embedModelPath]
|
2026-01-10 18:16:50 +09:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-19 17:09:37 +09:00
|
|
|
|
2026-01-13 16:04:25 +09:00
|
|
|
isLoaded = true
|
2026-01-10 18:16:50 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-13 16:04:25 +09:00
|
|
|
if (!isLoaded) {
|
|
|
|
|
// 로딩 중 표시
|
|
|
|
|
CircularProgressIndicator()
|
2026-01-10 18:16:50 +09:00
|
|
|
} else {
|
|
|
|
|
when (currentScreen) {
|
|
|
|
|
AppScreen.Settings -> {
|
|
|
|
|
SettingsScreen(
|
2026-01-13 16:04:25 +09:00
|
|
|
onAuthSuccess = {
|
|
|
|
|
// 2. 설정 및 인증 완료 시점의 처리
|
|
|
|
|
val config = KisSession.config
|
|
|
|
|
|
|
|
|
|
// LLM 서버 시작 (설정된 모델 경로 사용)
|
|
|
|
|
if (config.modelPath.isNotEmpty()) {
|
2026-01-21 18:30:03 +09:00
|
|
|
LlamaServerManager.startServer(binPath, config.modelPath,port = 8080)
|
|
|
|
|
}
|
|
|
|
|
if (config.embedModelPath.isNotEmpty()) {
|
|
|
|
|
LlamaServerManager.startServer(binPath, config.embedModelPath, port = 8081)
|
2026-01-13 16:04:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 대시보드로 화면 전환
|
2026-01-10 18:16:50 +09:00
|
|
|
currentScreen = AppScreen.Dashboard
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
AppScreen.Dashboard -> {
|
2026-01-13 16:04:25 +09:00
|
|
|
DashboardScreen()
|
2026-01-10 18:16:50 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|