Explorar el Código

【会员系统】AI相关问题修正

niehaoyu hace 3 meses
padre
commit
b6a2c9e68f

+ 5 - 1
PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/Views/AIHeaderView/AIHeaderView.swift

@@ -81,7 +81,11 @@ class AIHeaderView: NSView, NibLoadable {
             embeddedWC.showWindow(self)
             embeddedWC.window?.center()
 #else
-            AIPurchaseWindowController.currentWC().showWindow(nil)
+            if KMMemberInfo.shared.aiPoint > 0 {
+                
+            } else {
+                AIPurchaseWindowController.currentWC().showWindow(nil)
+            }
 #endif
         }
         

+ 6 - 2
PDF Office/PDF Master/Class/AIInfo/AIUserInfoController/AIUserInfoController.swift

@@ -270,8 +270,12 @@ import Cocoa
         }
         if KMMemberInfo.shared.isLogin == false {
             KMLoginWindowsController.shared.openWindow() { success in
-                if success {
-                    callBack(self)
+                if KMMemberInfo.shared.aiPoint > 0 {
+                    
+                } else {
+                    if success {
+                        callBack(self)
+                    }
                 }
             }
             return

+ 4 - 4
PDF Office/PDF Master/Class/AIInfo/KMAIRequestServerManager.swift

@@ -94,7 +94,7 @@ class ResultWrapper: NSObject {
             }
         } else if state == .extractSummaryFile {    // 提取摘要
             let aiInfo: AIInfo = AIInfoManager.default().aiInfo
-            if aiInfo.totalToken - aiInfo.usedTimes > 1 {
+            if aiInfo.totalToken - aiInfo.usedTimes > 0 {
                 extractSummaryFile(file: content, complete: complete)
             } else {
                 memberExtractSummaryFile(file: content, complete: complete)
@@ -299,7 +299,7 @@ class ResultWrapper: NSObject {
     private func memberAITranslationFileUpload(file: String, complete: @escaping KMRequestServerComplete) {
         let token: String = KMMemberInfo.shared.access_token
         if token == "" {
-            return
+            complete(ResultWrapper(success: false, content: "unknown error"))
         }
         
         let urlString = AIInfoConfig().memberAIActionURL + "/member-system-website/v1/translate/fileUpload"
@@ -576,7 +576,7 @@ class ResultWrapper: NSObject {
     private func aiRewriting(content: String, state: KMAIRewritingState, complete: @escaping KMRequestServerComplete) {
         let aiInfo: AIInfo = AIInfoManager.default().aiInfo
         
-        if aiInfo.totalToken - aiInfo.usedTimes > 1 {
+        if aiInfo.totalToken - aiInfo.usedTimes > 0 {
             var urlString = AIInfoConfig().aiActionURL + "/api/AI/rewrite"
             if state == .correctTypos {
                 urlString = AIInfoConfig().aiActionURL + "/api/AI/correctTypos"
@@ -625,7 +625,7 @@ class ResultWrapper: NSObject {
     func aiMemberRewriting(content: String, state: KMAIRewritingState, complete: @escaping KMRequestServerComplete) {
         let token: String = KMMemberInfo.shared.access_token
         if token == "" {
-            return
+            complete(ResultWrapper(success: false, content: "unknown error"))
         }
         var urlString = AIInfoConfig().memberAIActionURL + "/member-system-website/api/rewrite"
         if state == .correctTypos {

+ 13 - 15
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationMessageViewController.m

@@ -361,22 +361,20 @@ NSPopoverDelegate>
             totalWidth+=4;
         }
 #endif
-        if (type == KMUserScenarioTypeLite_type1 ||
-            type == KMUserScenarioTypeLite_type3 ||
-            type == KMUserScenarioTypeLite_type7 ||
-            type == KMUserScenarioTypeLite_type11) {
-            if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) {
-                if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) {
-                    KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject;
-                    NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name];
-                    self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)];
-                    
-                    NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
-                    __weak typeof(self)weakSelf = self;
-                    weakSelf.bgImg.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
+ 
+        if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) {
+            if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) {
+                KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject;
+                NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name];
+                self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)];
+                
+                NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
+                __weak typeof(self)weakSelf = self;
+                NSImage * img = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
+                    if (image != nil) {
                         weakSelf.bgImg.image = image;
-                    }];
-                }
+                    }
+                }];
             }
         }
         

+ 5 - 1
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -1110,7 +1110,11 @@ import Cocoa
             } else {
                 KMLoginWindowsController.shared.openWindow() { success in
                     if success {
-                        AIPurchaseWindowController.currentWC().showWindow(nil)
+                        if KMMemberInfo.shared.aiPoint > 0 {
+                            
+                        } else {
+                            AIPurchaseWindowController.currentWC().showWindow(nil)
+                        }
                     }
                 }
                 return false

+ 5 - 3
PDF Office/PDF Master/MemberCenter/WindowsController/KMLoginWindowsController.swift

@@ -111,9 +111,11 @@ class KMLoginWindowsController: NSWindowController {
                     let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: content?.image, highlight: false))
                     let _ = KMAdvertisementImage.imageWithURL(url: url) { [weak self] image in
                         guard let self = self else { return }
-                        self.leftImageView.image = image
-                        self.leftsubLabel.isHidden = true
-                        self.leftsubImageView.isHidden = true
+                        if image.isValid {
+                            self.leftImageView.image = image
+                            self.leftsubLabel.isHidden = true
+                            self.leftsubImageView.isHidden = true
+                        }
                     }
                 }
             }