Selaa lähdekoodia

Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0

tangchao 1 viikko sitten
vanhempi
commit
1280d97647

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

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

@@ -360,23 +360,24 @@ NSPopoverDelegate>
             totalWidth+=CGRectGetWidth(self.officeButton.bounds);
             totalWidth+=4;
         }
+#else
+        self.officeButton.hidden = YES;
+        self.officeImg.hidden = YES;
 #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;
-                    }];
-                }
+                    }
+                }];
             }
         }
         
@@ -411,6 +412,12 @@ NSPopoverDelegate>
             }
         }
         
+        buttonWidth = CGRectGetMaxX(self.button.frame);
+        NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
+        if (fabs(buttonWidth-btnRect.size.width)>50) {
+            buttonWidth = btnRect.size.width + 10;
+        }
+        
         self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap);
         CGRect rect = self.button.frame;
         self.bgImg.frame = rect;

+ 6 - 1
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -442,6 +442,7 @@ class KMMemberCenterManager: NSObject {
                 var uniqueSn = ""
                 var deviceName = ""
                 var id = ""
+                var model = ""
 
                 if let token = dict["device_id"] {
                     device_id = token as? String ?? ""
@@ -456,11 +457,15 @@ class KMMemberCenterManager: NSObject {
                     deviceName = token as? String ?? ""
                 }
                 
+                if let token = dict["model"] {
+                    model = token as? String ?? ""
+                }
+                
                 if let token = dict["id"] {
                     id = token as? String ?? ""
                 }
                 
-                let list = KMMemberDeviceList(deviceId: device_id, productId: productId, uniqueSn: uniqueSn, appId: "", deviceName: deviceName)
+                let list = KMMemberDeviceList(deviceId: device_id, productId: productId, uniqueSn: uniqueSn, appId: "", device_model:model, deviceName: deviceName)
                 list.id = id
                 deviceLists.append(list)
             }

+ 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

+ 2 - 9
PDF Office/PDF Master/MemberCenter/ViewModel/KMSignUpViewModel.swift

@@ -295,7 +295,7 @@ class KMSignUpViewModel: ObservableObject {
                 
                 self.timer?.cancel()
                 self.sendContent = NSLocalizedString("Resend", tableName: "MemberCenterLocalizable", comment: "")
-
+                
                 KMMemberInfo.shared.avatarImage = nil
             } else {
                 if(resultDict.code == 305) {
@@ -326,19 +326,12 @@ class KMSignUpViewModel: ObservableObject {
                     }
                 } else {
                     callback?(false)
-                    
                     print("错误信息:%@", msg as Any)
-                    DispatchQueue.main.async {
-                        let alert = NSAlert()
-                        alert.messageText = NSLocalizedString(msg!, comment: "")
-                        alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                        let response = alert.runModal()
+                    KMMemberCenterManager.showAlert(code: .init(rawValue: resultDict.code), message: resultDict.msg) { response, _ in
                         if response == .alertFirstButtonReturn {
                             if(resultDict.code == 317) {
                                 self.signUpState = .verificationCode
                                 self.countDown(type: .login, callback: nil)
-                            } else {
-                                KMMemberCenterManager.showAlert(code: .init(rawValue: resultDict.code), message: resultDict.msg, callback: nil)
                             }
                         }
                     }

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

+ 5 - 4
PDF Office/PDF Master/MemberCenter/WindowsController/KMMemberCenterWindowController.swift

@@ -150,14 +150,15 @@ class KMMemberCenterWindowController: NSWindowController {
         
         for i in 0 ..< deviceList_Result.count {
             let device = deviceList_Result[i]
+            let name = String(format: "%@(%@)",device.deviceName ?? "PDF Reader Pro User for ",device.device_model ?? " Device Name")
             if i == 0 {
-                device1Label.stringValue = device.deviceName ?? "PDF Reader Pro User"
+                device1Label.stringValue = name
             } else if i == 1 {
-                device2Label.stringValue = device.deviceName ?? "PDF Reader Pro User"
+                device2Label.stringValue = name
             }  else if i == 2 {
-                device3Label.stringValue = device.deviceName ?? "PDF Reader Pro User"
+                device3Label.stringValue = name
             } else if i == 3 {
-                device4Label.stringValue = device.deviceName ?? "PDF Reader Pro User"
+                device4Label.stringValue = name
             }
         }
         let maxDeviceNum = memberCenterdeviceResult.maxDeviceNum ?? 1