Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

wangshuai 3 months ago
parent
commit
1456a03a7a

+ 5 - 3
PDF Office/PDF Master/AppDelegate.swift

@@ -234,15 +234,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
         
         NotificationCenter.default.addObserver(self, selector: #selector(deviceActivateStatusChangeNotification), name: NSNotification.Name(rawValue: "kDeviceActivateNotification"), object: nil)
         
-        initDidFinish()
+//        initDidFinish()
     }
     
     func initDidFinish() {
 #if VERSION_DMG
-        DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
+        DispatchQueue.main.async {
+//        DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
             let memberInfo: KMMemberInfo = KMMemberInfo.shared
             if KMMemberInfo.shared.isMemberAllFunction == false && memberInfo.isLogin == false {
-                self?.checkLoginAndPrompt()
+                self.checkLoginAndPrompt()
             }
         }
 #endif
@@ -516,6 +517,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
                 }
             }
         }
+        initDidFinish()
     }
     
     func refreshAIMenuItemInfo() -> Void {

+ 7 - 11
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -134,7 +134,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     
     private var timer: Timer?
     private var pollCount = 0
-    private let maxPolls = 18
+    private let maxPolls = 36
     private let interval: TimeInterval = 5.0
 
     private var _activityAlertViewController: KMActivityALertViewController?
@@ -1358,7 +1358,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     private func openWebView(_ urlPath: String) -> Void {
         DispatchQueue.main.async { [weak self] in
             guard let self = self else { return }
+            
             self.pollCount = 0
+            self.startPolling()
             self.embeddedPaymentPopWC = KMEmbeddedPaymentPopWC.currentFirstTrialWC(urlPath)
             if self.paymentMethod == .paddle {
                 self.embeddedPaymentPopWC?.isPaddle = true
@@ -1369,7 +1371,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             self.embeddedPaymentPopWC?.callback = { isClose in
             }
         }
-        startPolling()
     }
     
     private func convertBase64StringToNSImage(base64String: String) -> NSImage? {
@@ -1399,13 +1400,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
 
             self.qrCodeImageView.image = img
             
-            self.startPolling()
-        }
-    }
-    
-    private func pollingResult() -> Void {
-        DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
-            guard let self = self else { return }
+            self.pollCount = 0
             self.startPolling()
         }
     }
@@ -1552,8 +1547,9 @@ extension KMPurchaseEmbeddedWindowController: NSTextFieldDelegate {
 
 extension KMPurchaseEmbeddedWindowController: NSWindowDelegate {
     func windowWillClose(_ notification: Notification) {
-        if orderID != "" {
-            pollingResult()
+        if let data = self.window?.isEqual(to: notification.object), data {
+            // 窗口关闭,关闭轮询
+            stopPolling()
         }
         if self.embeddedPaymentPopWC != nil {
             self.embeddedPaymentPopWC?.close()

+ 1 - 1
PDF Office/PDF Master/Class/Purchase/DMG/Window/KMPurchaseSuccessWindowController.swift

@@ -94,7 +94,7 @@ class KMPurchaseSuccessWindowController: KMBaseWindowController {
             .foregroundColor: NSColor(named: "42464D") ?? NSColor.black as Any,
             .font: font,
             .paragraphStyle: paragraphStyle2
-        ], range: (fullString as NSString).range(of: fullString2))
+        ], range: (fullString2 as NSString).range(of: fullString2))
         attributedString2.addAttributes([
             .foregroundColor: linkColor,
             .link: "action://checkBenefit",