AppDelegate.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // AppDelegate.swift
  3. // PDF Reader Pro DMG
  4. //
  5. // Created by Niehaoyu on 2022/9/23.
  6. //
  7. import Cocoa
  8. @main
  9. class AppDelegate: NSObject, NSApplicationDelegate {
  10. func applicationWillFinishLaunching(_ notification: Notification) {
  11. ComPDFUIConfig.initializeUIConfig();
  12. }
  13. func applicationDidFinishLaunching(_ aNotification: Notification) {
  14. // Insert code here to initialize your application
  15. // MARK: 广告数据初始化
  16. KMAdvertisementManager.manager.initConfig(appName: .PDFReaderProMac,
  17. subscribeType: .unsubscribed,
  18. platform: .Mac)
  19. // 测试模式,默认false
  20. KMAdvertisementManager.manager.debug = true
  21. }
  22. func applicationWillTerminate(_ aNotification: Notification) {
  23. // Insert code here to tear down your application
  24. }
  25. func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
  26. return true
  27. }
  28. }
  29. extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
  30. func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  31. let action = menuItem.action
  32. if action == #selector(manageAcctounMenuAction) {
  33. return KMLightMemberManager.manager.isLogin()
  34. }
  35. if action == #selector(loginMenuItemAction) {
  36. return !KMLightMemberManager.manager.isLogin()
  37. }
  38. return true
  39. }
  40. }