Mining/cmd/desktop/mining-desktop/main.go
snider 80d2c56047 feat: Add Wails desktop app with cross-platform GitHub Actions build
Create native desktop application using Wails v3 with Angular frontend.
The app wraps the mining CLI backend and exposes functionality via
TypeScript bindings for system info, miner control, profiles, and stats.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:55:14 +00:00

71 lines
1.6 KiB
Go

package main
import (
"embed"
_ "embed"
"io/fs"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed all:frontend/dist/browser
var assets embed.FS
func main() {
// Create the mining service
miningService := NewMiningService()
// Get the sub-filesystem rooted at frontend/dist/browser
browserFS, err := fs.Sub(assets, "frontend/dist/browser")
if err != nil {
log.Fatal("Failed to create sub-filesystem:", err)
}
// Create a new Wails application
app := application.New(application.Options{
Name: "Mining Dashboard",
Description: "Multi-miner management dashboard",
Services: []application.Service{
application.NewService(miningService),
},
Assets: application.AssetOptions{
Handler: http.FileServer(http.FS(browserFS)),
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create the main window
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Mining Dashboard",
Width: 1400,
Height: 900,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
},
BackgroundColour: application.NewRGB(10, 10, 18),
URL: "/",
})
// Handle graceful shutdown
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigChan
miningService.Shutdown()
os.Exit(0)
}()
// Run the application
if err := app.Run(); err != nil {
log.Fatal(err)
}
}