add: send files

This commit is contained in:
2026-02-04 17:57:56 +08:00
parent 68533dad31
commit 0e94ae3220
17 changed files with 725 additions and 315 deletions

30
main.go
View File

@@ -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,