78 lines
2.4 KiB
Go
78 lines
2.4 KiB
Go
package main
|
||
|
||
import (
|
||
"embed"
|
||
"log"
|
||
"path/filepath"
|
||
|
||
"github.com/ituoke/ituoke/internal/agent"
|
||
"github.com/ituoke/ituoke/internal/applog"
|
||
"github.com/ituoke/ituoke/internal/device"
|
||
"github.com/ituoke/ituoke/internal/mcpclient"
|
||
"github.com/ituoke/ituoke/internal/runtimeassets"
|
||
"github.com/wailsapp/wails/v3/pkg/application"
|
||
)
|
||
|
||
//go:embed all:frontend/dist
|
||
var assets embed.FS
|
||
|
||
func main() {
|
||
// ============================================================
|
||
// [入口] 应用启动:注册服务 → 创建窗口 → 进入事件循环
|
||
// 改窗口标题/尺寸/macOS 外观:看下方 Window.NewWithOptions
|
||
// 改后端能力:看 Services 列表(DeviceService / AgentService)
|
||
// ============================================================
|
||
|
||
deviceSvc := device.NewService()
|
||
mcpSvc := mcpclient.NewService()
|
||
agentSvc := agent.NewServiceWithMCP(mcpSvc, func(delta agent.ChatDelta) {
|
||
if app := application.Get(); app != nil {
|
||
app.Event.Emit("agent:chat-delta", delta)
|
||
}
|
||
})
|
||
var browserPath string
|
||
if browser := runtimeassets.Find(filepath.Join("webview2", "msedgewebview2.exe")); browser != "" {
|
||
browserPath = filepath.Dir(browser)
|
||
if err := runtimeassets.PrepareWebview(browserPath); err != nil {
|
||
// Program Files installations already receive these grants from NSIS.
|
||
log.Printf("%v", err)
|
||
}
|
||
}
|
||
|
||
app := application.New(application.Options{
|
||
Name: "iTuoke",
|
||
Description: "Enterprise phone control — ADB capture + AI agent",
|
||
Services: []application.Service{
|
||
// [绑定] 前端可通过 Wails bindings 调用这些 Go 方法
|
||
application.NewService(deviceSvc),
|
||
application.NewService(agentSvc),
|
||
application.NewService(mcpSvc),
|
||
application.NewService(applog.NewService()),
|
||
},
|
||
Assets: application.AssetOptions{
|
||
Handler: application.AssetFileServerFS(assets),
|
||
},
|
||
Mac: application.MacOptions{
|
||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||
},
|
||
Windows: application.WindowsOptions{WebviewBrowserPath: browserPath},
|
||
})
|
||
|
||
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
||
Title: "iTuoke",
|
||
Width: 1440,
|
||
Height: 900,
|
||
Mac: application.MacWindow{
|
||
InvisibleTitleBarHeight: 52,
|
||
Backdrop: application.MacBackdropTranslucent,
|
||
TitleBar: application.MacTitleBarHiddenInset,
|
||
},
|
||
BackgroundColour: application.NewRGB(18, 18, 20),
|
||
URL: "/",
|
||
})
|
||
|
||
if err := app.Run(); err != nil {
|
||
log.Fatal(err)
|
||
}
|
||
}
|