1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2024-11-22 10:25:48 +01:00
rolens/main.go

77 lines
1.7 KiB
Go
Raw Normal View History

2023-01-10 17:28:27 +01:00
package main
import (
2023-02-21 17:47:21 +01:00
"context"
2023-01-10 17:28:27 +01:00
"embed"
2023-02-11 21:57:52 +01:00
"path"
2023-01-10 17:28:27 +01:00
"github.com/garraflavatra/rolens/internal/app"
2023-02-21 17:47:21 +01:00
uictrl "github.com/garraflavatra/rolens/internal/ui"
2023-05-27 21:18:47 +02:00
"github.com/ncruces/zenity"
2023-01-10 17:28:27 +01:00
"github.com/wailsapp/wails/v2"
2023-02-11 21:57:52 +01:00
"github.com/wailsapp/wails/v2/pkg/logger"
2023-01-10 17:28:27 +01:00
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
2023-01-16 16:56:16 +01:00
"github.com/wailsapp/wails/v2/pkg/options/mac"
2023-05-27 21:18:47 +02:00
"github.com/wailsapp/wails/v2/pkg/runtime"
2023-01-10 17:28:27 +01:00
)
2023-01-16 16:56:16 +01:00
var (
//go:embed all:frontend/dist
assets embed.FS
//go:embed build/appicon.png
appIcon []byte
)
2023-01-10 17:28:27 +01:00
func main() {
2023-01-14 20:47:29 +01:00
app := app.NewApp()
2023-02-21 17:47:21 +01:00
ui := uictrl.New()
2023-01-10 17:28:27 +01:00
err := wails.Run(&options.App{
2023-02-11 21:57:52 +01:00
Title: "Rolens",
Width: 1000,
Height: 600,
MinWidth: 1000,
MinHeight: 600,
2023-01-16 16:56:16 +01:00
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 139, A: 1},
2023-01-20 16:27:51 +01:00
Menu: app.Menu(),
2023-02-21 17:47:21 +01:00
Bind: []interface{}{app, ui},
2023-02-15 20:33:29 +01:00
AssetServer: &assetserver.Options{Assets: assets},
2023-02-21 17:47:21 +01:00
OnStartup: func(ctx context.Context) {
2023-05-27 21:18:47 +02:00
defer func() {
if p := recover(); p != nil {
runtime.LogFatalf(ctx, "Application panicked: %v", p)
zenity.Error("A fatal error occured.")
}
}()
2023-02-21 17:47:21 +01:00
ui.Startup(ctx)
2023-05-27 21:18:47 +02:00
app.Startup(ctx, ui)
2023-02-21 17:47:21 +01:00
},
2023-02-15 20:33:29 +01:00
OnShutdown: app.Shutdown,
2023-01-16 16:56:16 +01:00
2023-02-11 21:57:52 +01:00
Logger: logger.NewFileLogger(path.Join(app.Env.LogDirectory, "rolens.log")),
LogLevel: logger.TRACE,
LogLevelProduction: logger.INFO,
2023-01-16 16:56:16 +01:00
Mac: &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: "Rolens - Multiplatform MongoDB client",
2023-01-16 16:56:16 +01:00
Message: "© 2023 Romein van Buren",
Icon: appIcon,
},
},
2023-01-10 17:28:27 +01:00
})
if err != nil {
println("Error:", err.Error())
}
}