add: send files
This commit is contained in:
30
main.go
30
main.go
@@ -10,11 +10,17 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/wailsapp/wails/v3/pkg/events"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
type FilesDroppedEvent struct {
|
||||
Files []string `json:"files"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
state := config.LoadWindowState()
|
||||
|
||||
@@ -57,14 +63,26 @@ func main() {
|
||||
app.RegisterService(application.NewService(discoveryService))
|
||||
app.RegisterService(application.NewService(transferService))
|
||||
|
||||
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
||||
Title: "mesh drop",
|
||||
Width: state.Width,
|
||||
Height: state.Height,
|
||||
X: state.X,
|
||||
Y: state.Y,
|
||||
windows := app.Window.NewWithOptions(application.WebviewWindowOptions{
|
||||
Title: "mesh drop",
|
||||
Width: state.Width,
|
||||
Height: state.Height,
|
||||
X: state.X,
|
||||
Y: state.Y,
|
||||
EnableFileDrop: true,
|
||||
})
|
||||
|
||||
windows.OnWindowEvent(events.Common.WindowFilesDropped, func(event *application.WindowEvent) {
|
||||
files := event.Context().DroppedFiles()
|
||||
details := event.Context().DropTargetDetails()
|
||||
app.Event.Emit("files-dropped", FilesDroppedEvent{
|
||||
Files: files,
|
||||
Target: details.ElementID,
|
||||
})
|
||||
})
|
||||
|
||||
application.RegisterEvent[FilesDroppedEvent]("files-dropped")
|
||||
|
||||
// Initialize structured logging
|
||||
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelDebug,
|
||||
|
||||
Reference in New Issue
Block a user