wails-app-dock/main.go

99 lines
2.6 KiB
Go
Raw Normal View History

2024-02-17 17:00:13 +08:00
package main
import (
"embed"
"log"
2024-02-17 21:45:43 +08:00
"skapp/pkg/core"
2024-02-17 17:00:13 +08:00
"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/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
//go:embed frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
func main() {
// Create an instance of the app structure
// 创建一个App结构体实例
2024-02-17 21:45:43 +08:00
app := core.NewApp()
2024-02-17 17:00:13 +08:00
// Create application with options
// 使用选项创建应用
err := wails.Run(&options.App{
Title: "wails-app-dock",
2024-02-17 21:45:43 +08:00
Width: 1024,
Height: 768,
MinWidth: 1024,
MinHeight: 768,
MaxWidth: 0,
MaxHeight: 0,
2024-02-17 17:00:13 +08:00
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: false,
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 0},
Menu: nil,
Logger: nil,
LogLevel: logger.DEBUG,
2024-02-17 21:45:43 +08:00
OnStartup: app.Startup,
OnDomReady: app.DomReady,
OnBeforeClose: app.BeforeClose,
OnShutdown: app.Shutdown,
2024-02-17 17:00:13 +08:00
WindowStartState: options.Normal,
AssetServer: &assetserver.Options{
2024-02-17 21:45:43 +08:00
Assets: assets,
Handler: app.Handler,
2024-02-17 17:00:13 +08:00
},
Bind: []interface{}{
app,
},
// Windows platform specific options
// Windows平台特定选项
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: false,
DisableWindowIcon: false,
DisableFramelessWindowDecorations: false,
WebviewUserDataPath: "",
WebviewBrowserPath: "",
Theme: windows.SystemDefault,
},
// Mac platform specific options
// Mac平台特定选项
Mac: &mac.Options{
TitleBar: &mac.TitleBar{
TitlebarAppearsTransparent: true,
HideTitle: true,
HideTitleBar: false,
FullSizeContent: true,
UseToolbar: false,
HideToolbarSeparator: false,
},
Appearance: mac.NSAppearanceNameDarkAqua,
WebviewIsTransparent: true,
WindowIsTranslucent: true,
About: &mac.AboutInfo{
Title: "Wails Template Vue",
Message: "A Wails template based on Vue and Vue-Router",
Icon: icon,
},
},
Linux: &linux.Options{
Icon: icon,
},
})
if err != nil {
log.Fatal(err)
}
}