// // KMEmbeddedPaymentPopWC.swift // PDF Reader Pro // // Created by wanjun on 2024/9/4. // import Cocoa import WebKit class KMEmbeddedPaymentPopWC: NSWindowController { @IBOutlet weak var webView: WKWebView! var urlPath: String? var callback: ((_ isClose: Bool) -> Void)? static var currentWindowController: KMEmbeddedPaymentPopWC! @objc static func currentFirstTrialWC(_ urlPath: String) -> KMEmbeddedPaymentPopWC { if currentWindowController != nil { currentWindowController.urlPath = urlPath return currentWindowController } else { let configWC: KMEmbeddedPaymentPopWC = KMEmbeddedPaymentPopWC.init(windowNibName: "KMEmbeddedPaymentPopWC") currentWindowController = configWC; currentWindowController.urlPath = urlPath return currentWindowController } } override func windowDidLoad() { super.windowDidLoad() // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. if urlPath != nil { if let url = URL(string: urlPath!) { let request = URLRequest(url: url) webView.load(request) } } self.window?.delegate = self; } } extension KMEmbeddedPaymentPopWC: NSWindowDelegate { func windowWillClose(_ notification: Notification) { if let callback = self.callback { callback(true) } KMEmbeddedPaymentPopWC.currentWindowController = nil } }