Selaa lähdekoodia

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

wangshuai 1 viikko sitten
vanhempi
commit
237395a5a9

+ 7 - 1
PDF Office/PDF Master/Class/AIInfo/KMAIRequestServerManager.swift

@@ -438,6 +438,9 @@ class ResultWrapper: NSObject {
                 }
                 var result_bool: Bool = true
                 var message: String = ""
+                if let value = jsonObject!["message"]{
+                    message = value as! String
+                }
                 
                 let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
                 if code == 200 {
@@ -456,7 +459,7 @@ class ResultWrapper: NSObject {
                         complete(ResultWrapper(success: true, content: ossDownUrl as! String))
                     }
                 } else {
-                    complete(ResultWrapper(success: false, content: ""))
+                    complete(ResultWrapper(success: false, content: message))
                 }
             } else {
                 complete(ResultWrapper(success: false, content: ""))
@@ -916,6 +919,9 @@ class KMAIRequestServer {
                 var result_bool: Bool = true
                 
                 var message: String = ""
+                if let value = jsonObject!["message"]{
+                    message = value as! String
+                }
                 if let string = jsonObject!["data"] {
                     let dataDic = jsonObject!["data"] as? NSDictionary ?? [:]
                     if let dataStr = dataDic["content"] {

+ 14 - 0
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMToolbarItemPopViewController.swift

@@ -10,6 +10,20 @@ import Cocoa
 class KMToolbarItemPopViewController: NSViewController{
     @IBOutlet var toolbarHelpTipLabel: NSTextField!
     
+    @IBOutlet weak var topConst: NSLayoutConstraint!
+    @IBOutlet weak var leftConst: NSLayoutConstraint!
+    @IBOutlet weak var rightConst: NSLayoutConstraint!
+    @IBOutlet weak var bottomConst: NSLayoutConstraint!
+    
+    var contentInset: NSEdgeInsets = .init(top: 5, left: 5, bottom: 5, right: 5) {
+        didSet {
+            topConst.constant = contentInset.top
+            leftConst.constant = contentInset.left
+            rightConst.constant = contentInset.right
+            bottomConst.constant = contentInset.bottom
+        }
+    }
+    
     convenience init() {
         self.init(nibName: "KMToolbarItemPopViewController", bundle: nil)
         

+ 7 - 3
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMToolbarItemPopViewController.xib

@@ -1,14 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarItemPopViewController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
+                <outlet property="bottomConst" destination="pgE-Je-WDF" id="nbE-mW-Vj6"/>
+                <outlet property="leftConst" destination="TC0-WL-8ct" id="1ub-0I-SsO"/>
+                <outlet property="rightConst" destination="Vvb-Qb-5dD" id="hCZ-bs-ehU"/>
                 <outlet property="toolbarHelpTipLabel" destination="Anw-6R-RbF" id="Ra3-8V-bZf"/>
+                <outlet property="topConst" destination="I9x-u0-py7" id="z4m-m7-8Sg"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
         </customObject>
@@ -18,7 +22,7 @@
             <rect key="frame" x="0.0" y="0.0" width="10" height="24"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
-                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Anw-6R-RbF">
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Anw-6R-RbF">
                     <rect key="frame" x="3" y="5" width="4" height="14"/>
                     <constraints>
                         <constraint firstAttribute="width" relation="lessThanOrEqual" constant="300" id="jFH-vi-FyE"/>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Tool.m

@@ -136,7 +136,7 @@
                 area &= ~CPDFLinkArea;
             
             NSRect rect = CPDFListViewRectFromCenterAndSize(p, CGSizeMake(80, 100));
-            CPDFSelection *sel = [page selectionForRect:rect];
+//            CPDFSelection *sel = [page selectionForRect:rect];
             if ([self isEditWithCurrentFreeText:self.activeAnnotation] && [[self.activeAnnotation page] isEqual:page] && NSPointInRect(p, [self.activeAnnotation bounds])) {
                 area = CPDFTextFieldArea;
             } else if ((area & CReadingBarArea) == 0) {

+ 11 - 3
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -824,13 +824,15 @@ import Cocoa
                         .map { $0.trimmingCharacters(in: .whitespaces) }
 
                     if  userScenarioType == .pro_type5 {
-                        if(platformsArray.contains("mac")) { //购买了mac
+                        if(platformsArray.contains("mac") && KMMemberInfo.shared.vip_levels == "3") { //购买了mac且高级
                             return true
                         }
                     } else if userScenarioType == .pro_type1 ||
                               userScenarioType == .pro_type2 ||
                               userScenarioType == .pro_type4  {
-                        return true
+                        if(platformsArray.contains("mac") && KMMemberInfo.shared.vip_levels == "3") { //购买了mac
+                            return true
+                        }
                     }
                     return false
                 }
@@ -871,11 +873,17 @@ import Cocoa
 #else
     // AppStore 付费版
         if KMMemberInfo.shared.isLogin {
-            if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
+            if KMMemberInfo.shared.aiPoint > 0 {
+                return true
+            }
+            if AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes > 0 {
                 return true
             }
             return false
         } else {
+            if AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes > 0 {
+                return true
+            }
             return false
         }
 #endif

+ 55 - 1
PDF Office/PDF Master/MemberCenter/View/KMSignUpView.swift

@@ -42,6 +42,8 @@ class KMSignUpView: KMBaseXibView {
     private var viewModel = KMSignUpViewModel()
     private var cancellables = Set<AnyCancellable>()
     
+    private var popOver_: NSPopover?
+    
     convenience init(model: KMSignUpViewModel, superView: NSView) {
         self.init(frame: superView.bounds)
         viewModel = model
@@ -308,6 +310,39 @@ class KMSignUpView: KMBaseXibView {
         }
     }
     
+    private func _showPop() {
+        guard let _ = self.window else {
+            return
+        }
+        
+        if (self.popOver_ != nil) {
+            return
+        }
+        let popViewController = KMToolbarItemPopViewController()
+        self.popOver_ = NSPopover()
+        self.popOver_?.contentViewController = popViewController
+        self.popOver_?.animates = false
+        self.popOver_?.behavior = .semitransient
+        self.popOver_?.contentSize = popViewController.view.frame.size
+        self.popOver_?.delegate = self
+
+        // 0.8
+        var color = NSColor(hex: "#273C62").withAlphaComponent(1)
+        if KMAppearance.isDarkMode() {
+            color = NSColor(hex: "#4E7FDB").withAlphaComponent(1)
+        }
+        popViewController.view.wantsLayer = true
+        popViewController.view.layer?.backgroundColor = color.cgColor
+        self.popOver_?.setBackgroundColor(color)
+        popViewController.toolbarHelpTipLabel.textColor = .white
+        popViewController.toolbarHelpTipLabel.font = .SFProTextRegularFont(13)
+        
+        popViewController.contentInset  = .init(top: 12, left: 8, bottom: 12, right: 8)
+        
+        popViewController.updateWithHelpTip(helpTip: NSLocalizedString("Please agree and check the agreement first.", tableName: "MemberCenterLocalizable", comment: ""))
+        self.popOver_?.show(relativeTo: NSMakeRect(0, 0, 0, 12), of: privacyCheckButton, preferredEdge: .maxY)
+    }
+    
     // MARK: Bind Method
     
     func bindViewModel() -> Void {
@@ -327,6 +362,7 @@ class KMSignUpView: KMBaseXibView {
             .receive(on: RunLoop.main)
             .sink { [weak self] newValue in
                 self?.checkStateChange(button: self?.privacyCheckButton, state: newValue)
+                self?.popOver_?.close()
             }
             .store(in: &cancellables)
         viewModel.$signUpState
@@ -386,8 +422,18 @@ class KMSignUpView: KMBaseXibView {
                 }
             }
             .store(in: &cancellables)
+        
+        viewModel.$privacyPopShow
+            .receive(on: RunLoop.main)
+            .sink { [weak self] newValue in
+                if newValue {
+                    KMMainThreadExecute {
+                        self?._showPop()
+                    }
+                }
+            }
+            .store(in: &cancellables)
     }
-    
         
     // MARK: Action Method
     
@@ -501,3 +547,11 @@ extension KMSignUpView: NSTextFieldDelegate {
         resetTextFileData()
     }
 }
+
+extension KMSignUpView: NSPopoverDelegate {
+    func popoverDidClose(_ notification: Notification) {
+        if let data = self.popOver_?.isEqual(to: notification.object), data {
+            self.popOver_ = nil
+        }
+    }
+}

+ 15 - 0
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -738,6 +738,21 @@ class KMProductModel: ObservableObject {
                 if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isSubscribed {
                     isSubscribed = true
                 }
+            } else if productId == "com.pdfreaderpro.mac.advanced_add_devices_all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription-standard-upgrade"
+                if IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac.advanced_add_devices_all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription-single-upgrade"
+                if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription-multi-upgrade"
+                if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.isSubscribed {
+                    isSubscribed = true
+                }
             }
             if isSubscribed {
                 KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in

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

@@ -41,6 +41,11 @@ class KMSignUpViewModel: ObservableObject {
      是否同意隐私权限
      */
     @Published var privacyState: Bool = false
+    /**
+     隐私权限显示Pop提示
+     */
+    @Published var privacyPopShow: Bool = false
+    
     /**
      登录界面是验证码验证还是邮箱验证
      */
@@ -253,19 +258,9 @@ class KMSignUpViewModel: ObservableObject {
             code = password
         }
         if !privacyState {
-            DispatchQueue.main.async {
-                
-                let alert = NSAlert()
-                alert.messageText = NSLocalizedString("Please agree and check the agreement first.", tableName: "MemberCenterLocalizable", comment: "")
-                alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-                //            alert.beginSheetModal(for: NSApp.mainWindow!)
-                let result = alert.runModal()
-                if (result == .alertFirstButtonReturn) {
-                    self.privacyState = true
-                }
-                
-                callback?(nil)
-            }
+            callback?(nil)
+            
+            self.privacyPopShow = true
             return
         }
         KMMemberCenterManager.manager.emailLogin(email: email, code: code, type: signUpState) { [weak self] success, wrapper  in
@@ -440,8 +435,7 @@ class KMSignUpViewModel: ObservableObject {
             if success {
                 print("验证邮箱成功")
             } else {
-                self.emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
-                
+//                self.emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
                 KMMemberCenterManager.showAlert(code: .init(rawValue: wrapper?.code ?? 0), message: wrapper?.msg, callback: nil)
             }
         }

+ 3 - 2
PDF Office/PDF Master/MemberCenter/ViewModel/KMUserInfoVCModel.swift

@@ -192,8 +192,9 @@ class KMUserInfoVCModel: ObservableObject {
                 }
             }
         } else {
-            if (KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_status == 1) || (KMMemberInfo.shared.ai_status == 1 && KMMemberInfo.shared.ai_paymentModel == "1") {
-                // 订阅用户提示退订
+            if (KMMemberInfo.shared.vip_payType == 1) ||
+                (KMMemberInfo.shared.ai_payType == 1) {
+                // 在续订中用户提示退订
                 NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
                 KMMemberPromptWC.shared.showWindow(nil)
                 KMMemberPromptWC.shared.tipType = .unsubscribe

+ 1 - 1
PDF Office/PDF Master/MemberCenter/WindowsController/KMMemberCenterWindowController.swift

@@ -150,7 +150,7 @@ 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")
+            let name = String(format: "%@%@(%@)","PDF Reader Pro for ",device.device_model ?? "PDF Reader Pro User",device.deviceName ?? " Device Name")
             if i == 0 {
                 device1Label.stringValue = name
             } else if i == 1 {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 5 - 3
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift