Przeglądaj źródła

【综合】登陆补充loading

tangchao 1 tydzień temu
rodzic
commit
102ae5c17f

+ 13 - 5
PDF Office/PDF Master/MemberCenter/ViewModel/KMSignUpViewModel.swift

@@ -168,7 +168,7 @@ class KMSignUpViewModel: ObservableObject {
     /**
      @abstract 刷新用户个人信息
      */
-    private func refreshUserInfo() -> Void {
+    private func refreshUserInfo(callback: ((Bool?, Any ...)->Void)?) -> Void {
         if KMMemberCenterManager.manager.isConnectionAvailable() == false {
             let alert = NSAlert()
             alert.alertStyle = .critical
@@ -176,9 +176,13 @@ class KMSignUpViewModel: ObservableObject {
             alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
             alert.runModal()
+            
+            callback?(nil)
             return
         }
-        KMUserInfoVCModel().refreshUserInfo { success, msg in
+        
+        KMUserInfoVCModel().refreshUserInfo(networkAlert: false) { success, msg in
+            callback?(success)
             if success {
                 KMMemberInfo.shared.isLogin = true
                 NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MemberCenterLoginSuccess"), object: nil)
@@ -245,8 +249,6 @@ class KMSignUpViewModel: ObservableObject {
             return
         }
         KMMemberCenterManager.manager.emailLogin(email: email, code: code, type: signUpState) { [weak self] success, wrapper  in
-            callback?(success)
-            
             guard let self = self else { return }
             let resultDict = wrapper! as KMMemberCenterResult
             let msg = resultDict.msg
@@ -269,7 +271,7 @@ class KMSignUpViewModel: ObservableObject {
                 KMMemberInfo.shared.refresh_token = refresh_token!
                 KMMemberInfo.shared.access_token = access_token!
                 KMMemberInfo.shared.token_type = token_type!
-                self.refreshUserInfo()
+                self.refreshUserInfo(callback: callback)
                 
                 self.timer?.cancel()
                 self.sendContent = NSLocalizedString("Resend", tableName: "MemberCenterLocalizable", comment: "")
@@ -283,9 +285,13 @@ class KMSignUpViewModel: ObservableObject {
                         alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
                         alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
                         alert.runModal()
+                        
+                        callback?(false)
                         return
                     }
                     KMMemberCenterManager.manager.getUserDeviceList(email: self.email) { [weak self] success, result in
+                        callback?(false)
+                        
                         guard self != nil else { return }
                         if success {
                             KMMemberCenterWindowController.shared.showWindow(nil)
@@ -293,6 +299,8 @@ class KMSignUpViewModel: ObservableObject {
                         }
                     }
                 } else {
+                    callback?(false)
+                    
                     print("错误信息:%@", msg as Any)
                     let alert = NSAlert()
                     alert.messageText = NSLocalizedString(msg!, comment: "")

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

@@ -22,8 +22,8 @@ class KMUserInfoVCModel: ObservableObject {
      @abstract 刷新个人权益
      @param
      */
-    func refreshUserInfo(_ complete: @escaping UserInfoComplete) -> Void {
-        if KMMemberCenterManager.manager.isConnectionAvailable() == false {
+    func refreshUserInfo(networkAlert: Bool = true ,_ complete: @escaping UserInfoComplete) -> Void {
+        if KMMemberCenterManager.manager.isConnectionAvailable() == false && networkAlert {
             let alert = NSAlert()
             alert.alertStyle = .critical
             alert.messageText = NSLocalizedString("Error Information", comment: "")