|
@@ -87,11 +87,9 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
subscribeWaterMarkWindowController.subscribeAction = { controller in
|
|
|
- KMPrint("购买")
|
|
|
controller.waterMarkView.beginLoading(backgroundColor: NSColor.black.withAlphaComponent(0.2))
|
|
|
KMPurchaseManager.manager.purchaseProduct(productIdentifier: PRODUCT_1) { isSuccess, error in
|
|
|
if isSuccess {
|
|
|
- KMPrint("购买成功")
|
|
|
subscribeWaterMarkMainWindow?.endSheet(controller.window!)
|
|
|
controller.window?.close()
|
|
|
subscribeWaterMarkController = nil
|
|
@@ -107,8 +105,7 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- KMPrint("购买失败")
|
|
|
- controller.purchasefailed()
|
|
|
+ KMComparativeTableViewController.purchasefailed(state: .failed)
|
|
|
completion(false, false, false)
|
|
|
}
|
|
|
|
|
@@ -117,26 +114,25 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
subscribeWaterMarkWindowController.restoreAction = { controller in
|
|
|
- KMPrint("restore")
|
|
|
controller.waterMarkView.beginLoading(backgroundColor: NSColor.black.withAlphaComponent(0.2))
|
|
|
KMPurchaseManager.manager.restorePurchases { isSuccess in
|
|
|
if isSuccess {
|
|
|
- KMPrint("restore成功")
|
|
|
subscribeWaterMarkMainWindow?.endSheet(controller.window!)
|
|
|
controller.window?.close()
|
|
|
subscribeWaterMarkController = nil
|
|
|
subscribeWaterMarkMainWindow = nil
|
|
|
|
|
|
- if NSApp.mainWindow != nil {
|
|
|
- let controller = KMSubscribeSuccessWindowController.show(window: NSApp.mainWindow!)
|
|
|
- controller.closeAction = { controller in
|
|
|
- controller.closeWindow()
|
|
|
- completion(true, false, false)
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
|
|
|
+ if NSApp.mainWindow != nil {
|
|
|
+ let controller = KMSubscribeSuccessWindowController.show(window: NSApp.mainWindow!)
|
|
|
+ controller.closeAction = { controller in
|
|
|
+ controller.closeWindow()
|
|
|
+ completion(true, false, false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- KMPrint("restore失败")
|
|
|
- controller.purchasefailed()
|
|
|
+ KMComparativeTableViewController.purchasefailed(state: .restoreFailed)
|
|
|
completion(false, false, false)
|
|
|
}
|
|
|
controller.waterMarkView.endLoading()
|
|
@@ -207,27 +203,4 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
|
|
|
}
|
|
|
return KMSubscribeWaterMarkWindowController()
|
|
|
}
|
|
|
-
|
|
|
- func purchasefailed() {
|
|
|
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.messageText = NSLocalizedString("购买失败", comment: "")
|
|
|
- alert.informativeText = NSLocalizedString("", comment: "")
|
|
|
-// alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- alert.addButton(withTitle: NSLocalizedString("OK", 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) {
|
|
|
-
|
|
|
- } else if result == .alertSecondButtonReturn {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
}
|