소스 검색

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

liujiajie 6 달 전
부모
커밋
e965e3b3fe
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12 2
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

+ 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
+                    }
+                }
             }
         }
     }