sync/main.go
2025-05-20 13:01:02 -04:00

58 lines
1.5 KiB
Go

package main
import (
"FanslySync/utils"
"context"
"embed"
"log"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
// Create an instance of the app structure
app := NewApp()
// Create our custom file logger
fileLogger, loggerCreateErr := utils.NewLogger("runtime")
startupLogger, startupLoggerCreateErr := utils.NewLogger("startup")
if loggerCreateErr != nil || startupLoggerCreateErr != nil {
log.Fatal("Failed to create one or more loggers: ", loggerCreateErr, startupLoggerCreateErr)
}
// Create application with options
err := wails.Run(&options.App{
Title: "FanslySync",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
},
DisableResize: true,
Logger: fileLogger,
LogLevel: logger.ERROR,
LogLevelProduction: logger.INFO,
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: func(ctx context.Context) {
app.startup(ctx, startupLogger)
},
Bind: []interface{}{
app,
},
})
if err != nil {
// Build a message box with the error
utils.ShowMessageBox(app.ctx, "FanslySync | Initialization Error", "Could not start application.\n\nError: "+err.Error(), utils.WithDialogType(runtime.ErrorDialog))
runtime.Quit(app.ctx)
}
}