|
@@ -36,101 +36,17 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
//MARK: 打开文件
|
|
|
- static func show(window: NSWindow, completion: @escaping (_ isSubscribeSuccess: Bool, _ isWaterMarkExport: Bool, _ isClose: Bool) -> Void) -> KMSubscribeWaterMarkWindowController {
|
|
|
+ static func show(window: NSWindow, isContinue: Bool = false, completion: @escaping (_ isSubscribeSuccess: Bool, _ isWaterMarkExport: Bool, _ isClose: Bool) -> Void) -> KMSubscribeWaterMarkWindowController {
|
|
|
let subscribeWaterMarkWindowController: KMSubscribeWaterMarkWindowController = KMSubscribeWaterMarkWindowController.init(windowNibName: "KMSubscribeWaterMarkWindowController")
|
|
|
window.beginSheet(subscribeWaterMarkWindowController.window!)
|
|
|
subscribeWaterMarkWindowController.window?.center()
|
|
|
|
|
|
- subscribeWaterMarkWindowController.waterMarkView.waterExportButton.title = NSLocalizedString("带水印保存", comment: "")
|
|
|
-
|
|
|
- subscribeWaterMarkWindowController.closeAction = { controller in
|
|
|
- completion(false, false, true)
|
|
|
- subscribeWaterMarkMainWindow?.endSheet(controller.window!)
|
|
|
- controller.window?.close()
|
|
|
-
|
|
|
- subscribeWaterMarkController = nil
|
|
|
- subscribeWaterMarkMainWindow = nil
|
|
|
- }
|
|
|
-
|
|
|
- subscribeWaterMarkWindowController.watermarkExportAction = { controller in
|
|
|
- completion(false, true, false)
|
|
|
- subscribeWaterMarkMainWindow?.endSheet(controller.window!)
|
|
|
- controller.window?.close()
|
|
|
- subscribeWaterMarkController = nil
|
|
|
- subscribeWaterMarkMainWindow = nil
|
|
|
- }
|
|
|
-
|
|
|
- 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
|
|
|
- subscribeWaterMarkMainWindow = nil
|
|
|
-
|
|
|
- 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("购买失败")
|
|
|
- controller.purchasefailed()
|
|
|
- completion(false, false, false)
|
|
|
- }
|
|
|
-
|
|
|
- controller.waterMarkView.endLoading()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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)
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- KMPrint("restore失败")
|
|
|
- controller.purchasefailed()
|
|
|
- completion(false, false, false)
|
|
|
- }
|
|
|
- controller.waterMarkView.endLoading()
|
|
|
- }
|
|
|
+ if isContinue {
|
|
|
+ subscribeWaterMarkWindowController.waterMarkView.waterExportButton.title = NSLocalizedString("Continue", comment: "")
|
|
|
+ } else {
|
|
|
+ subscribeWaterMarkWindowController.waterMarkView.waterExportButton.title = NSLocalizedString("带水印保存", comment: "")
|
|
|
}
|
|
|
|
|
|
- subscribeWaterMarkController = subscribeWaterMarkWindowController
|
|
|
- subscribeWaterMarkMainWindow = window
|
|
|
- return subscribeWaterMarkWindowController
|
|
|
- }
|
|
|
-
|
|
|
- //MARK: - 打开文件
|
|
|
-
|
|
|
- static func show_continue(window: NSWindow, completion: @escaping (_ isSubscribeSuccess: Bool, _ isWaterMarkExport: Bool, _ isClose: Bool) -> Void) -> KMSubscribeWaterMarkWindowController {
|
|
|
- let subscribeWaterMarkWindowController: KMSubscribeWaterMarkWindowController = KMSubscribeWaterMarkWindowController.init(windowNibName: "KMSubscribeWaterMarkWindowController")
|
|
|
- window.beginSheet(subscribeWaterMarkWindowController.window!)
|
|
|
- subscribeWaterMarkWindowController.window?.center()
|
|
|
-
|
|
|
- subscribeWaterMarkWindowController.waterMarkView.waterExportButton.title = NSLocalizedString("Continue", comment: "")
|
|
|
-
|
|
|
subscribeWaterMarkWindowController.closeAction = { controller in
|
|
|
completion(false, false, true)
|
|
|
subscribeWaterMarkMainWindow?.endSheet(controller.window!)
|