KMEmbeddedPaymentPopWC.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // KMEmbeddedPaymentPopWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/9/4.
  6. //
  7. import Cocoa
  8. import WebKit
  9. class KMEmbeddedPaymentPopWC: NSWindowController {
  10. @IBOutlet weak var webView: WKWebView!
  11. var urlPath: String?
  12. static var currentWindowController: KMEmbeddedPaymentPopWC!
  13. @objc static func currentFirstTrialWC(_ urlPath: String) -> KMEmbeddedPaymentPopWC {
  14. if currentWindowController != nil {
  15. currentWindowController.urlPath = urlPath
  16. return currentWindowController
  17. } else {
  18. let configWC: KMEmbeddedPaymentPopWC = KMEmbeddedPaymentPopWC.init(windowNibName: "KMEmbeddedPaymentPopWC")
  19. currentWindowController = configWC;
  20. currentWindowController.urlPath = urlPath
  21. return currentWindowController
  22. }
  23. }
  24. override func windowDidLoad() {
  25. super.windowDidLoad()
  26. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  27. if urlPath != nil {
  28. if let url = URL(string: urlPath!) {
  29. let request = URLRequest(url: url)
  30. webView.load(request)
  31. }
  32. }
  33. self.window?.delegate = self;
  34. }
  35. }
  36. extension KMEmbeddedPaymentPopWC: NSWindowDelegate {
  37. func windowWillClose(_ notification: Notification) {
  38. KMEmbeddedPaymentPopWC.currentWindowController = nil
  39. }
  40. }