Ver Fonte

【转档】首页转档补充权限弹窗阻挡

tangchao há 1 ano atrás
pai
commit
ad4b3505f4

+ 1 - 56
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -821,62 +821,7 @@ extension KMHomeViewController {
         }
     }
     
-    internal func showConvertWindow(type: KMPDFConvertType) {
-        Task { @MainActor in
-            if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-                let _ =  KMComparativeTableViewController.show(window: self.view.window!, .convert)
-                return
-            }
-            
-            NSOpenPanel.km_secure_openPanel_success(window: self.view.window!) { url, password in
-                if (url.path.isPDFValid() == false) {
-                    let alert = NSAlert()
-                    alert.alertStyle = .critical
-                    alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
-                    alert.runModal()
-                    return
-                }
-                var windowController: KMConvertBaseWindowController?
-                if (type == .word) { /// Word
-                    windowController = KMConvertWordWindowController()
-                } else if (type == .excel) {
-                    windowController = KMConvertExcelWindowController()
-                } else if (type == .ppt || type == .rtf || type == .html || type == .text) {
-                    windowController = KMConvertPPTsWindowController()
-                    if (type == .ppt) {
-                        windowController?.subType = 1
-                    } else if (type == .rtf) {
-                        windowController?.subType = 2
-                    } else if (type == .html) {
-                        windowController?.subType = 3
-                    } else if (type == .text) {
-                        windowController?.subType = 4
-                    }
-                } else if (type == .csv) {
-                    windowController = KMConvertCSVWindowController()
-                } else if (type == .image) {
-                    windowController = KMConvertImageWindowController()
-                }
-                
-                let model = KMDocumentModel(url: url)
-                if (password != nil) {
-                    let _ = model.unlock(password!)
-                }
-                windowController?.documentModel = model
-
-                windowController?.itemClick = { [weak self] index in
-                    if (self?.currentWindowController == nil) {
-                        return
-                    }
-                    self?.view.window?.endSheet((self?.currentWindowController?.window)!)
-                    self?.currentWindowController = nil
-                }
-
-                self.view.window?.beginSheet((windowController?.window)!)
-                self.currentWindowController = windowController
-            }
-        }
-    }
+    
     
     // MARK: PDF Tools
     

+ 79 - 0
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+UI.swift

@@ -171,6 +171,85 @@ extension KMHomeViewController {
             break
         }
     }
+    
+    func showConvertWindow(type: KMPDFConvertType) {
+        Task { @MainActor in
+            if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
+                let _ =  KMComparativeTableViewController.show(window: self.view.window!, .convert)
+                return
+            }
+            if await (KMLightMemberManager.manager.canPayFunction() == false) {
+                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!) { isSubscribeSuccess, isWaterMarkExport, isClose in
+                    if (isClose) {
+                        return
+                    }
+                    self.km_secure_openPanel_convert(type: type)
+                }
+                return
+            }
+            
+            self.km_secure_openPanel_convert(type: type)
+        }
+    }
+    
+    func km_secure_openPanel_convert(type: KMPDFConvertType) {
+        DispatchQueue.main.async {
+            NSOpenPanel.km_secure_openPanel_success(window: self.view.window!) { url, password in
+                if (url.path.isPDFValid() == false) {
+                    let alert = NSAlert()
+                    alert.alertStyle = .critical
+                    alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
+                    alert.runModal()
+                    return
+                }
+                
+                self._showConvertWindow(type: type, url: url, password: password)
+            }
+        }
+    }
+    
+    // MARK: - Private Methods
+    
+    fileprivate func _showConvertWindow(type: KMPDFConvertType, url: URL, password: String? = nil) {
+        var windowController: KMConvertBaseWindowController?
+        if (type == .word) { /// Word
+            windowController = KMConvertWordWindowController()
+        } else if (type == .excel) {
+            windowController = KMConvertExcelWindowController()
+        } else if (type == .ppt || type == .rtf || type == .html || type == .text) {
+            windowController = KMConvertPPTsWindowController()
+            if (type == .ppt) {
+                windowController?.subType = 1
+            } else if (type == .rtf) {
+                windowController?.subType = 2
+            } else if (type == .html) {
+                windowController?.subType = 3
+            } else if (type == .text) {
+                windowController?.subType = 4
+            }
+        } else if (type == .csv) {
+            windowController = KMConvertCSVWindowController()
+        } else if (type == .image) {
+            windowController = KMConvertImageWindowController()
+        }
+        
+        let model = KMDocumentModel(url: url)
+        if (password != nil) {
+            let _ = model.unlock(password!)
+        }
+        windowController?.documentModel = model
+        
+        windowController?.itemClick = { [weak self] index in
+            if (self?.currentWindowController == nil) {
+                return
+            }
+            self?.view.window?.endSheet((self?.currentWindowController?.window)!)
+            self?.currentWindowController = nil
+        }
+        
+        self.view.window?.beginSheet((windowController?.window)!)
+        self.currentWindowController = windowController
+    }
 }
 
 // MARK: - NSSplitViewDelegate