Ver código fonte

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

tangchao 1 ano atrás
pai
commit
9fa7a291f4

+ 6 - 5
PDF Office/PDF Master/Class/KMLightMember/Controller/AccountInfo/KMAccountInfoWindowController.swift

@@ -94,15 +94,16 @@ class KMAccountInfoWindowController: NSWindowController {
         
         self.accountInfoView.logOutAction = { view in
             print("登出")
-            KMLightMemberManager.manager.logOut()
-            accountInfoMainWindow?.endSheet(view.window!)
-            view.window?.close()
             KMRequestServerManager.manager.logout { success, result in
                 if success {
-                    accountInfoController = nil
-                    accountInfoMainWindow = nil
+                    print("登出成功")
                 }
             }
+            KMLightMemberManager.manager.logOut()
+            accountInfoMainWindow?.endSheet(view.window!)
+            view.window?.close()
+            accountInfoController = nil
+            accountInfoMainWindow = nil
         }
         
         self.accountInfoView.cancellationAction = { [unowned self] view in

+ 8 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/Presenter/KMRegisterPresenter.swift

@@ -60,8 +60,8 @@ extension KMRegisterPresenter: KMRegisterPresenterProtocol {
     
     func refreshNextState() {
         let isEmailSuccess = KMRegisterPresenter.verificationEmail(self.model.email)
-        let isPasswordSuccess = self.model.password.count >= 6 && self.model.password.count <= 24
-        let isRePasswordSuccess = self.model.rePassword.count >= 6 && self.model.rePassword.count <= 24
+        let isPasswordSuccess = self.model.password.count >= 6 && self.model.password.count <= 24 && !self.model.password.contains(" ")
+        let isRePasswordSuccess = self.model.rePassword.count >= 6 && self.model.rePassword.count <= 24 && !self.model.rePassword.contains(" ")
         
         if isEmailSuccess || self.model.email.count == 0 {
             self.model.emailAlertType = .unknown
@@ -76,7 +76,9 @@ extension KMRegisterPresenter: KMRegisterPresenterProtocol {
             self.model.passwordAlertType = .EXCEPTION_MSG_PASSWORD_SIZE_MIN
         } else if self.model.password.count > 24 {
             self.model.passwordAlertType = .EXCEPTION_MSG_PASSWORD_SIZE_MAX
-        } else  {
+        } else if self.model.password.contains(" ") {
+            self.model.passwordAlertType = .EXCEPTION_MSG_PASSWORD_CONTAIN_EMRTY
+        } else {
             self.model.passwordAlertType = .unknown
         }
         
@@ -84,8 +86,10 @@ extension KMRegisterPresenter: KMRegisterPresenterProtocol {
             self.model.rePasswordAlertType = .unknown
         } else if self.model.rePassword.count < 6 && self.model.rePassword.count != 0 {
             self.model.rePasswordAlertType = .EXCEPTION_MSG_PASSWORD_SIZE_MIN
-        } else if self.model.password.count > 24 {
+        } else if self.model.rePassword.count > 24 {
             self.model.rePasswordAlertType = .EXCEPTION_MSG_PASSWORD_SIZE_MAX
+        } else if self.model.rePassword.contains(" ") {
+            self.model.rePasswordAlertType = .EXCEPTION_MSG_PASSWORD_CONTAIN_EMRTY
         } else {
             self.model.rePasswordAlertType = .unknown
         }

+ 1 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMLightNoNetworkView.xib

@@ -5,7 +5,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMLightNoNetworkView" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMLightNoNetworkView" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="subtitleLabel" destination="uX9-qS-yeu" id="VD3-VH-B2K"/>
                 <outlet property="titleLabel" destination="fMD-gC-2Kk" id="AVZ-R6-AOM"/>

+ 19 - 0
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMLoginInputPasswordView.swift

@@ -224,6 +224,25 @@ extension KMLoginInputPasswordView: NSTextFieldDelegate {
             self.presenter.changePassword(string: textField!.stringValue)
         }
     }
+    
+    func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
+        switch commandSelector {
+        case #selector(NSResponder.insertNewline(_:)):
+            if let inputView = control as? NSTextField {
+                //当当前TextField按下enter
+                if (textView.string == self.model.password) {
+                    print("按下 enter")
+                    
+                    if self.model.canNext {
+                        self.loginButtonAction(self.loginButton)
+                    }
+                }
+            }
+            return true
+        default:
+            return false
+        }
+    }
 }
 
 extension KMLoginInputPasswordView: NSTextViewDelegate {

+ 4 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMLoginInputPasswordView.xib

@@ -5,7 +5,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMLoginInputPasswordView" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMLoginInputPasswordView" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="alertView" destination="ff5-IQ-deE" id="WgJ-Fd-6aV"/>
                 <outlet property="describeLable" destination="v1H-K3-lim" id="ikz-9Z-zWf"/>
@@ -54,7 +54,7 @@
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="fBp-l6-nG8">
                                     <rect key="frame" x="0.0" y="4" width="262" height="32"/>
                                     <subviews>
-                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="6Vy-iH-Gtq" customClass="FocusAwareTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="6Vy-iH-Gtq" customClass="FocusAwareTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="5" width="222" height="22"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="22" id="opq-pU-Cxs"/>
@@ -68,7 +68,7 @@
                                                 </allowedInputSourceLocales>
                                             </textFieldCell>
                                         </textField>
-                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jtV-xD-84b" customClass="FocusAwareSecureTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jtV-xD-84b" customClass="FocusAwareSecureTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="6" width="222" height="20"/>
                                             <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="border" usesSingleLineMode="YES" id="UlY-us-n8s">
                                                 <font key="font" metaFont="system"/>
@@ -204,7 +204,7 @@ DQ
                         <constraint firstItem="cWe-4o-FbE" firstAttribute="top" secondItem="Fiq-Tb-FhO" secondAttribute="bottom" constant="8" id="eM0-r7-erm"/>
                     </constraints>
                 </customView>
-                <customView translatesAutoresizingMaskIntoConstraints="NO" id="ff5-IQ-deE" customClass="KMLightMemberAlertView" customModule="PDF_Office" customModuleProvider="target">
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="ff5-IQ-deE" customClass="KMLightMemberAlertView" customModule="PDF_Master" customModuleProvider="target">
                     <rect key="frame" x="0.0" y="0.0" width="326" height="48"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="48" id="jHg-Mk-TWh"/>

+ 19 - 0
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMLoginView.swift

@@ -145,6 +145,25 @@ extension KMLoginView: NSTextFieldDelegate {
             self.alertLabel.stringValue = ""
         }
     }
+    
+    func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
+        switch commandSelector {
+        case #selector(NSResponder.insertNewline(_:)):
+            if let inputView = control as? NSTextField {
+                //当当前TextField按下enter
+                if inputView == self.emailTextField {
+                    print("按下 enter")
+                    
+                    if KMLoginView.verificationEmail(self.emailTextField.stringValue) {
+                        self.nextButtonAction(self.nextButton)
+                    }
+                }
+            }
+            return true
+        default:
+            return false
+        }
+    }
 }
 
 //MARK: 事件

+ 1 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMRegisterSuccessView.xib

@@ -5,7 +5,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMRegisterSuccessView" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMRegisterSuccessView" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="doneButton" destination="BHA-OV-pZP" id="jf3-NX-5Ue"/>
                 <outlet property="imageView" destination="7K1-g6-KF8" id="AWD-Xz-DEM"/>

+ 22 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMRegisterView.swift

@@ -244,7 +244,28 @@ extension KMRegisterView: NSTextFieldDelegate {
         if (textField == self.passwordSecureTextField ||
             textField == self.passwordTextField) {
             self.presenter.changePassword(string: textField!.stringValue)
-            self.passwordAlertLabel.stringValue = ""
+//            self.passwordAlertLabel.stringValue = ""
+        }
+    }
+    
+    func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
+        switch commandSelector {
+        case #selector(NSResponder.insertNewline(_:)):
+            if let inputView = control as? NSTextField {
+                //当当前TextField按下enter
+                if (textView.string == self.emailTextField.stringValue ||
+                    textView.string == self.passwordTextField.stringValue ||
+                    textView.string == self.passwordSecureTextField.stringValue) {
+                    print("按下 enter")
+                    
+                    if self.model.canNext {
+                        self.nextButtonAction(self.nextButton)
+                    }
+                }
+            }
+            return true
+        default:
+            return false
         }
     }
 }

+ 22 - 0
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMResetPasswordView.swift

@@ -273,6 +273,28 @@ extension KMResetPasswordView: NSTextFieldDelegate {
             self.presenter.changeRePassword(string: textField!.stringValue)
         }
     }
+    
+    func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
+        switch commandSelector {
+        case #selector(NSResponder.insertNewline(_:)):
+            if let inputView = control as? NSTextField {
+                //当当前TextField按下enter
+                if (textView.string == self.passwordTextField.stringValue ||
+                    textView.string == self.passwordSecureTextField.stringValue ||
+                    textView.string == self.rePasswordTextField.stringValue ||
+                    textView.string == self.rePasswordSecureTextField.stringValue) {
+                    print("按下 enter")
+                    
+                    if self.model.canNext {
+                        self.doneButtonAction(self.doneButton)
+                    }
+                }
+            }
+            return true
+        default:
+            return false
+        }
+    }
 }
 
 extension KMResetPasswordView: KMRegisterPresenterDelegate {

+ 5 - 5
PDF Office/PDF Master/Class/KMLightMember/Controller/Login&Register/View/KMResetPasswordView.xib

@@ -5,7 +5,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMResetPasswordView" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMResetPasswordView" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="doneButton" destination="V94-fh-pV8" id="cRN-LT-Hzr"/>
                 <outlet property="passwordAlertLabel" destination="S3I-lh-2pB" id="qRx-yK-3dm"/>
@@ -52,7 +52,7 @@
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="QVr-yK-c7l">
                                     <rect key="frame" x="0.0" y="22" width="262" height="32"/>
                                     <subviews>
-                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="9aV-vU-Yrm" customClass="FocusAwareTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="9aV-vU-Yrm" customClass="FocusAwareTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="5" width="222" height="22"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="22" id="jn6-yk-MJN"/>
@@ -66,7 +66,7 @@
                                                 </allowedInputSourceLocales>
                                             </textFieldCell>
                                         </textField>
-                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HjQ-Ir-c1K" customClass="FocusAwareSecureTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HjQ-Ir-c1K" customClass="FocusAwareSecureTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="6" width="222" height="20"/>
                                             <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="border" usesSingleLineMode="YES" id="KXj-xa-VvR">
                                                 <font key="font" metaFont="system"/>
@@ -128,7 +128,7 @@
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="CYd-rp-4G4">
                                     <rect key="frame" x="0.0" y="22" width="262" height="32"/>
                                     <subviews>
-                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="hqd-kg-bPA" customClass="FocusAwareTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <textField verticalHuggingPriority="750" contentType="password" translatesAutoresizingMaskIntoConstraints="NO" id="hqd-kg-bPA" customClass="FocusAwareTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="5" width="222" height="22"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="22" id="spi-7i-Sgi"/>
@@ -142,7 +142,7 @@
                                                 </allowedInputSourceLocales>
                                             </textFieldCell>
                                         </textField>
-                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TvB-NY-BFX" customClass="FocusAwareSecureTextField" customModule="PDF_Office" customModuleProvider="target">
+                                        <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TvB-NY-BFX" customClass="FocusAwareSecureTextField" customModule="PDF_Master" customModuleProvider="target">
                                             <rect key="frame" x="8" y="6" width="222" height="20"/>
                                             <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="border" usesSingleLineMode="YES" id="q1a-hJ-YJy">
                                                 <font key="font" metaFont="system"/>

+ 1 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/VerificationCode/View/KMLightMemberAlertView.swift

@@ -60,7 +60,7 @@ class KMLightMemberAlertView: KMBaseXibView {
 
         // 创建一个新的计时器,延迟 2 秒
         timer = DispatchSource.makeTimerSource()
-        timer?.schedule(deadline: .now() + 2, leeway: .milliseconds(10))
+        timer?.schedule(deadline: .now() + 3, leeway: .milliseconds(10))
         timer?.setEventHandler(handler: { [unowned self] in
             // 2 秒后执行的代码
             methodToExecuteAfterDelay()

+ 6 - 4
PDF Office/PDF Master/Class/KMLightMember/Manager/KMLightMemberManager.swift

@@ -65,10 +65,12 @@ enum KMLightMemberUserState: String, CaseIterable {
     }
     
     func logOut() {
-        self.userState = .logOut
-        KMLightMemberCache.cache.clean()
-        self.reloadUserInfo()
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: USER_LOGINSTATE_NOTIFICATION), object: nil, userInfo: nil)
+        DispatchQueue.main.async {
+            self.userState = .logOut
+            KMLightMemberCache.cache.clean()
+            self.reloadUserInfo()
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: USER_LOGINSTATE_NOTIFICATION), object: nil, userInfo: nil)
+        }
     }
     
     func logIn() {

+ 10 - 8
PDF Office/PDF Master/Class/KMLightMember/Manager/KMRequestServerManager.swift

@@ -60,7 +60,7 @@ enum KMRequestServerErrorCodeType: Int, CaseIterable {
         case .EMAIL_REGISTER_ERROR:
             result = "Register error"
         case .EXCEPTION_MSG_PASSWORD_ERROR:
-            result = "The password is incorrect, please re-enter it."
+            result = "Wrong password. You can check whether the letter is uppercase or lowercase."
         case .EXCEPTION_MSG_CODE_ACTION_ERROR:
             result = "Incorrect code"
         case .EXCEPTION_MSG_CODE_SEND_ERROR:
@@ -357,14 +357,16 @@ class KMRequestServerManager: NSObject {
                     requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
                 } completion: { [unowned self] (task, responseObject, error) in
                     let result = self.dealData(responseObject: responseObject as? NSDictionary, error: error)
-                    if result.code == 200 {
-                        //解析数据
-                        KMLightMemberUserInfo.parseData(data: responseObject as! NSDictionary) { data in
-                            KMLightMemberManager.manager.reloadUserInfo()
-                            continuation.resume(returning: (true, result))
+                    DispatchQueue.main.async {
+                        if result.code == 200 {
+                            //解析数据
+                            KMLightMemberUserInfo.parseData(data: responseObject as! NSDictionary) { data in
+                                KMLightMemberManager.manager.reloadUserInfo()
+                                continuation.resume(returning: (true, result))
+                            }
+                        } else {
+                            continuation.resume(returning: (false, result))
                         }
-                    } else {
-                        continuation.resume(returning: (false, result))
                     }
                 }
             }