57b35ffd08
Use BundledAssetFileServer so production builds serve the Wails runtime alongside the embedded frontend dist (including kbsim samples copied at build time). Verified via wails3 task build. Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
//go:embed all:frontend/dist
|
|
var assets embed.FS
|
|
|
|
func main() {
|
|
var fileService *FileService
|
|
|
|
app := application.New(application.Options{
|
|
Name: "sfxkeeb",
|
|
Description: "Annotate keyboard key presses on a video timeline",
|
|
Assets: application.AssetOptions{
|
|
Handler: application.BundledAssetFileServer(assets),
|
|
Middleware: func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path == localMediaVideoPath && fileService != nil {
|
|
fileService.serveVideo(w, r)
|
|
return
|
|
}
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
},
|
|
},
|
|
Mac: application.MacOptions{
|
|
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
|
},
|
|
})
|
|
|
|
fileService = NewFileService(app)
|
|
app.RegisterService(application.NewService(fileService))
|
|
|
|
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
|
Title: "sfxkeeb",
|
|
Width: 1280,
|
|
Height: 900,
|
|
MinWidth: 960,
|
|
MinHeight: 600,
|
|
Mac: application.MacWindow{
|
|
InvisibleTitleBarHeight: 50,
|
|
Backdrop: application.MacBackdropTranslucent,
|
|
TitleBar: application.MacTitleBarHiddenInset,
|
|
},
|
|
BackgroundColour: application.NewRGB(27, 38, 54),
|
|
URL: "/",
|
|
})
|
|
|
|
if err := app.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|