AppDelegate.swift 1.5 KB

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