|
|
@@ -21,20 +21,30 @@ import (
|
|
|
// @in header
|
|
|
// @name x-token
|
|
|
// @BasePath /
|
|
|
-func main() {
|
|
|
- global.GVA_VP = core.Viper() // 初始化Viper
|
|
|
+
|
|
|
+// InitBackend initializes the Go backend (Viper, Zap, GORM, Gin) and starts the
|
|
|
+// HTTP server in a background goroutine. It does not block. Call this before
|
|
|
+// running the Wails application.
|
|
|
+func InitBackend() {
|
|
|
+ global.GVA_VP = core.Viper()
|
|
|
initialize.OtherInit()
|
|
|
- global.GVA_LOG = core.Zap() // 初始化zap日志库
|
|
|
+ global.GVA_LOG = core.Zap()
|
|
|
zap.ReplaceGlobals(global.GVA_LOG)
|
|
|
- global.GVA_DB = initialize.Gorm() // gorm连接数据库
|
|
|
+ global.GVA_DB = initialize.Gorm()
|
|
|
initialize.Timer()
|
|
|
initialize.DBList()
|
|
|
if global.GVA_DB != nil {
|
|
|
- initialize.RegisterTables() // 初始化表
|
|
|
- // 程序结束前关闭数据库链接
|
|
|
+ initialize.RegisterTables()
|
|
|
db, _ := global.GVA_DB.DB()
|
|
|
defer db.Close()
|
|
|
}
|
|
|
initialize.InitUHFDevices()
|
|
|
- core.RunWindowsServer()
|
|
|
+ go core.RunWindowsServer()
|
|
|
+}
|
|
|
+
|
|
|
+// main is retained for standalone (non-Wails) usage.
|
|
|
+func main() {
|
|
|
+ InitBackend()
|
|
|
+ // Block forever when running standalone.
|
|
|
+ select {}
|
|
|
}
|