// // KMComparativeTableViewController.swift // PDF Master // // Created by lizhe on 2023/2/24. // import Cocoa typealias KMComparativeTableViewControllerLoginAction = (_ controller: KMComparativeTableViewController) -> Void typealias KMComparativeTableViewControllerSignUpAction = (_ controller: KMComparativeTableViewController) -> Void var comparativeController: KMComparativeTableViewController? var comparativeMainWindow: NSWindow? class KMComparativeTableViewController: NSWindowController { @IBOutlet weak var comparativeTableView: KMComparativeTableView! var inputType: DataNavigationViewButtonActionType? var loginAction: KMComparativeTableViewControllerLoginAction? var signUpAction: KMComparativeTableViewControllerSignUpAction? deinit { print("KMComparativeTableViewController 释放") } //MARK: 打开文件 /** @abstract 弹出比较表 @param window 弹出window @param type 从什么页面跳转到比较表 默认batch */ static func show(window: NSWindow, _ type: DataNavigationViewButtonActionType = .Batch) -> KMComparativeTableViewController { let controller: KMComparativeTableViewController = KMComparativeTableViewController.init(windowNibName: "KMComparativeTableViewController") controller.inputType = type controller.loginAction = { controller in comparativeController = nil comparativeMainWindow?.endSheet(controller.window!) comparativeMainWindow = nil controller.close() KMLoginWindowController.show(window: NSApp.mainWindow!, .Batch, .login) } controller.signUpAction = { controller in comparativeController = nil comparativeMainWindow?.endSheet(controller.window!) comparativeMainWindow = nil controller.close() KMLoginWindowController.show(window: NSApp.mainWindow!, .Batch, .register) } window.beginSheet(controller.window!) comparativeController = controller comparativeMainWindow = window return controller } 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. self.setup() } func setup() { self.window?.contentView?.backgroundColor(NSColor(hex: "FFFFFF")) self.comparativeTableView.closeAction = { view in print("关闭") comparativeMainWindow?.endSheet(view.window!) view.window?.close() comparativeController = nil comparativeMainWindow = nil } self.comparativeTableView.signUpAction = { [weak self] view in print("注册") guard let callBack = self?.signUpAction else { return } callBack(self!) } self.comparativeTableView.loginAction = { [weak self] view in print("登录") guard let callBack = self?.loginAction else { return } callBack(self!) } } }