AppDelegate.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. //
  2. // AppDelegate.swift
  3. // PDF Master
  4. //
  5. // Created by Niehaoyu on 2022/9/23.
  6. //
  7. import Cocoa
  8. import KMAdvertisement
  9. #if VERSION_DMG
  10. import AppCenter
  11. import AppCenterAnalytics
  12. import AppCenterCrashes
  13. #endif
  14. @main
  15. class AppDelegate: NSObject, NSApplicationDelegate {
  16. func applicationWillBecomeActive(_ notification: Notification) {
  17. // NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
  18. }
  19. func applicationDidBecomeActive(_ notification: Notification) {
  20. }
  21. func applicationWillFinishLaunching(_ notification: Notification) {
  22. let appTarget = KMTools_OC.getAppTarget()
  23. if (appTarget == .free) {
  24. CPDFKit.setLicenseKey("cdq2EJ0yq9HmBQy/AlHPtC/+pnZCKi9HaV8t+N2McjPDNTB0Z8xK+4hw4/xn55GNsnWlNbSB7RTkRMQ45T0IZ4Bhsb2wTjMKZgLHXOYCVs+y/A54hwA/v1fm5F6/mdCjqyFpy2uq7LVxNwsCbVVT+PuHmXDUuWqkErl02537Y3E=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4p9ms/F1zY6gZ1RBu8mNJH8VDCh7HQsi+BJS7RukFVBsD3jYTYlv7OHV9TgoY0SmO6Ptvguf6vCH30IoM4xINMau4aGVjtYuk+Uxs/kosIBwyxQV1SVCQFsC27oMGz5P/rBQYv0T/D0N0z+Um3U+I+tTRwFO+iE6+0emjaIlX2OMDXw8/CDEmc6oakb9zq80YfY7KtZ0LxrqSdyM0ZMT4i8IZqTxD9KkvMj3/O+zX155uoFv1BTjCeXlkEOSDvmglU=")
  25. CPDFConvertKit.setLicenseKey("HcZ7sehqdnIvgtFnAF85D2B6tQjbMAklBEZyrSKYYSY/bdNOfGvcNIKpDTUchwAtZLw1fkJ3uN49bgUVSz8UEHm2LpoXPcRK9b+laQ17UHE7qFx6twVZ2IIyEURhMClmFSDD5yAxxpndYl8mmwjIoWspgAdDGX8pixFDQUE3/9w=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MxU9avJIxe/9rGTVfLJgjbpoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  26. } else if (appTarget == .DMG) {
  27. CPDFKit.setLicenseKey("anWsjwnFLewcxYRZbdvBVgX9bZ2Ofz9Yy+tje+KJ6BktwciBCx51vZBUDXpFdUrDugu0t4yVSEh+yOhXXRPgiaeCh1dJX+IR7ztnArFoCS8HQDk3ROXjYWkFOmWioOljbNuORZ/zrsv8l0jRNMLUCPxPbga271sOcUVDeHNn/8c=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4rCrm/O2+fI9yUYXNZ/JY1KPbFCeKgG+lEVwrbGHrpAyXATqjrt8ApqRYhafFooQjwAFgayISwZT/pa4NjR459gu4aGVjtYuk+Uxs/kosIBw9vgMz/YdzEMZoMhFEbmUEc6H4o/0cJmYd/bLPc1WFIlJ3VN41JnIqAKG97dQtCXYUplTxrh5mQs6SZcN0B2PF/dEupdk9Zstt+VbVf6kPXvj9NGZMFeJwC3Ilgq78L0gg==")
  28. CPDFConvertKit.setLicenseKey("SVRr1XuTMVrF85Sp+DpK2q/NpcumFDTxBWajzl08eWpk7DomcFajxwMpgfhLCSCNn5jgMumR/diO8X+tZhrBuPs0UP2gYX1lstnpKPqRx8ZnHCTFMyS06zkIrVGTghH+DHNWyXfMFVGQtIVO/+X77wGOtmn5S4/uUHLJDSgLkmw=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MwekFC/LCdvQ96bASGL15ECoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  29. } else {
  30. CPDFKit.setLicenseKey("cdq2EJ0yq9HmBQy/AlHPtC/+pnZCKi9HaV8t+N2McjPDNTB0Z8xK+4hw4/xn55GNsnWlNbSB7RTkRMQ45T0IZ4Bhsb2wTjMKZgLHXOYCVs+y/A54hwA/v1fm5F6/mdCjqyFpy2uq7LVxNwsCbVVT+PuHmXDUuWqkErl02537Y3E=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4p9ms/F1zY6gZ1RBu8mNJH8VDCh7HQsi+BJS7RukFVBsD3jYTYlv7OHV9TgoY0SmO6Ptvguf6vCH30IoM4xINMau4aGVjtYuk+Uxs/kosIBwyxQV1SVCQFsC27oMGz5P/rBQYv0T/D0N0z+Um3U+I+tTRwFO+iE6+0emjaIlX2OMDXw8/CDEmc6oakb9zq80YfY7KtZ0LxrqSdyM0ZMT4i8IZqTxD9KkvMj3/O+zX155uoFv1BTjCeXlkEOSDvmglU=")
  31. CPDFConvertKit.setLicenseKey("HcZ7sehqdnIvgtFnAF85D2B6tQjbMAklBEZyrSKYYSY/bdNOfGvcNIKpDTUchwAtZLw1fkJ3uN49bgUVSz8UEHm2LpoXPcRK9b+laQ17UHE7qFx6twVZ2IIyEURhMClmFSDD5yAxxpndYl8mmwjIoWspgAdDGX8pixFDQUE3/9w=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MxU9avJIxe/9rGTVfLJgjbpoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  32. }
  33. // CDocumentAIKit.sharedInstance().setLicenseKey("1F8B081800599C640000616C7068610034413635373236463644363535393631364536370001F0010FFE33C3D4634F3E0B148EA10B8E59B57FA6B17EC34749CDBBD02D697F1A481C00666DCDDC517B4F576C4F8A9961080E556DF332DA7C816D3A3C212DCBE34749B6845E561A60C7E13BF8F84EC77FCF314333E1DFFC92E88A6CD97F65F6153452E9677F7A248FD45C98E87647367A29D678DA15EECB5E28854C674FE4DFE810740CB43F4DC1A7444B1EFA3C8C3E3F4D5859A9BAEDF1CF87917E86E6541B924A1AD0FBEC61BDFA0886A1E8FDFECCDE64FCCB645A89323F0177FE0B3CB7E3D72EA9A3DE1823FEB5D967F90751F46B6C97A1C250B669FD145747ADF6571859F78FDA05DA5B963B799DA5CC53ECE0FB8D53165EB3B0188FF8BB201D8AD7A34F01EC1BA855378F2CB8B9176EE463B1F2B1D8BD776113BAEF4C9A78EE7BC12EF192DABD2FBAB2E252A09B38A85BFCD76B4AFBEFF5A4E9FFE499A77B76E97B9C01CC7485688CD696FD1145D47AD969074FD300783583B70460617A0EC2D7579D0EC5AC33DB3F32E0CC920AC25B6D8F177D2F73FF26457534D6233844BEB4B223A37AA59EFB3D2469C8367C0CBF29C8A3E505AA53E62661FFC59771E77C3C274B51E2C066E87C796BA6AC2D2567D25560A7E9DFE3433FC5233A2C0CB4320D57EB8C0422B416CB5E25F94DB1CC0DCE1A39684827B61BCAE552A05607748113F3D6194A29A8C5C400A02FE3C69204D754550FA5E24BC3FF068B99DDF0010000")
  34. ComPDFUIConfig.initializeUIConfig();
  35. KMDesignToken.shared.parserExcel(withPath: "")
  36. }
  37. func applicationDidFinishLaunching(_ aNotification: Notification) {
  38. // Insert code here to initialize your application
  39. var appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
  40. #if VERSION_DMG
  41. let updater = SUUpdater.shared()
  42. updater!.delegate = self
  43. updater!.automaticallyChecksForUpdates = true
  44. appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
  45. #endif
  46. // MARK: 广告数据初始化
  47. KMAdvertisementManager.manager.initConfig(appName: .PDFReaderProMac,
  48. subscribeType: .unsubscribed,
  49. platform: .Mac)
  50. // 测试模式,默认false
  51. KMAdvertisementManager.manager.debug = true
  52. // 初版不支持暗黑模式
  53. NSApp.appearance = NSAppearance(named: .aqua)
  54. #if VERSION_DMG
  55. AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
  56. #endif
  57. //第一次开启app
  58. var info = UserDefaults.standard.value(forKey: "kFirstOpenAppCount")
  59. var count = 0
  60. if info != nil {
  61. count = info as? Int ?? 0
  62. }
  63. count += 1
  64. UserDefaults.standard.set(count, forKey: "kFirstOpenAppCount")
  65. UserDefaults.standard.synchronize()
  66. self.initMainMenu()
  67. /// pro
  68. // [DBClientsManager setupWithAppKeyDesktop:@"amipzwtlg9lrwyl"];
  69. DBClientsManager.setup(withAppKeyDesktop: "jxjlqfm1cfp2mjj")
  70. reopenDocument(forPaths: [])
  71. KMPreferenceManager.shared.author = NSFullUserName()
  72. }
  73. func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  74. }
  75. func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String : Any]) {
  76. }
  77. func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
  78. if !flag {
  79. let browser: KMBrowser = KMBrowser.init()
  80. browser.windowController = KMBrowserWindowController.init(browser: browser)
  81. browser.addHomeTabContents()
  82. browser.windowController.showWindow(self)
  83. }
  84. return flag
  85. }
  86. func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
  87. if (KMPreferenceManager.shared.openLastUnclosedDocumentWhenAppStart == false) {
  88. return false
  89. }
  90. let filepaths = KMPreferenceManager.shared.lastOpenFilepaths
  91. if (filepaths == nil || filepaths!.count == 0) {
  92. return false
  93. }
  94. DispatchQueue.main.async {
  95. for filepath in filepaths! {
  96. if filepath.isPDFValid() {
  97. NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: filepath), display: true) { document, result, error in
  98. }
  99. } else {
  100. let alert = NSAlert()
  101. alert.alertStyle = .critical
  102. alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
  103. alert.runModal()
  104. }
  105. }
  106. }
  107. return false
  108. }
  109. func applicationWillTerminate(_ aNotification: Notification) {
  110. if (NSApp.orderedDocuments.count > 0) {
  111. var filepaths: [String] = []
  112. for document in NSApp.orderedDocuments {
  113. // KMPrint(document.fileURL as Any)
  114. if (document.fileURL?.path != nil) {
  115. filepaths.append((document.fileURL?.path)!)
  116. }
  117. }
  118. KMPreferenceManager.shared.lastOpenFilepaths = filepaths
  119. } else {
  120. KMPreferenceManager.shared.lastOpenFilepaths = nil
  121. }
  122. }
  123. func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
  124. return true
  125. }
  126. // MARK: private
  127. func reopenDocument(forPaths paths: [String]) -> Void {
  128. let browser = KMBrowser.init() as KMBrowser
  129. browser.windowController = KMBrowserWindowController.init(browser: browser)
  130. browser.addHomeTabContents()
  131. browser.windowController.showWindow(self)
  132. }
  133. // MARK: Menu
  134. func initMainMenu() {
  135. // 处理菜单栏多语
  136. let mainMenu = NSApp.mainMenu
  137. if (mainMenu == nil) {
  138. return
  139. }
  140. for menu in mainMenu!.items {
  141. let subMenu = menu.submenu
  142. for item in subMenu!.items {
  143. item.title = NSLocalizedString(item.title, comment: "")
  144. let itemSubMenu = item.submenu
  145. if (itemSubMenu == nil) {
  146. continue
  147. }
  148. for item in itemSubMenu!.items {
  149. item.title = NSLocalizedString(item.title, comment: "")
  150. }
  151. }
  152. }
  153. let PDFOfficeMenu = mainMenu?.item(at: 0)?.submenu
  154. let appTarget = KMTools_OC.getAppTarget()
  155. if (appTarget == .DMG) {
  156. PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Check for Updates", comment: ""), action: #selector(checkForUpdates), target: self, at: 1)
  157. }
  158. if let items = PDFOfficeMenu?.items {
  159. for menu in items {
  160. let ranges = menu.title.ranges(of: "PDF Master")
  161. let appTarget = KMTools_OC.getAppTarget()
  162. var appName = "PDF Master"
  163. if (appTarget == .pro) {
  164. appName = "PDF Master Pro"
  165. } else if (appTarget == .DMG) {
  166. // appName = "PDF Master DMG"
  167. appName = "PDF Master"
  168. }
  169. if let _range = ranges.range.first {
  170. menu.title.replaceSubrange(_range, with: appName)
  171. }
  172. }
  173. }
  174. let fileMenu = mainMenu?.item(at: 1)?.submenu
  175. let shareItem: NSMenuItem = NSMenuItem(title: NSLocalizedString("Share", comment: ""), action: nil, target: nil)
  176. fileMenu!.insertItem(shareItem, at: (fileMenu?.items.count)!-1)
  177. shareItem.submenu = NSSharingServicePicker.menu(forSharingItems: [""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
  178. let viewMenu = mainMenu?.item(at: 3)?.submenu
  179. var zoomMenu: NSMenu?
  180. for item in viewMenu!.items {
  181. if (item.title == NSLocalizedString("Zoom", comment: "")) {
  182. zoomMenu = item.submenu
  183. break
  184. }
  185. }
  186. if (zoomMenu != nil) {
  187. for item in zoomMenu!.items {
  188. if (item.title == NSLocalizedString("Zoom In", comment: "")) {
  189. item.keyEquivalent = "+"
  190. item.keyEquivalentModifierMask = [.command]
  191. break
  192. }
  193. }
  194. }
  195. }
  196. @objc func sharePageItemAction(sender: NSMenuItem) {
  197. if ((NSApp.mainWindow?.windowController is KMBrowserWindowController) == false) {
  198. return
  199. }
  200. let windowControler = NSApp.mainWindow?.windowController as! KMBrowserWindowController
  201. let model: CTTabStripModel = windowControler.browser.tabStripModel
  202. if (model.count() <= 0) {
  203. return
  204. }
  205. if (model.activeTabContents().isHome) {
  206. return
  207. }
  208. let document: KMMainDocument = model.activeTabContents() as! KMMainDocument
  209. let represent : NSSharingService = sender.representedObject as! NSSharingService
  210. represent.perform(withItems: [document.fileURL as Any])
  211. }
  212. // MARK: PDF Master Menu
  213. @IBAction func openPreferenceWindow(_ sender: Any) {
  214. KMPreferenceWindowController.shared.showWindow(nil)
  215. }
  216. @objc @IBAction func manageAcctounMenuAction(_ sender: Any) {
  217. if KMLightMemberManager.manager.isLogin() {
  218. KMAccountInfoWindowController.show(window: NSApp.mainWindow!)
  219. }
  220. }
  221. @IBAction func loginMenuItemAction(_ sender: Any) {
  222. // Login & Logout
  223. if KMLightMemberManager.manager.isLogin() {
  224. } else {
  225. KMLoginWindowController.show(window: NSApp.mainWindow!)
  226. }
  227. }
  228. @IBAction func logoutMenuItemAction(_ sender: Any) {
  229. // Login & Logout
  230. if KMLightMemberManager.manager.isLogin() {
  231. KMRequestServerManager.manager.logout { success, result in
  232. if success {
  233. print("登出成功")
  234. }
  235. }
  236. }
  237. }
  238. @objc func showAccount() {
  239. }
  240. @objc func resumePurchase() {
  241. }
  242. // MARK: help Menu
  243. @IBAction func menuItemAction_quickStudy(_ sender: NSMenuItem) -> Void {
  244. KMTools.openQuickStartStudy()
  245. }
  246. @IBAction func menuItemAction_onlineHelp(_ sender: NSMenuItem) -> Void {
  247. KMTools.openFAQWebsite()
  248. }
  249. @IBAction func menuItemAction_morePudact(_ sender: NSMenuItem) -> Void {
  250. KMTools.openMoreProductWebsite()
  251. }
  252. @IBAction func menuItemAction_freePDFTemplate(_ sender: NSMenuItem) -> Void {
  253. KMTools.openFreePDFTemplatesWebsite()
  254. }
  255. @IBAction func menuItemAction_payEmail(_ sender: NSMenuItem) -> Void {
  256. KMEmailSubWindowController().showWindow(nil)
  257. }
  258. @IBAction func menuItemAction_poweredByComPDFKit(_ sender: NSMenuItem) -> Void {
  259. KMTools.openComPDFKitPowerWebsite()
  260. }
  261. @IBAction func menuItemAction_feekback(_ sender: NSMenuItem) -> Void {
  262. KMTools.feekback()
  263. }
  264. @IBAction func menuItemAction_giveFiveStar(_ sender: NSMenuItem) -> Void {
  265. }
  266. // MARK:- DMG
  267. @objc func checkForUpdates(_ sender: NSMenuItem) {
  268. let appTarget = KMTools_OC.getAppTarget()
  269. if (appTarget != .DMG) {
  270. return
  271. }
  272. #if VERSION_DMG
  273. SUUpdater.shared().checkForUpdates(sender)
  274. #endif
  275. }
  276. }
  277. extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
  278. func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  279. let action = menuItem.action
  280. if action == #selector(manageAcctounMenuAction) {
  281. self.updateLoginMenuItem()
  282. return KMLightMemberManager.manager.isLogin()
  283. }
  284. if action == #selector(loginMenuItemAction) {
  285. self.updateLoginMenuItem()
  286. return !KMLightMemberManager.manager.isLogin()
  287. }
  288. if action == #selector(logoutMenuItemAction) {
  289. self.updateLoginMenuItem()
  290. return KMLightMemberManager.manager.isLogin()
  291. }
  292. return true
  293. }
  294. func updateLoginMenuItem() {
  295. let firstItem = NSApp.mainMenu?.item(at: 0)?.submenu
  296. if firstItem != nil {
  297. let item1 = firstItem?.item(withTag: 11)
  298. let item2 = firstItem?.item(withTag: 12)
  299. let item3 = firstItem?.item(withTag: 13)
  300. let item4 = firstItem?.item(withTag: 14)
  301. if KMLightMemberManager.manager.isLogin() {
  302. item1?.title = KMLightMemberManager.manager.info.email
  303. item1?.isHidden = false
  304. item2?.isHidden = true
  305. item3?.isHidden = false
  306. item4?.isHidden = false
  307. } else {
  308. item1?.isHidden = true
  309. item2?.isHidden = false
  310. item3?.isHidden = true
  311. item4?.isHidden = true
  312. }
  313. }
  314. }
  315. @objc func clickOutline(menuItem: NSMenuItem) {
  316. print("更新菜单栏")
  317. }
  318. func menuNeedsUpdate(_ menu: NSMenu) {
  319. print("menuNeedsUpdate")
  320. // menu.removeAllItems()
  321. //
  322. // var item = NSMenuItem()
  323. // item = menu.addItem(withTitle: NSLocalizedString("Insert", comment: ""), action: nil, target: self)
  324. // item.representedObject = row
  325. //
  326. // var subMenu = NSMenu()
  327. // var subitem = NSMenuItem()
  328. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert File", comment: ""), action: #selector(insertPageItemAction), target: self, tag:0)
  329. // subitem.representedObject = row
  330. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert blank page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:1)
  331. // subitem.representedObject = row
  332. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:2)
  333. // subitem.representedObject = row
  334. // item.submenu = subMenu
  335. //
  336. // item = menu.addItem(withTitle: NSLocalizedString("Extract", comment: ""), action: #selector(extractPageItemAction), target: self)
  337. // item.representedObject = row
  338. // item = menu.addItem(withTitle: NSLocalizedString("Delete Page", comment: ""), action: #selector(deletePageItemAction), target: self)
  339. // item.representedObject = row
  340. // item = menu.addItem(withTitle: NSLocalizedString("Page Edit", comment: ""), action: #selector(pageEditItemAction), target: self)
  341. // item.representedObject = row
  342. //
  343. // menu.addItem(NSMenuItem.separator())
  344. //
  345. // item = menu.addItem(withTitle: NSLocalizedString("90 Rotate", comment: ""), action: #selector(rotatePageItemAction), target: self)
  346. // item.representedObject = row
  347. // item = menu.addItem(withTitle: NSLocalizedString("-90 Rotate", comment: ""), action: #selector(leftRotatePageItemAction), target: self)
  348. // item.representedObject = row
  349. //
  350. // menu.addItem(NSMenuItem.separator())
  351. //
  352. // item = menu.addItem(withTitle: NSLocalizedString("copy", comment: ""), action: #selector(copyItemAction), target: self)
  353. // item.representedObject = row
  354. // item = menu.addItem(withTitle: NSLocalizedString("cut", comment: ""), action: #selector(cutItemAction), target: self)
  355. // item.representedObject = row
  356. // item = menu.addItem(withTitle: NSLocalizedString("paste", comment: ""), action: #selector(pastePageItemAction), target: self)
  357. //
  358. // menu.addItem(NSMenuItem.separator())
  359. //
  360. // item = menu.addItem(withTitle: NSLocalizedString("print", comment: ""), action: #selector(printItemAction), target: self)
  361. //
  362. // item = menu.addItem(withTitle: NSLocalizedString("Share", comment: ""), action: nil, target: self)
  363. //
  364. // item.submenu = NSSharingServicePicker.menu(forSharingItems: [self.listView.document.documentURL ?? ""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
  365. // }
  366. }
  367. func menu(_ menu: NSMenu, update item: NSMenuItem, at index: Int, shouldCancel: Bool) -> Bool {
  368. return true
  369. }
  370. }
  371. #if VERSION_DMG
  372. extension AppDelegate : SUUpdaterDelegate {
  373. func updaterWillRelaunchApplication(_ updater: SUUpdater) {
  374. }
  375. func feedURLString(for updater: SUUpdater) -> String? {
  376. #if DEBUG
  377. return "http://test-pdf-pro.kdan.cn:3021/downloads/pdfmasterprocast.xml"
  378. #else
  379. return "https://www.pdfreaderpro.com/downloads/pdfmasterprocast.xml"
  380. #endif
  381. }
  382. func updaterShouldPromptForPermissionToCheck(forUpdates updater: SUUpdater) -> Bool {
  383. return false
  384. }
  385. func upgradeAPP(with updater: SUUpdater) {
  386. let string = "macappstore://apps.apple.com/cn/app/pdf-master-ai-pdf/id6446781258?mt=12"
  387. let url: URL = URL(string: string)!
  388. NSWorkspace.shared.open(url)
  389. }
  390. func upgradeButtonString(for updater: SUUpdater) -> String {
  391. return NSLocalizedString("PDF Master", comment: "")
  392. }
  393. }
  394. #endif