Service.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package handler
  2. import (
  3. "context"
  4. "file-manage-ui/data"
  5. "github.com/wailsapp/wails/v3/pkg/application"
  6. )
  7. type Ctx struct {
  8. ctx context.Context
  9. }
  10. // Service struct
  11. type Service struct {
  12. //ctx context.Context
  13. Ctx *Ctx
  14. }
  15. // NewService creates a new App application struct
  16. func NewService(Ctx *Ctx) *Service {
  17. return &Service{Ctx: Ctx}
  18. }
  19. // Startup is called when the app starts. The context is saved,
  20. // so we can call the runtime methods
  21. func (a *Ctx) Startup(ctx context.Context) {
  22. a.ctx = ctx
  23. }
  24. // CloseApp 根据名称关闭窗口
  25. func (a *Service) CloseApp(winName string) {
  26. if winName == "login-page" {
  27. }
  28. }
  29. func (a *Service) OpenLoginPage() {
  30. LoginWindow(data.App)
  31. }
  32. func LoginWindow(app *application.App) {
  33. //窗口管理
  34. win1 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
  35. Title: "Login",
  36. Name: "login",
  37. Mac: application.MacWindow{
  38. InvisibleTitleBarHeight: 50,
  39. Backdrop: application.MacBackdropTranslucent,
  40. TitleBar: application.MacTitleBarHiddenInset,
  41. },
  42. Frameless: true,
  43. Windows: application.WindowsWindow{},
  44. //BackgroundColour: application.NewRGB(27, 38, 54),
  45. URL: "/#/login",
  46. EnableDragAndDrop: true,
  47. })
  48. // 加载窗口到 管理器中
  49. data.WindowMap[win1] = true
  50. }