mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 13:41:50 +08:00
pass service options
This commit is contained in:
parent
be1da68dbc
commit
ef3b7d2bc3
@ -20,9 +20,9 @@ import (
|
|||||||
"github.com/wailsapp/wails/v3/pkg/application"
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
)
|
)
|
||||||
|
|
||||||
type notificationImpl interface {
|
type platformNotifier interface {
|
||||||
// Lifecycle methods
|
// Lifecycle methods
|
||||||
Startup(ctx context.Context) error
|
Startup(ctx context.Context, options application.ServiceOptions) error
|
||||||
Shutdown() error
|
Shutdown() error
|
||||||
|
|
||||||
// Core notification methods
|
// Core notification methods
|
||||||
@ -45,7 +45,7 @@ type notificationImpl interface {
|
|||||||
|
|
||||||
// Service represents the notifications service
|
// Service represents the notifications service
|
||||||
type Service struct {
|
type Service struct {
|
||||||
impl notificationImpl
|
impl platformNotifier
|
||||||
|
|
||||||
// notificationResponseCallback is called when a notification result is received.
|
// notificationResponseCallback is called when a notification result is received.
|
||||||
// Only one callback can be assigned at a time.
|
// Only one callback can be assigned at a time.
|
||||||
@ -136,7 +136,7 @@ func (ns *Service) handleNotificationResult(result NotificationResult) {
|
|||||||
|
|
||||||
// ServiceStartup is called when the service is loaded
|
// ServiceStartup is called when the service is loaded
|
||||||
func (ns *Service) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
|
func (ns *Service) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
|
||||||
return ns.impl.Startup(ctx)
|
return ns.impl.Startup(ctx, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceShutdown is called when the service is unloaded
|
// ServiceShutdown is called when the service is unloaded
|
||||||
|
@ -15,6 +15,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
)
|
)
|
||||||
|
|
||||||
type darwinNotifier struct {
|
type darwinNotifier struct {
|
||||||
@ -56,7 +58,7 @@ func New() *Service {
|
|||||||
return NotificationService
|
return NotificationService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dn *darwinNotifier) Startup(ctx context.Context) error {
|
func (dn *darwinNotifier) Startup(ctx context.Context, options application.ServiceOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func New() *Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Startup is called when the service is loaded
|
// Startup is called when the service is loaded
|
||||||
func (ln *linuxNotifier) Startup(ctx context.Context) error {
|
func (ln *linuxNotifier) Startup(ctx context.Context, options application.ServiceOptions) error {
|
||||||
ln.appName = application.Get().Config().Name
|
ln.appName = application.Get().Config().Name
|
||||||
|
|
||||||
if err := ln.loadCategories(); err != nil {
|
if err := ln.loadCategories(); err != nil {
|
||||||
|
@ -57,7 +57,7 @@ func New() *Service {
|
|||||||
|
|
||||||
// Startup is called when the service is loaded
|
// Startup is called when the service is loaded
|
||||||
// Sets an activation callback to emit an event when notifications are interacted with.
|
// Sets an activation callback to emit an event when notifications are interacted with.
|
||||||
func (wn *windowsNotifier) Startup(ctx context.Context) error {
|
func (wn *windowsNotifier) Startup(ctx context.Context, options application.ServiceOptions) error {
|
||||||
wn.appName = application.Get().Config().Name
|
wn.appName = application.Get().Config().Name
|
||||||
|
|
||||||
guid, err := wn.getGUID()
|
guid, err := wn.getGUID()
|
||||||
|
Loading…
Reference in New Issue
Block a user