Forráskód Böngészése

【存储文件】拖拽图片到首页打开,文档不应该自动存在Application Support路径下

liujiajie 6 hónapja
szülő
commit
45d30a7e5d

+ 12 - 2
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -600,8 +600,18 @@ extension KMHomeViewController {
         } else {
         }
         if success {
-            NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { _, _, _ in
-                
+            NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { document, isOpened, error in
+                if error != nil {
+                    NSApp.presentError(error!)
+                } else {
+                    if FileManager.default.fileExists(atPath: filePath) {
+                        try? FileManager.default.removeItem(atPath: filePath)
+                    }
+                    if document is KMMainDocument {
+                        let newDocument = document
+                        (newDocument as! KMMainDocument).isNewCreated = true
+                    }
+                }
             }
         }
     }