| package main |
|
|
| import ( |
| "log" |
|
|
| "fyne.io/fyne/v2" |
| "fyne.io/fyne/v2/app" |
| "fyne.io/fyne/v2/driver/desktop" |
| coreLauncher "github.com/mudler/LocalAI/cmd/launcher/internal" |
| "github.com/mudler/LocalAI/pkg/signals" |
| ) |
|
|
| func main() { |
| |
| myApp := app.NewWithID("com.localai.launcher") |
| myApp.SetIcon(resourceIconPng) |
| myWindow := myApp.NewWindow("LocalAI Launcher") |
| myWindow.Resize(fyne.NewSize(800, 600)) |
|
|
| |
| ui := coreLauncher.NewLauncherUI() |
|
|
| |
| launcher := coreLauncher.NewLauncher(ui, myWindow, myApp) |
|
|
| |
| content := ui.CreateMainUI(launcher) |
| myWindow.SetContent(content) |
|
|
| |
| myWindow.SetCloseIntercept(func() { |
| myWindow.Hide() |
| }) |
|
|
| |
| if desk, ok := myApp.(desktop.App); ok { |
| |
| systray := coreLauncher.NewSystrayManager(launcher, myWindow, desk, myApp, resourceIconPng) |
| launcher.SetSystray(systray) |
| } |
|
|
| |
| signals.RegisterGracefulTerminationHandler(func() { |
| |
| if err := launcher.Shutdown(); err != nil { |
| log.Printf("Error during shutdown: %v", err) |
| } |
| }) |
|
|
| |
| go func() { |
| if err := launcher.Initialize(); err != nil { |
| log.Printf("Failed to initialize launcher: %v", err) |
| if launcher.GetUI() != nil { |
| launcher.GetUI().UpdateStatus("Failed to initialize: " + err.Error()) |
| } |
| } else { |
| |
| launcher.GetUI().LoadConfiguration() |
| launcher.GetUI().UpdateStatus("Ready") |
|
|
| |
| config := launcher.GetConfig() |
| if *config.ShowWelcome { |
| launcher.GetUI().ShowWelcomeWindow() |
| } |
| } |
| }() |
|
|
| |
| myApp.Run() |
| } |
|
|