|
@@ -143,6 +143,8 @@ typealias KMRequestServerComplete = (_ success: Bool, _ result: Result?) -> Void
|
|
|
|
|
|
class KMRequestServerManager: NSObject {
|
|
class KMRequestServerManager: NSObject {
|
|
static let manager = KMRequestServerManager()
|
|
static let manager = KMRequestServerManager()
|
|
|
|
+
|
|
|
|
+ var loginAlert: NSAlert? = nil
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - 会员
|
|
//MARK: - 会员
|
|
@@ -519,6 +521,25 @@ extension KMRequestServerManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func checkDeviceStatus(complete: @escaping KMRequestServerComplete) {
|
|
|
|
+ var urlString = KMLightMemberManager.manager.config.kServerURL + "/pdf-office-sso/auth/checkDeviceStatus"
|
|
|
|
+
|
|
|
|
+ let uuid: String = GetHardwareUUID() ?? ""
|
|
|
|
+// let params: [String: Any] = ["appId": "16",
|
|
|
|
+// "deviceSign": uuid]
|
|
|
|
+ urlString = urlString + (NSString(format: "?appId=16&deviceSign=%@", uuid) as String)
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
|
|
|
|
+ requestSerializer.setValue("Apifox/1.0.0 (https://www.apifox.cn)", forHTTPHeaderField: "User-Agent")
|
|
|
|
+ } completion: { [unowned self] (task, responseObject, error) in
|
|
|
|
+ let result = self.dealData(responseObject: responseObject as? NSDictionary, error: error)
|
|
|
|
+ if result.code == 200 {
|
|
|
|
+ complete(true, result)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - 数据处理
|
|
//MARK: - 数据处理
|
|
@@ -548,28 +569,69 @@ extension KMRequestServerManager {
|
|
}
|
|
}
|
|
|
|
|
|
if code == 318 {
|
|
if code == 318 {
|
|
- let alert = NSAlert()
|
|
|
|
- alert.messageText = NSLocalizedString("Unable to Log in", comment: "")
|
|
|
|
- alert.informativeText = NSLocalizedString("Your account is currently being canceled and cannot be logged in. If you have any questions, please contact us at support@pdfreaderpro.com", comment: "")
|
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Contact Us", comment: ""))
|
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
|
|
|
|
- var window = NSApp.mainWindow
|
|
|
|
- if NSApp.mainWindow?.sheets.first != nil {
|
|
|
|
- window = NSApp.mainWindow?.sheets.first
|
|
|
|
- }
|
|
|
|
- alert.beginSheetModal(for: window!) { result in
|
|
|
|
- if (result == .alertFirstButtonReturn) {
|
|
|
|
-// KMMailHelper.newEmail(withContacts: "support@pdfreaderpro.com", andSubjects: "")
|
|
|
|
-// NSWorkspace.shared.launchApplication("Mailto:support@pdfreaderpro.com")
|
|
|
|
-// NSWorkspace.shared.open(URL(string: "mailto:support@pdfreaderpro.com")!)
|
|
|
|
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/contact")!)
|
|
|
|
-// let service = NSSharingService(named: NSSharingService.Name.composeEmail)
|
|
|
|
-// service?.recipients = ["support@pdfreaderpro.com"]
|
|
|
|
-// service?.subject = "Test Mail"
|
|
|
|
-// service?.perform(withItems: ["Test Mail body"])
|
|
|
|
- } else if result == .alertSecondButtonReturn {
|
|
|
|
- return
|
|
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
|
|
|
|
+ let alert = NSAlert()
|
|
|
|
+ alert.messageText = NSLocalizedString("Unable to Log in", comment: "")
|
|
|
|
+ alert.informativeText = NSLocalizedString("Your account is currently being canceled and cannot be logged in. If you have any questions, please contact us at support@pdfreaderpro.com", comment: "")
|
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("Contact Us", comment: ""))
|
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
|
|
|
|
+ var window = NSApp.mainWindow
|
|
|
|
+ if NSApp.mainWindow?.sheets.first != nil {
|
|
|
|
+ window = NSApp.mainWindow?.sheets.first
|
|
|
|
+ }
|
|
|
|
+ if window != nil {
|
|
|
|
+ alert.beginSheetModal(for: window!) { result in
|
|
|
|
+ if (result == .alertFirstButtonReturn) {
|
|
|
|
+ // KMMailHelper.newEmail(withContacts: "support@pdfreaderpro.com", andSubjects: "")
|
|
|
|
+ // NSWorkspace.shared.launchApplication("Mailto:support@pdfreaderpro.com")
|
|
|
|
+ // NSWorkspace.shared.open(URL(string: "mailto:support@pdfreaderpro.com")!)
|
|
|
|
+ NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/contact")!)
|
|
|
|
+ // let service = NSSharingService(named: NSSharingService.Name.composeEmail)
|
|
|
|
+ // service?.recipients = ["support@pdfreaderpro.com"]
|
|
|
|
+ // service?.subject = "Test Mail"
|
|
|
|
+ // service?.perform(withItems: ["Test Mail body"])
|
|
|
|
+ } else if result == .alertSecondButtonReturn {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if code == 304 {
|
|
|
|
+ self.checkDeviceStatus { success, result in
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if code == 330 {
|
|
|
|
+ if KMLoginWindowController.fetchSampleController() == nil {
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2, execute: { [unowned self] in
|
|
|
|
+ if loginAlert == nil {
|
|
|
|
+ loginAlert = NSAlert()
|
|
|
|
+ loginAlert?.messageText = NSLocalizedString("请重新登录", comment: "")
|
|
|
|
+ loginAlert?.informativeText = NSLocalizedString("您的账号已在其他设备登录,若非本人操作,请尽快修改您的账号密码", comment: "")
|
|
|
|
+ loginAlert?.addButton(withTitle: NSLocalizedString("登录", comment: ""))
|
|
|
|
+ loginAlert?.addButton(withTitle: NSLocalizedString("取消", comment: ""))
|
|
|
|
+ var window = NSApp.mainWindow
|
|
|
|
+ if NSApp.mainWindow?.sheets.first != nil {
|
|
|
|
+ window = NSApp.mainWindow?.sheets.first
|
|
|
|
+ }
|
|
|
|
+ if window != nil {
|
|
|
|
+ loginAlert?.beginSheetModal(for: window!) { result in
|
|
|
|
+ if (result == .alertFirstButtonReturn) {
|
|
|
|
+ KMLoginWindowController.show(window: window!)
|
|
|
|
+ } else if result == .alertSecondButtonReturn {
|
|
|
|
+ self.loginAlert = nil
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self.loginAlert = nil
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ self.loginAlert = nil
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|