mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
# Conflicts:
# mkdocs-website/docs/en/changelog.md
This commit is contained in:
parent
2c55110776
commit
4386f5fcb2
12 changed files with 32 additions and 37 deletions
|
|
@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Do not bind internal service methods in [#3720](https://github.com/wailsapp/wails/pull/3720) by [leaanthony](https://github.com/leaanthony)
|
||||
- [windows] Fixed system tray startup panic in [#3693](https://github.com/wailsapp/wails/issues/3693) by [@DeltaLaboratory](https://github.com/DeltaLaboratory)
|
||||
- Major menu item refactor and event handling. Mainly improves macOS for now. By [leaanthony](https://github.com/leaanthony)
|
||||
- Fix tests after plugins and event refactor in [#3746](https://github.com/wailsapp/wails/pull/3746) by [@stendler](https://github.com/stendler)
|
||||
- [windows] Fixed `Failed to unregister class Chrome_WidgetWin_0` warning. By [leaanthony](https://github.com/leaanthony)
|
||||
|
||||
## v3.0.0-alpha.6 - 2024-07-30
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func main() {
|
|||
JS: `window.iamhere = function() { console.log("Hello World!"); }`,
|
||||
})
|
||||
|
||||
app.customEventProcessor.On("clicked", func(_ *application.CustomEvent) {
|
||||
app.OnEvent("clicked", func(_ *application.CustomEvent) {
|
||||
println("clicked")
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ func main() {
|
|||
},
|
||||
})
|
||||
|
||||
app.customEventProcessor.On("button-pressed", func(_ *application.CustomEvent) {
|
||||
app.OnEvent("button-pressed", func(_ *application.CustomEvent) {
|
||||
println("Button Pressed!")
|
||||
})
|
||||
app.customEventProcessor.On("hover", func(_ *application.CustomEvent) {
|
||||
app.OnEvent("hover", func(_ *application.CustomEvent) {
|
||||
println("Hover time!")
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func (a *AssetServer) processWebViewRequestInternal(r webview.Request) {
|
|||
|
||||
uri, err = r.URL()
|
||||
if err != nil {
|
||||
a.options.Logger.Error("Error processing request, unable to get URL: %s (HttpResponse=500)", err)
|
||||
a.options.Logger.Error(fmt.Sprintf("Error processing request, unable to get URL: %s (HttpResponse=500)", err))
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package main
|
|||
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
func ServiceInitialiser[T any]() func(*T) application.Service {
|
||||
func ServiceInitialiser[T any]() func(*T, ...application.ServiceOptions) application.Service {
|
||||
return application.NewService[T]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ func CustomNewService[T any](srv T) application.Service {
|
|||
return application.NewService(&srv)
|
||||
}
|
||||
|
||||
func ServiceInitialiser[T any]() func(*T) application.Service {
|
||||
func ServiceInitialiser[T any]() func(*T, ...application.ServiceOptions) application.Service {
|
||||
return application.NewService[T]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ func (s *SignalHandler) Start() {
|
|||
s.cleanup()
|
||||
break
|
||||
} else if i < s.MaxSignal {
|
||||
s.Logger.Info("Received signal: %v. Press CTRL+C %d more times to force quit...\n", sig, s.MaxSignal-i)
|
||||
s.Logger.Info(fmt.Sprintf("Received signal: %v. Press CTRL+C %d more times to force quit...\n", sig, s.MaxSignal-i))
|
||||
continue
|
||||
} else {
|
||||
s.Logger.Info("Received signal: %v. Force quitting...\n", sig)
|
||||
s.Logger.Info(fmt.Sprintf("Received signal: %v. Force quitting...\n", sig))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,7 @@ func main() {
|
|||
go func() {
|
||||
for {
|
||||
now := time.Now().Format(time.RFC1123)
|
||||
app.Events.Emit(&application.WailsEvent{
|
||||
Name: "time",
|
||||
Data: now,
|
||||
})
|
||||
app.EmitEvent("time", now)
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func New(appOptions Options) *App {
|
|||
if name == "" {
|
||||
name = getServiceName(service)
|
||||
}
|
||||
globalApplication.error("OnStartup() failed:", "service", name, "error", err.Error())
|
||||
globalApplication.Logger.Error("OnStartup() failed:", "service", name, "error", err.Error())
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package oauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gorilla/pat"
|
||||
"github.com/gorilla/sessions"
|
||||
|
|
@ -26,7 +27,6 @@ type Plugin struct {
|
|||
config Config
|
||||
server *http.Server
|
||||
router *pat.Router
|
||||
api application.PluginAPI
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
@ -81,8 +81,7 @@ func (p *Plugin) Name() string {
|
|||
return "github.com/wailsapp/wails/v3/plugins/oauth"
|
||||
}
|
||||
|
||||
func (p *Plugin) Init(api application.PluginAPI) error {
|
||||
p.api = api
|
||||
func (p *Plugin) OnStartup(ctx context.Context, options application.ServiceOptions) error {
|
||||
store := sessions.NewCookieStore([]byte(p.config.SessionSecret))
|
||||
store.MaxAge(p.config.MaxAge)
|
||||
store.Options.Path = "/"
|
||||
|
|
@ -232,16 +231,13 @@ func (p *Plugin) start(provider string) error {
|
|||
router := pat.New()
|
||||
router.Get("/auth/{provider}/callback", func(res http.ResponseWriter, req *http.Request) {
|
||||
|
||||
event := &application.WailsEvent{Name: Success}
|
||||
|
||||
user, err := gothic.CompleteUserAuth(res, req)
|
||||
if err != nil {
|
||||
event.Data = err.Error()
|
||||
event.Name = Error
|
||||
application.Get().EmitEvent(Error, err.Error())
|
||||
} else {
|
||||
event.Data = user
|
||||
application.Get().EmitEvent(Success, user)
|
||||
}
|
||||
application.Get().Events.Emit(event)
|
||||
|
||||
_ = p.server.Close()
|
||||
p.server = nil
|
||||
})
|
||||
|
|
@ -283,10 +279,10 @@ func (p *Plugin) start(provider string) error {
|
|||
window := application.Get().NewWebviewWindowWithOptions(*p.config.WindowConfig)
|
||||
window.Show()
|
||||
|
||||
application.Get().Events.On(Success, func(event *application.WailsEvent) {
|
||||
application.Get().OnEvent(Success, func(event *application.CustomEvent) {
|
||||
window.Close()
|
||||
})
|
||||
application.Get().Events.On(Error, func(event *application.WailsEvent) {
|
||||
application.Get().OnEvent(Error, func(event *application.CustomEvent) {
|
||||
window.Close()
|
||||
})
|
||||
|
||||
|
|
@ -301,12 +297,11 @@ func (p *Plugin) logout(provider string) error {
|
|||
router := pat.New()
|
||||
router.Get("/logout/{provider}", func(res http.ResponseWriter, req *http.Request) {
|
||||
err := gothic.Logout(res, req)
|
||||
event := &application.WailsEvent{Name: LoggedOut}
|
||||
if err != nil {
|
||||
event.Data = err.Error()
|
||||
event.Name = Error
|
||||
application.Get().EmitEvent(Error, err.Error())
|
||||
} else {
|
||||
application.Get().EmitEvent(LoggedOut)
|
||||
}
|
||||
application.Get().Events.Emit(event)
|
||||
_ = p.server.Close()
|
||||
p.server = nil
|
||||
})
|
||||
|
|
@ -344,10 +339,10 @@ func (p *Plugin) logout(provider string) error {
|
|||
window := application.Get().NewWebviewWindowWithOptions(*p.config.WindowConfig)
|
||||
window.Show()
|
||||
|
||||
application.Get().Events.On(LoggedOut, func(event *application.WailsEvent) {
|
||||
application.Get().OnEvent(LoggedOut, func(event *application.CustomEvent) {
|
||||
window.Close()
|
||||
})
|
||||
application.Get().Events.On(Error, func(event *application.WailsEvent) {
|
||||
application.Get().OnEvent(Error, func(event *application.CustomEvent) {
|
||||
window.Close()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package single_instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
|
|
@ -43,8 +44,8 @@ func NewPlugin(config *Config) *Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Shutdown is called when the app is shutting down
|
||||
func (p *Plugin) Shutdown() error {
|
||||
// OnShutdown is called when the app is shutting down
|
||||
func (p *Plugin) OnShutdown() error {
|
||||
return p.lockfile.Close()
|
||||
}
|
||||
|
||||
|
|
@ -53,10 +54,10 @@ func (p *Plugin) Name() string {
|
|||
return "github.com/wailsapp/wails/v3/plugins/single-instance"
|
||||
}
|
||||
|
||||
// Init is called when the app is starting up. You can use this to
|
||||
// OnStartup is called when the app is starting up. You can use this to
|
||||
// initialise any resources you need. You can also access the application
|
||||
// instance via the app property.
|
||||
func (p *Plugin) Init(api application.PluginAPI) error {
|
||||
func (p *Plugin) OnStartup(ctx context.Context, options application.ServiceOptions) error {
|
||||
var err error
|
||||
lockfileName := p.config.LockFilePath + "/" + p.config.LockFileName
|
||||
p.lockfile, err = CreateLockFile(lockfileName, application.Get().GetPID())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package start_at_login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"io/fs"
|
||||
)
|
||||
|
|
@ -22,9 +23,9 @@ func NewPlugin(options Config) *Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Shutdown is called when the app is shutting down
|
||||
// OnShutdown is called when the app is shutting down
|
||||
// You can use this to clean up any resources you have allocated
|
||||
func (p *Plugin) Shutdown() error { return nil }
|
||||
func (p *Plugin) OnShutdown() error { return nil }
|
||||
|
||||
// Name returns the name of the plugin.
|
||||
// You should use the go module format e.g. github.com/myuser/myplugin
|
||||
|
|
@ -32,7 +33,7 @@ func (p *Plugin) Name() string {
|
|||
return "github.com/wailsapp/wails/v3/plugins/start_at_login"
|
||||
}
|
||||
|
||||
func (p *Plugin) Init(api application.PluginAPI) error {
|
||||
func (p *Plugin) OnStartup(ctx context.Context, options application.ServiceOptions) error {
|
||||
// OS specific initialiser
|
||||
err := p.init()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue