5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-12 06:59:30 +08:00

[v2]feat: optimize the content of the default template

This commit is contained in:
misitebao 2021-09-23 02:08:58 +08:00
parent fe6dd4d18f
commit 54a401106b
10 changed files with 84 additions and 69 deletions

View File

@ -21,6 +21,11 @@ func (b *App) startup(ctx context.Context) {
b.ctx = ctx
}
// domReady is called after the front-end dom has been loaded
func (b App) domReady(ctx context.Context) {
// Add your action here
}
// shutdown is called at application termination
func (b *App) shutdown(ctx context.Context) {
// Perform your teardown here

View File

@ -23,5 +23,6 @@
},
"dependencies": {
"sirv-cli": "^1.0.0"
}
,"author":"{{.AuthorName}}"}
},
"author": "{{.AuthorName}}"
}

View File

@ -1,52 +0,0 @@
package main
import (
"embed"
"log"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
// Create application with options
app := NewApp()
err := wails.Run(&options.App{
Title: "",
Width: 800,
Height: 600,
MinWidth: 400,
MinHeight: 400,
MaxWidth: 1280,
MaxHeight: 1024,
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: false,
HideWindowOnClose: false,
RGBA: 0x000000FF,
Assets: assets,
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
DisableWindowIcon: true,
},
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
})
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,54 @@
package main
import (
"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/windows"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
// Create an instance of the app structure
app := NewApp()
// Create application with options
err := wails.Run(&options.App{
Title: "{{.ProjectName}}",
Width: 720,
Height: 570,
MinWidth: 720,
MinHeight: 570,
MaxWidth: 1280,
MaxHeight: 740,
DisableResize: false,
Fullscreen: false,
Frameless: false,
StartHidden: false,
HideWindowOnClose: false,
RGBA: &options.RGBA{255, 255, 255, 255},
Assets: assets,
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnDomReady: app.domReady,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
// Windows platform specific options
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
})
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,7 +1,7 @@
{
"name": "Basic Svelte + Rollup",
"shortname": "svelte",
"author": "Lea Anthony",
"author": "Lea Anthony <lea.anthony@gmail.com>",
"description": "Svelte template using rollup to bundle css, images and fonts",
"helpurl": "https://github.com/wailsapp/wails"
}
}

View File

@ -2,10 +2,10 @@
"name": "{{.ProjectName}}",
"outputfilename": "{{.BinaryName}}",
"assetdir": "frontend/dist",
"frontend:build": "npm run build",
"frontend:install": "npm install",
"frontend:build": "npm run build",
"author": {
"name": "{{.AuthorName}}",
"email": "{{.AuthorEmail}}"
}
}
}

View File

@ -21,6 +21,11 @@ func (b *App) startup(ctx context.Context) {
b.ctx = ctx
}
// domReady is called after the front-end dom has been loaded
func (b App) domReady(ctx context.Context) {
// Add your action here
}
// shutdown is called at application termination
func (b *App) shutdown(ctx context.Context) {
// Perform your teardown here

View File

@ -14,10 +14,10 @@ import (
var assets embed.FS
func main() {
// Create application with options
// Create an instance of the app structure
app := NewApp()
// Create application with options
err := wails.Run(&options.App{
Title: "{{.ProjectName}}",
Width: 720,
@ -33,17 +33,19 @@ func main() {
HideWindowOnClose: false,
RGBA: &options.RGBA{255, 255, 255, 255},
Assets: assets,
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnDomReady: app.domReady,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
// Windows platform specific options
Windows: &windows.Options{
WebviewIsTransparent: false,
WindowIsTranslucent: false,
DisableWindowIcon: false,
},
LogLevel: logger.DEBUG,
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
})
if err != nil {

View File

@ -1,7 +1,7 @@
{
"name": "Vanilla HTML/JS/CSS",
"shortname": "vanilla",
"author": "Lea Anthony<lea.anthony@gmail.com>",
"author": "Lea Anthony <lea.anthony@gmail.com>",
"description": "A simple template using only HTML/CSS/JS",
"helpurl": "https://github.com/wailsapp/wails"
}
}

View File

@ -6,4 +6,4 @@
"name": "{{.AuthorName}}",
"email": "{{.AuthorEmail}}"
}
}
}