main.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "embed"
  4. "github.com/astaxie/beego"
  5. "github.com/wailsapp/wails/v2"
  6. "github.com/wailsapp/wails/v2/pkg/options"
  7. "github.com/wailsapp/wails/v2/pkg/options/assetserver"
  8. "nginx-ui/desktop"
  9. _ "nginx-ui/server/init"
  10. )
  11. //go:embed all:frontend/dist
  12. var assets embed.FS
  13. func main() {
  14. // Create an instance of the app structure
  15. api := desktop.NewApi()
  16. go beego.Run()
  17. // Create application with options
  18. err := wails.Run(&options.App{
  19. Title: "nginx-ui-desktop",
  20. Width: 1200,
  21. Height: 800,
  22. AssetServer: &assetserver.Options{
  23. Assets: assets,
  24. //如果你想为你的前端动态加载或生成资产,你可以使用 AssetsHandler 选项 来实现。
  25. //AssetsHandler 是一个通用的 http.Handler,对于资产服务器上的任何非 GET 请求以及由于找不到文件而无法从捆绑资产提供服务的 GET 请求,都会调用它。
  26. Handler: desktop.NewApiHandler(nil),
  27. },
  28. BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
  29. OnStartup: api.Startup,
  30. Bind: []interface{}{},
  31. })
  32. if err != nil {
  33. println("Error:", err.Error())
  34. }
  35. }