package main import ( "embed" _ "embed" "file-manage-ui/data" "file-manage-ui/handler" "fmt" "github.com/wailsapp/wails/v3/pkg/events" "log" "time" "github.com/wailsapp/wails/v3/pkg/application" ) //go:embed all:frontend/dist var assets embed.FS func main() { a := &handler.Service{} app := application.New(application.Options{ Name: "文件管理系统", Description: "上传文件管理系统", //功能服务 Services: []application.Service{ //application.NewService(&GreetService{}), application.NewService(a), application.NewService(&handler.LoginHandler{}), }, //资源文件配置 Assets: application.AssetOptions{ Handler: application.AssetFileServerFS(assets), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, }, }) data.WindowManager(app) MainWindow(app) go func() { for { now := time.Now().Format(time.RFC1123) app.EmitEvent("time", now) time.Sleep(time.Second) } }() err := app.Run() if err != nil { log.Fatal(err) } } func MainWindow(app *application.App) { //窗口管理 win1 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ Title: "Main", Name: "main", Mac: application.MacWindow{ InvisibleTitleBarHeight: 50, Backdrop: application.MacBackdropTranslucent, TitleBar: application.MacTitleBarHiddenInset, }, Frameless: true, Windows: application.WindowsWindow{}, //BackgroundColour: application.NewRGB(27, 38, 54), URL: "/", EnableDragAndDrop: true, }) // 加载窗口到 管理器中 data.WindowMap[win1] = true win1.OnWindowEvent(events.Common.WindowFilesDropped, func(e *application.WindowEvent) { app.Logger.Info("WindowFilesDropped") for index, item := range e.Context().DroppedFiles() { app.Logger.Info(fmt.Sprintf("文件路径(%d): %s", index, item)) } }) }