1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2024-11-25 12:20:33 +01:00
rolens/main.go

83 lines
1.9 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"
"github.com/garraflavatra/rolens/internal"
"github.com/garraflavatra/rolens/internal/app"
2023-02-21 17:47:21 +01:00
uictrl "github.com/garraflavatra/rolens/internal/ui"
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
//go:embed build/version.txt
version string
2023-01-16 16:56:16 +01:00
)
2023-01-10 17:28:27 +01:00
func main() {
app := app.NewApp(version)
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)
runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "A fatal error occured!",
Message: "Please try to restart the application, or consult the logs for more details.",
})
2023-05-27 21:18:47 +02:00
}
}()
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
Logger: internal.NewAppLogger(app.Env.LogDirectory, "rolens.log"),
2023-02-11 21:57:52 +01:00
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",
2024-06-25 10:49:47 +02:00
Message: "© 2022-2024 Romein van Buren",
2023-01-16 16:56:16 +01:00
Icon: appIcon,
},
},
2023-01-10 17:28:27 +01:00
})
if err != nil {
println("Error:", err.Error())
}
}