mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
feat(cli): optimized template generation (#1166)
* feat(cli): update base template configuration * feat: optimize template project script (https://github.com/wailsapp/wails/issues/1165)
This commit is contained in:
@@ -26,6 +26,13 @@ func (a App) domReady(ctx context.Context) {
|
||||
// Add your action here
|
||||
}
|
||||
|
||||
// beforeClose is called when the application is about to quit,
|
||||
// either by clicking the window close button or calling runtime.Quit.
|
||||
// Returning true will cause the application to continue, false will continue shutdown as normal.
|
||||
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
||||
return false
|
||||
}
|
||||
|
||||
// shutdown is called at application termination
|
||||
func (a *App) shutdown(ctx context.Context) {
|
||||
// Perform your teardown here
|
||||
|
||||
@@ -7,23 +7,27 @@ import (
|
||||
"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/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 := NewApp()
|
||||
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "{{.ProjectName}}",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
// MinWidth: 720,
|
||||
// MinHeight: 570,
|
||||
Title: "{{.ProjectName}}",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
MinWidth: 1024,
|
||||
MinHeight: 768,
|
||||
// MaxWidth: 1280,
|
||||
// MaxHeight: 740,
|
||||
DisableResize: false,
|
||||
@@ -31,12 +35,16 @@ func main() {
|
||||
Frameless: false,
|
||||
StartHidden: false,
|
||||
HideWindowOnClose: false,
|
||||
RGBA: &options.RGBA{255, 255, 255, 255},
|
||||
RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
||||
Assets: assets,
|
||||
Menu: nil,
|
||||
Logger: nil,
|
||||
LogLevel: logger.DEBUG,
|
||||
OnStartup: app.startup,
|
||||
OnDomReady: app.domReady,
|
||||
OnBeforeClose: app.beforeClose,
|
||||
OnShutdown: app.shutdown,
|
||||
WindowStartState: options.Normal,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
@@ -45,6 +53,27 @@ func main() {
|
||||
WebviewIsTransparent: false,
|
||||
WindowIsTranslucent: false,
|
||||
DisableWindowIcon: false,
|
||||
// DisableFramelessWindowDecorations: false,
|
||||
WebviewUserDataPath: "",
|
||||
},
|
||||
// Mac platform specific options
|
||||
Mac: &mac.Options{
|
||||
TitleBar: &mac.TitleBar{
|
||||
TitlebarAppearsTransparent: true,
|
||||
HideTitle: false,
|
||||
HideTitleBar: false,
|
||||
FullSizeContent: false,
|
||||
UseToolbar: false,
|
||||
HideToolbarSeparator: true,
|
||||
},
|
||||
Appearance: mac.NSAppearanceNameDarkAqua,
|
||||
WebviewIsTransparent: true,
|
||||
WindowIsTranslucent: true,
|
||||
About: &mac.AboutInfo{
|
||||
Title: "{{.ProjectName}}",
|
||||
Message: "",
|
||||
Icon: icon,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "{{.ProjectName}}",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"install": "go install github.com/wailsapp/wails/v2/cmd/wails@latest",
|
||||
"build": "wails build --clean",
|
||||
"build:macos": "npm run build -- --platform darwin/universal",
|
||||
"build:macos-arm": "npm run build -- --platform darwin/arm64",
|
||||
"build:macos-intel": "npm run build -- --platform darwin",
|
||||
"build:windows": "npm run build -- --platform windows/amd64"
|
||||
},
|
||||
"workspaces": [
|
||||
"frontend"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Start building the app for macos platform..."
|
||||
wails build --clean --platform darwin/arm64
|
||||
|
||||
echo -e "End running the script!"
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Start building the app for macos platform..."
|
||||
wails build --clean --platform darwin
|
||||
|
||||
echo -e "End running the script!"
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Start building the app for macos platform..."
|
||||
wails build --clean --platform darwin/universal
|
||||
|
||||
echo -e "End running the script!"
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Start building the app for windows platform..."
|
||||
wails build --clean --platform windows/amd64
|
||||
|
||||
echo -e "End running the script!"
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Start building the app..."
|
||||
wails build --clean
|
||||
|
||||
echo -e "End running the script!"
|
||||
@@ -0,0 +1,14 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo -e "Start running the script..."
|
||||
cd ../
|
||||
|
||||
echo -e "Current Go version: \c"
|
||||
go version
|
||||
|
||||
echo -e "Install the Wails command line tool..."
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
|
||||
echo -e "Successful installation!"
|
||||
|
||||
echo -e "End running the script!"
|
||||
Reference in New Issue
Block a user