KMProductPromotionViewController.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // KMProductPromotionViewController.swift
  3. // PDF Master
  4. //
  5. // Home--运营活动 模块
  6. // Created by wanjun on 2022/10/18.
  7. //
  8. import Cocoa
  9. class KMProductPromotionViewController: NSViewController {
  10. @IBOutlet weak var activitiesBox: KMBox!
  11. @IBOutlet weak var activitiesImageView: NSImageView!
  12. @IBOutlet weak var activitiesCloseButton: NSButton!
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. // Do view setup here.
  16. activitiesBox.cornerRadius = 8.0
  17. self.activitiesCloseButton.isHidden = true
  18. self.activitiesBox.downCallback = {(downEntered: Bool, mouseBox: KMBox, event) -> Void in
  19. if downEntered {
  20. self.activitiesButtonAction()
  21. }
  22. }
  23. self.activitiesBox.moveCallback = {(mouseEntered: Bool, mouseBox: KMBox) -> Void in
  24. // if mouseEntered {
  25. // self.activitiesCloseButton.isHidden = false
  26. // } else {
  27. // self.activitiesCloseButton.isHidden = true
  28. // }
  29. }
  30. }
  31. // MARK: Action
  32. func activitiesButtonAction() {
  33. // 点击运营活动
  34. let httpUrl: NSURL = NSURL.init(string: "https://www.pdfreaderpro.com/store")!
  35. let tWorkSpace: NSWorkspace = NSWorkspace.shared
  36. if !tWorkSpace.open(httpUrl as URL) {
  37. tWorkSpace.open(httpUrl as URL)
  38. }
  39. }
  40. @IBAction func activitiesCloseButtonAction(_ sender: NSButton) {
  41. self.activitiesBox.removeFromSuperview()
  42. }
  43. }