Browse Source

AI - 修复copy粘贴板为nil时崩溃

wanjun 1 year ago
parent
commit
2abbc0c3d5

+ 7 - 3
PDF Office/PDF Master/Class/Home/ViewController/KMAIRewritingVC.swift

@@ -244,9 +244,13 @@ class KMAIRewritingVC: NSViewController {
         if self.state == .AIRewriting {
             if (self.aiRewritingStr.count > 0) && (self.aiRewritingResultStr.count > 0) {
                 let pasteboard = NSPasteboard.general
-                if pasteboard.string(forType: .string)!.count > 0 {
-                    if pasteboard.string(forType: .string)! == self.aiRewritingResultStr {
-                        self.uiState = .CanCopy
+                if pasteboard.string(forType: .string) != nil {
+                    if pasteboard.string(forType: .string)!.count > 0 {
+                        if pasteboard.string(forType: .string)! == self.aiRewritingResultStr {
+                            self.uiState = .CanCopy
+                        } else {
+                            self.uiState = .Copyed
+                        }
                     } else {
                         self.uiState = .Copyed
                     }