KMHomeViewController.swift 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. //
  2. // KMHomeViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2022/10/13.
  6. //
  7. import Cocoa
  8. @objc enum KMHomeToolState : Int {
  9. case OpenPDF = 0
  10. case CreatePDF
  11. case Home
  12. case PDFTools
  13. case FavoriteDocuments
  14. case CloudDocuments
  15. }
  16. @objc enum KMAIHomeToolState : Int {
  17. case Home = 0
  18. case AITranslation
  19. case AIRewriting
  20. case AIErrorCorrection
  21. }
  22. @objcMembers class KMHomeViewController: NSViewController {
  23. @IBOutlet weak var leftBox: NSBox!
  24. @IBOutlet weak var rightBox: NSBox!
  25. @IBOutlet weak var homeSplitView: NSSplitView!
  26. @IBOutlet weak var homeRightScrollViewView: NSScrollView!
  27. @IBOutlet weak var rightTopBox: NSBox!
  28. @IBOutlet weak var rightBottomBox: NSBox!
  29. @IBOutlet weak var rightFullBox: NSBox!
  30. @IBOutlet weak var rightTopBoxHeightConstraint: NSLayoutConstraint!
  31. @IBOutlet var fastToolViewController: KMHomeFastToolViewController!
  32. @IBOutlet var historyFileViewController: KMHomeHistoryFileViewController!
  33. @IBOutlet var pdfToolsViewController: KMPDFToolsViewController!
  34. @IBOutlet var cloudDocumentsViewController: KMCloudDocumentsViewController!
  35. @IBOutlet weak var dragView: KMHomeDragView!
  36. // AI 临时UI
  37. @IBOutlet weak var aiHomeBox: KMBox!
  38. @IBOutlet weak var aiHomeImageView: NSImageView!
  39. @IBOutlet weak var aiHomeLabel: NSTextField!
  40. @IBOutlet weak var aiTranslationBox: KMBox!
  41. @IBOutlet weak var aiTranslationImageView: NSImageView!
  42. @IBOutlet weak var aiTranslationLabel: NSTextField!
  43. @IBOutlet weak var aiRewritingBox: KMBox!
  44. @IBOutlet weak var aiRewritingImageView: NSImageView!
  45. @IBOutlet weak var aiRewritingLabel: NSTextField!
  46. @IBOutlet weak var aiErrorCorrectionBox: KMBox!
  47. @IBOutlet weak var aiErrorCorrectionImageView: NSImageView!
  48. @IBOutlet weak var aiErrorCorrectionLabel: NSTextField!
  49. @IBOutlet var aiOpenPDFFilesViewController: KMAIOpenPDFFilesVC!
  50. @IBOutlet var aiTranslationViewController: KMAITranslationVC!
  51. @IBOutlet var aiRewritingViewController: KMAIRewritingVC!
  52. @IBOutlet weak var creatPDFView: KMCreatPDFView!
  53. //HomeContentView
  54. @IBOutlet weak var homeContentView: KMHomeContentView!
  55. //广告 互推
  56. @IBOutlet weak var advertisementTableView: KMAdvertisementTableView!
  57. @IBOutlet weak var advertisementTableViewHeightConstraint: NSLayoutConstraint!
  58. @IBOutlet weak var advertisementShowView: KMAdvertisementShowView!
  59. //合并
  60. var mergeWindowController: KMMergeWindowController?
  61. var aiHomeState: KMAIHomeToolState = .Home
  62. let ScrollerViewWidget: CGFloat = 15.0
  63. var homeWindowController : MainWindowController!
  64. var isShowQuickTour: Bool = false
  65. weak var myDocument: NSDocument?
  66. var currentWindowController: NSWindowController?
  67. var homeState: KMHomeToolState = .Home
  68. var urlToPDFWindowController: KMURLToPDFWindowController?
  69. var openPDFButtonVC: KMDesignButton?
  70. var createPDFButtonVC: KMDesignButton?
  71. var createPDFImage: KMDesignButton?
  72. var createPDFAddButtonVC: KMDesignButton?
  73. var homeButtonVC: KMTextImageButtonVC?
  74. var pdfToolsButtonVC: KMTextImageButtonVC?
  75. var cloudDocumentsButtonVC: KMTextImageButtonVC?
  76. var pdfSeriesButtonVC: KMTextImageButtonVC?
  77. var pdfOthersButtonVC: KMTextImageButtonVC?
  78. var popover: NSPopover?
  79. var deviceBrowserWC: KMDeviceBrowserWindowController?
  80. var progressController: SKProgressController?
  81. var timer: Timer?
  82. var timerCounter = 0.0
  83. //AI相关
  84. //试用相关
  85. var didTrialExpiredLoad: Bool = false
  86. var repeatTrialAlertLoad: Bool = false
  87. var guideWindowVC: KMFunctionGuideWindowController!
  88. var showCoupon: Bool = true
  89. var couponDueWindowVC: KMCouponDueWindowController!
  90. @IBOutlet weak var rightBottonHeight: NSLayoutConstraint!
  91. var currentController: NSWindowController?
  92. deinit {
  93. NotificationCenter.default.removeObserver(self)
  94. }
  95. override func viewWillAppear() {
  96. super.viewWillAppear()
  97. if !KMLightMemberManager.manager.isLogin() {
  98. KMLightMemberManager.manager.canShowAdvancedView = true
  99. }
  100. self.homeContentView.reloadData()
  101. #if VERSION_DMG
  102. let kDMGFirstInstallKey = "DMGFirstInstallKey"
  103. if KMDataManager.ud_object(forKey: kDMGFirstInstallKey) == nil {
  104. KMDataManager.ud_set("Show", forKey: kDMGFirstInstallKey)
  105. KMTools.openURL(urlString: "http://www.pdfreaderpro.com/thank-you-for-installation")
  106. }
  107. #else
  108. // [self loadAIInfo];
  109. #endif
  110. }
  111. override func viewWillDisappear() {
  112. super.viewWillDisappear()
  113. // self.homeContentView.reloadData()
  114. }
  115. override func viewDidLoad() {
  116. super.viewDidLoad()
  117. // Do view setup here.
  118. openPDFButtonVC = KMDesignButton.init(withType: .Text)
  119. createPDFButtonVC = KMDesignButton.init(withType: .Text)
  120. createPDFImage = KMDesignButton.init(withType: .Image)
  121. createPDFAddButtonVC = KMDesignButton.init(withType: .Image)
  122. homeButtonVC = KMTextImageButtonVC.init(nibName: "KMTextImageButtonVC", bundle: nil)
  123. pdfToolsButtonVC = KMTextImageButtonVC.init(nibName: "KMTextImageButtonVC", bundle: nil)
  124. cloudDocumentsButtonVC = KMTextImageButtonVC.init(nibName: "KMTextImageButtonVC", bundle: nil)
  125. pdfSeriesButtonVC = KMTextImageButtonVC.init(nibName: "KMTextImageButtonVC", bundle: nil)
  126. pdfOthersButtonVC = KMTextImageButtonVC.init(nibName: "KMTextImageButtonVC", bundle: nil)
  127. self.homeSplitView.setPosition(270.0, ofDividerAt: 0)
  128. self.leftBox.fillColor = NSColor.km_init(hex: "#F7F8FA")
  129. self.rightBox.fillColor = NSColor.km_init(hex: "#F7F8FA")
  130. NSEvent.addLocalMonitorForEvents(matching: .leftMouseDown) { (aEvent) -> NSEvent? in
  131. self.otherMouseDown(with: aEvent)
  132. return aEvent
  133. }
  134. self.initNetworkingData()
  135. // self.initLocalization()
  136. // self.initializeUI()
  137. self.initializeUI_DMG()
  138. self.setup()
  139. // refreshUI()
  140. self.updateUI()
  141. self.changeEffectiveAppearance()
  142. NotificationCenter.default.addObserver(self, selector: #selector(homeFileRectChange(_:)), name: Notification.Name("KMHomeFileRectChange"), object: nil)
  143. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  144. // setAppearance(isDarkMode: KMAdvertisementConfig.isDarkModel())
  145. // NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name(NSApplication.didUpdateNotification.rawValue), object: nil)
  146. // NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name(NSWindow.didBecomeMainNotification.rawValue), object: nil)
  147. // NotificationCenter.default.addObserver(self, selector: #selector(appearanceChanged), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  148. NotificationCenter.default.addObserver(self, selector: #selector(openNewWindowAlertV), name: Notification.Name("KMCTTableChangeShowAlertView"), object: nil)
  149. #if VERSION_DMG
  150. NotificationCenter.default.addObserver(self, selector: #selector(deviceVerifyFinishNotification), name: Notification.Name.init(NSNotification.Name.deviceVerifyFinish.rawValue), object: nil)
  151. #endif
  152. NotificationCenter.default.addObserver(self, selector: #selector(importFromCamera), name: Notification.Name("kDeviceCameraMenuItemNotification"), object: nil)
  153. NotificationCenter.default.addObserver(self, selector: #selector(importFromScanner), name: Notification.Name("kDeviceScannerMenuItemNotification"), object: nil)
  154. self.loadFunctionGuide()
  155. }
  156. override func viewDidAppear() {
  157. super.viewDidAppear()
  158. refreshScrollView()
  159. }
  160. override func viewDidLayout() {
  161. super.viewDidLayout()
  162. refreshScrollView()
  163. // self.loadAITipIconGuide()
  164. }
  165. func initNetworkingData() {
  166. KMAdvertisementManager.manager.fetchDataWithResponseObject { [weak self] data, responseObject, error in
  167. KMPrint("获取广告数据成功")
  168. if data != nil {
  169. let content = data!.recommondContent
  170. let item = content?.recommondContentPDFPro
  171. var infos: [KMAdvertisementItemInfo] = []
  172. for info in item?.content ?? [] {
  173. if info.version == "recommondPDF-PDFtoOfficePack" {
  174. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() == false {
  175. infos.append(info)
  176. }
  177. } else {
  178. infos.append(info)
  179. }
  180. }
  181. item?.content = infos
  182. self?.advertisementTableView.inputData = content
  183. self?.advertisementTableView.didSelect = { view, item in
  184. let string = KMAdvertisementModelTransition.transitionLanguage(langeuage: item.linkURL)
  185. if string.count != 0 {
  186. NSWorkspace.shared.open(URL.init(string: string)!)
  187. }
  188. }
  189. self?.advertisementShowView.inputData = data!.advertisement
  190. self?.advertisementShowView.didSelect = { view, item in
  191. let string = KMAdvertisementModelTransition.transitionLanguage(langeuage: item.linkURL)
  192. if string.count != 0 {
  193. NSWorkspace.shared.open(URL.init(string: string)!)
  194. }
  195. guard let firebaseInfo = item.firebase else {
  196. return
  197. }
  198. KMAdvertisementModelTransition.sendFireBaseEvent(firebase: firebaseInfo)
  199. }
  200. if KMAdvertisementManager.manager.infoDict.allKeys.count > 0 {
  201. if let adsInfo = KMAdvertisementManager.manager.infoDict["adsInfo"] {
  202. let infoDict: NSDictionary = KMAdvertisementManager.manager.infoDict["adsInfo"] as! NSDictionary
  203. let array: [[String: Any]] = infoDict["content"] as! [[String : Any]]
  204. let arrM = NSMutableArray.init()
  205. for dict in array {
  206. let adsInfo = KMAdsInfo.init()
  207. let mutableDictionary = NSMutableDictionary(dictionary: dict)
  208. adsInfo.infoDict = mutableDictionary
  209. arrM.add(adsInfo)
  210. }
  211. KMAdsInfoManager.shareInstance.adsInfoArrM = arrM
  212. }
  213. if let couponInfo = KMAdvertisementManager.manager.infoDict["couponContent"] {
  214. let infoDict: NSDictionary = KMAdvertisementManager.manager.infoDict["couponContent"] as! NSDictionary
  215. let array: [[String: Any]] = infoDict["content"] as! [[String : Any]]
  216. if array.isEmpty == false {
  217. let dict = array[0]
  218. let adsInfo = KMCouponInfo.init()
  219. let mutableDictionary = NSMutableDictionary(dictionary: dict)
  220. adsInfo.infoDict = mutableDictionary
  221. KMAdsInfoManager.shareInstance.couponInfo = adsInfo
  222. }
  223. }
  224. self?.checkTrialEndCouponInfo()
  225. }
  226. }
  227. }
  228. }
  229. func setup() {
  230. //creatPDF
  231. self.creatPDFView.openPDFAction = { [unowned self] view, sender in
  232. self.openPDFAction(sender)
  233. }
  234. self.creatPDFView.creatPDFAction = { [unowned self] view, sender in
  235. self.creatPDFAction(sender)
  236. }
  237. //history
  238. self.homeContentView.historyDidSelect = { [unowned self] view, item in
  239. self.openHistoryFilePath(url: item.url!)
  240. }
  241. self.homeContentView.historyRemoveFileAction = { [unowned self] view, item in
  242. self.historyFile(deleteDocuments: [ item.url!])
  243. }
  244. self.homeContentView.historyShowPathAction = { [unowned self] view, item in
  245. if FileManager.default.fileExists(atPath: item.url!.path) {
  246. NSWorkspace.shared.activateFileViewerSelecting([item.url!])
  247. }
  248. }
  249. self.homeContentView.historyRemoveAllFileAction = { [unowned self] view in
  250. let alert = NSAlert()
  251. alert.alertStyle = .critical
  252. alert.messageText = String(format: "%@?", NSLocalizedString("Clear All Recents", comment: ""))
  253. alert.addButton(withTitle: NSLocalizedString("Delete", comment: ""))
  254. alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
  255. alert.beginSheetModal(for: self.view.window!) { response in
  256. if response == .alertFirstButtonReturn {
  257. let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
  258. self.historyFileDeleteAction(urls)
  259. }
  260. }
  261. }
  262. //quciktools
  263. self.homeContentView.qucikToolsDidSelect = { [unowned self] view, item in
  264. self.fastToolItemAction(item.type!)
  265. }
  266. self.homeContentView.qucikToolsAddAction = { [unowned self] view, item in
  267. KMBatchQuickActionManager.defaultManager.actionType = .add
  268. self.fastToolItemAction(item.type!)
  269. }
  270. self.homeContentView.qucikToolsRemoveAction = { [unowned self] view, item in
  271. KMBatchQuickActionManager.defaultManager.actionType = .remove
  272. self.fastToolItemAction(item.type!)
  273. }
  274. if IAPProductsManager.default().isAvailableAllFunction() {
  275. self.advertisementShowView.isHidden = true
  276. } else {
  277. self.advertisementShowView.isHidden = false
  278. }
  279. NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"), object: nil)
  280. NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "kDeviceActivateNotification"), object: nil)
  281. }
  282. // MARK: Init
  283. func initializeUI() {
  284. rightTopBox.fillColor = .white
  285. rightBottomBox.fillColor = .white
  286. rightFullBox.fillColor = .white
  287. self.refreshRightBoxUI(.Home)
  288. fastToolViewController.delete = self
  289. historyFileViewController.delete = self
  290. pdfToolsViewController.delete = self
  291. dragView.delete = self
  292. }
  293. func initLocalization() {
  294. // self.favoriteDocumentsLabel.stringValue = NSLocalizedString("Favorite Documents", comment: "")
  295. homeButtonVC?.stringValue = NSLocalizedString("Home", comment: "")
  296. pdfToolsButtonVC?.stringValue = NSLocalizedString("PDF Tools", comment: "")
  297. cloudDocumentsButtonVC?.stringValue = NSLocalizedString("Cloud Documents", comment: "")
  298. openPDFButtonVC?.stringValue = NSLocalizedString("Open File", comment: "")
  299. // openPDFBox.toolTip = NSLocalizedString("Open PDF", comment: "")
  300. createPDFButtonVC?.stringValue = NSLocalizedString("Create PDF", comment: "")
  301. // createPDFBox.toolTip = NSLocalizedString("Create PDF", comment: "")
  302. pdfSeriesButtonVC?.stringValue = NSLocalizedString("PDF Pro Series", comment: "")
  303. pdfOthersButtonVC?.stringValue = NSLocalizedString("Others", comment: "")
  304. }
  305. // MARK: Action
  306. func initializeUI_DMG() -> Void {
  307. rightTopBox.fillColor = .white
  308. rightBottomBox.fillColor = .white
  309. rightFullBox.fillColor = .white
  310. self.aiHomeBox.fillColor = .clear
  311. self.aiHomeBox.cornerRadius = 8.0
  312. self.aiHomeImageView.image = NSImage(named: "icon_home")
  313. self.aiHomeLabel.stringValue = NSLocalizedString("Home", comment: "")
  314. self.aiHomeLabel.textColor = NSColor.km_init(hex: "#252629")
  315. self.aiHomeLabel.font = NSFont.SFProTextRegularFont(16.0)
  316. self.aiHomeBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  317. if aiHomeState != .Home {
  318. if mouseEntered {
  319. self.aiHomeBox.fillColor = NSColor.km_init(hex: "#EDEEF0")
  320. } else {
  321. self.aiHomeBox.fillColor = .clear
  322. }
  323. }
  324. }
  325. self.aiHomeBox.downCallback = { [unowned self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  326. if aiHomeState != .Home {
  327. if downEntered {
  328. self.aiHomeState = .Home
  329. self.refreshAIUI()
  330. }
  331. }
  332. }
  333. self.aiTranslationBox.fillColor = .clear
  334. self.aiTranslationBox.cornerRadius = 8.0
  335. self.aiTranslationImageView.image = NSImage(named: "ic_function_other")
  336. self.aiTranslationLabel.stringValue = NSLocalizedString("AI Translation", comment: "")
  337. self.aiTranslationLabel.textColor = NSColor.km_init(hex: "#252629")
  338. self.aiTranslationLabel.font = NSFont.SFProTextRegularFont(16.0)
  339. self.aiTranslationBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  340. if aiHomeState != .AITranslation {
  341. if mouseEntered {
  342. self.aiTranslationBox.fillColor = NSColor.km_init(hex: "#EDEEF0")
  343. } else {
  344. self.aiTranslationBox.fillColor = .clear
  345. }
  346. }
  347. }
  348. self.aiTranslationBox.downCallback = { [unowned self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  349. if aiHomeState != .AITranslation {
  350. if downEntered {
  351. self.aiHomeState = .AITranslation
  352. self.trackEvent_ai(eventName: "AI Translation")
  353. self.refreshAIUI()
  354. }
  355. }
  356. }
  357. self.aiRewritingBox.fillColor = .clear
  358. self.aiRewritingBox.cornerRadius = 8.0
  359. self.aiRewritingImageView.image = NSImage(named: "ic_ai_Rewriting")
  360. self.aiRewritingLabel.stringValue = NSLocalizedString("AI Rewriting", comment: "")
  361. self.aiRewritingLabel.textColor = NSColor.km_init(hex: "#252629")
  362. self.aiRewritingLabel.font = NSFont.SFProTextRegularFont(16.0)
  363. self.aiRewritingBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  364. if aiHomeState != .AIRewriting {
  365. if mouseEntered {
  366. self.aiRewritingBox.fillColor = NSColor.km_init(hex: "#EDEEF0")
  367. } else {
  368. self.aiRewritingBox.fillColor = .clear
  369. }
  370. }
  371. }
  372. self.aiRewritingBox.downCallback = { [unowned self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  373. if aiHomeState != .AIRewriting {
  374. if downEntered {
  375. self.aiHomeState = .AIRewriting
  376. self.trackEvent_ai(eventName: "AI Rewriting")
  377. self.refreshAIUI()
  378. }
  379. }
  380. }
  381. self.aiErrorCorrectionBox.fillColor = .clear
  382. self.aiErrorCorrectionBox.cornerRadius = 8.0
  383. self.aiErrorCorrectionImageView.image = NSImage(named: "ic_ai_ErrorCorrection")
  384. self.aiErrorCorrectionLabel.stringValue = NSLocalizedString("AI Error Correction", comment: "")
  385. self.aiErrorCorrectionLabel.textColor = NSColor.km_init(hex: "#252629")
  386. self.aiErrorCorrectionLabel.font = NSFont.SFProTextRegularFont(16.0)
  387. self.aiErrorCorrectionBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  388. if aiHomeState != .AIErrorCorrection {
  389. if mouseEntered {
  390. self.aiErrorCorrectionBox.fillColor = NSColor.km_init(hex: "#EDEEF0")
  391. } else {
  392. self.aiErrorCorrectionBox.fillColor = .clear
  393. }
  394. }
  395. }
  396. self.aiErrorCorrectionBox.downCallback = { [unowned self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  397. if aiHomeState != .AIErrorCorrection {
  398. if downEntered {
  399. self.aiHomeState = .AIErrorCorrection
  400. self.trackEvent_ai(eventName: "AI Correction")
  401. self.refreshAIUI()
  402. }
  403. }
  404. }
  405. self.refreshAIUI()
  406. historyFileViewController.delete = self
  407. dragView.delete = self
  408. }
  409. func updateUI() {
  410. self.leftBox.fillColor = KMAppearance.Layout.l0Color()
  411. // self.homeSplitView.backgroundColor(KMAppearance.Layout.l0Color())
  412. }
  413. @objc func changeEffectiveAppearance() {
  414. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  415. if isDarkModel {
  416. self.view.appearance = NSAppearance(named: .darkAqua)
  417. } else {
  418. self.view.appearance = NSAppearance(named: .aqua)
  419. }
  420. self.updateUI()
  421. self.advertisementTableView.reloadData()
  422. }
  423. // MARK: Public Methods
  424. func savePDFDocument(_ pdf: CPDFDocument, password: String) -> Void {
  425. DispatchQueue.global(qos: .`default`).async {
  426. var isSuccessfully = false
  427. if pdf.isEncrypted {
  428. let dic = [
  429. CPDFDocumentWriteOption.userPasswordOption : password,
  430. CPDFDocumentWriteOption.ownerPasswordOption : password
  431. ]
  432. isSuccessfully = pdf.write(to: pdf.documentURL, withOptions: dic)
  433. } else {
  434. isSuccessfully = pdf.write(to: pdf.documentURL)
  435. }
  436. if !isSuccessfully {
  437. if let data = pdf.dataRepresentation() {
  438. isSuccessfully = NSData(data: data).write(to: pdf.documentURL, atomically: true)
  439. }
  440. }
  441. DispatchQueue.main.sync {
  442. if isSuccessfully {
  443. let workspace = NSWorkspace.shared
  444. let url = URL(fileURLWithPath: pdf.documentURL?.path ?? "")
  445. workspace.activateFileViewerSelecting([url])
  446. } else {
  447. let alert = NSAlert()
  448. alert.alertStyle = .critical
  449. alert.messageText = NSLocalizedString("Failed to insert page(s)!", comment: "")
  450. alert.runModal()
  451. }
  452. }
  453. }
  454. }
  455. // MARK: Private Methods
  456. func refreshUI() -> Void {
  457. homeButtonVC?.updateUI()
  458. pdfToolsButtonVC?.updateUI()
  459. cloudDocumentsButtonVC?.updateUI()
  460. }
  461. func refreshAIUI() -> Void {
  462. self.aiHomeBox.fillColor = .clear
  463. self.aiHomeLabel.font = NSFont.SFProTextRegularFont(16.0)
  464. self.aiTranslationBox.fillColor = .clear
  465. self.aiTranslationLabel.font = NSFont.SFProTextRegularFont(16.0)
  466. self.aiRewritingBox.fillColor = .clear
  467. self.aiRewritingLabel.font = NSFont.SFProTextRegularFont(16.0)
  468. self.aiErrorCorrectionBox.fillColor = .clear
  469. self.aiErrorCorrectionLabel.font = NSFont.SFProTextRegularFont(16.0)
  470. rightFullBox.isHidden = true
  471. rightTopBox.isHidden = true
  472. rightBottomBox.isHidden = true
  473. switch self.aiHomeState {
  474. case .Home:
  475. self.aiHomeBox.fillColor = NSColor.km_init(hex: "#1770F4", alpha: 0.1)
  476. self.aiHomeLabel.font = NSFont.SFProTextSemiboldFont(16.0)
  477. self.rightTopBox.isHidden = false
  478. self.rightBottomBox.isHidden = false
  479. self.rightTopBox.contentView = self.aiOpenPDFFilesViewController.view
  480. self.rightBottomBox.contentView = self.historyFileViewController.view
  481. self.rightFullBox.contentView = nil
  482. self.rightTopBoxHeightConstraint.constant = 388.0
  483. self.dragView.isHidden = false
  484. break
  485. case .AITranslation:
  486. self.aiTranslationBox.fillColor = NSColor.km_init(hex: "#1770F4", alpha: 0.1)
  487. self.aiTranslationLabel.textColor = NSColor.km_init(hex: "#252629")
  488. self.aiTranslationLabel.font = NSFont.SFProTextSemiboldFont(16.0)
  489. self.rightFullBox.isHidden = false
  490. self.rightTopBox.contentView = nil
  491. self.rightBottomBox.contentView = nil
  492. self.rightFullBox.contentView = self.aiTranslationViewController.view
  493. self.dragView.isHidden = false
  494. break
  495. case .AIRewriting:
  496. self.aiRewritingBox.fillColor = NSColor.km_init(hex: "#1770F4", alpha: 0.1)
  497. self.aiRewritingLabel.textColor = NSColor.km_init(hex: "#252629")
  498. self.aiRewritingLabel.font = NSFont.SFProTextSemiboldFont(16.0)
  499. self.rightFullBox.isHidden = false
  500. self.rightTopBox.contentView = nil
  501. self.rightBottomBox.contentView = nil
  502. self.rightFullBox.contentView = self.aiRewritingViewController.view
  503. // self.aiRewritingViewController.state = .AIRewriting
  504. self.aiRewritingViewController.initLocalization()
  505. self.aiRewritingViewController.acquisition_uiState()
  506. self.dragView.isHidden = true
  507. break
  508. case .AIErrorCorrection:
  509. self.aiErrorCorrectionBox.fillColor = NSColor.km_init(hex: "#1770F4", alpha: 0.1)
  510. self.aiErrorCorrectionLabel.textColor = NSColor.km_init(hex: "#252629")
  511. self.aiErrorCorrectionLabel.font = NSFont.SFProTextSemiboldFont(16.0)
  512. self.rightFullBox.isHidden = false
  513. self.rightTopBox.contentView = nil
  514. self.rightBottomBox.contentView = nil
  515. self.rightFullBox.contentView = self.aiRewritingViewController.view
  516. // self.aiRewritingViewController.state = .AIErrorCorrection
  517. self.aiRewritingViewController.initLocalization()
  518. self.aiRewritingViewController.acquisition_uiState()
  519. self.dragView.isHidden = true
  520. break
  521. default:
  522. break
  523. }
  524. }
  525. func fetchDifferentFilePath(filePath: String) -> String {
  526. var resultFilePath = filePath
  527. var index: Int = 0
  528. while (FileManager.default.fileExists(atPath: resultFilePath)) {
  529. index += 1
  530. let path = NSString(string: filePath).deletingPathExtension + "(" + String(index) + ")"
  531. resultFilePath = NSString(string: path).appendingPathExtension(NSString(string: filePath).pathExtension)!
  532. }
  533. return resultFilePath;
  534. }
  535. func showProgressWindow() {
  536. let progress = SKProgressController()
  537. progress.window?.backgroundColor = NSColor.km_init(hex: "#36383B")
  538. progress.window?.contentView?.wantsLayer = true
  539. progress.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#36383B").cgColor
  540. progress.progressField.textColor = NSColor.white
  541. progress.message = NSLocalizedString("Translating...", comment: "")
  542. progress.closeBlock = { [weak self] in
  543. }
  544. self.progressController = progress
  545. self.view.window?.beginSheet(progress.window!)
  546. }
  547. func hiddenProgressWindow() {
  548. DispatchQueue.main.async {
  549. self.progressController?.doubleValue = 100.0
  550. }
  551. self.stopTimer()
  552. if (self.progressController != nil) {
  553. self.view.window?.endSheet((self.progressController?.window)!)
  554. self.progressController = nil
  555. }
  556. }
  557. func isFileGreaterThan10MB(atPath filePath: String) -> Bool {
  558. let fileManager = FileManager.default
  559. do {
  560. let fileAttributes = try fileManager.attributesOfItem(atPath: filePath)
  561. if let fileSize = fileAttributes[.size] as? UInt64 {
  562. let megabyteSize = fileSize / (1024 * 1024)
  563. return megabyteSize >= 10
  564. }
  565. } catch {
  566. KMPrint("Error: \(error)")
  567. }
  568. return false
  569. }
  570. func isPDFPageCountExceedsLimit(filePath: String) -> Bool {
  571. let url = URL(fileURLWithPath: filePath)
  572. guard let document = PDFDocument(url: url) else {
  573. return false
  574. }
  575. let pageCount = document.pageCount
  576. return pageCount > 30
  577. }
  578. @objc func timerTick() {
  579. timerCounter += 1.0
  580. self.progressController?.increment(by: 1.0)
  581. if timerCounter >= 95 {
  582. stopTimer()
  583. }
  584. }
  585. func stopTimer() {
  586. timer?.invalidate()
  587. timer = nil
  588. }
  589. // MARK: Common methods
  590. func workSpaceOpenUrl(_ url: NSString) {
  591. let httpUrl: NSURL = NSURL.init(string: url as String)!
  592. let tWorkSpace: NSWorkspace = NSWorkspace.shared
  593. if !tWorkSpace.open(httpUrl as URL) {
  594. tWorkSpace.open(httpUrl as URL)
  595. }
  596. }
  597. }
  598. //MARK: Open Creat PDF
  599. extension KMHomeViewController: NSPopoverDelegate {
  600. }
  601. extension KMHomeViewController {
  602. func openPDFAction(_ sender: KMBox) {
  603. if needShowTabbingHintWindow() {
  604. showTabbingHintWindow()
  605. return
  606. }
  607. let openPanel = NSOpenPanel()
  608. openPanel.allowedFileTypes = ["pdf", "PDF"]
  609. openPanel.allowsMultipleSelection = false
  610. openPanel.beginSheetModal(for: self.view.window!) { (result) in
  611. if result == NSApplication.ModalResponse.OK {
  612. let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
  613. if controll?.browser?.tabCount() ?? 0 > 1 && KMPreference.shared.openDocumentType == .newWindow{
  614. self.reopenDocument(forPaths: openPanel.url!)
  615. }else {
  616. NSDocumentController.shared.km_safe_limit_openDocument(withContentsOf: openPanel.url!, display: true) { (document, documentWasAlreadyOpen, error) in
  617. }
  618. }
  619. }
  620. }
  621. }
  622. func needShowTabbingHintWindow() -> Bool {
  623. let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
  624. if controll?.browser?.tabCount() ?? 0 > 1 && !IAPProductsManager.default().isAvailableAllFunction() {
  625. return true
  626. }
  627. return false
  628. }
  629. func showTabbingHintWindow(){
  630. if !KMDataManager.default.isTabbingWin{
  631. KMDataManager.default.isTabbingWin = true
  632. let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
  633. tabbingWin.selectCallBack = { [weak self] continueOrNot in
  634. KMDataManager.default.isTabbingWin = false
  635. if continueOrNot {
  636. self?.reopenDocument(forPaths: nil)
  637. } else {
  638. }
  639. }
  640. self.km_beginSheet(windowC: tabbingWin)
  641. }
  642. }
  643. func creatPDFAction(_ sender: KMBox) {
  644. let popViewDataArr: [String] = [NSLocalizedString("New Blank Page", comment: ""),
  645. NSLocalizedString("New From Images", comment: ""),
  646. NSLocalizedString("New From Web Page", comment: ""),
  647. NSLocalizedString("Import From Camera", comment: ""),
  648. NSLocalizedString("Import From Scanner", comment: "")]
  649. let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(popViewDataArr)
  650. vc.background = KMAppearance.Layout.bgColor()
  651. vc.textColor = KMAppearance.Layout.h0Color()
  652. vc.enterFillColor = KMAppearance.Interactive.s0Color()
  653. let createFilePopover: NSPopover = NSPopover.init()
  654. createFilePopover.contentViewController = vc
  655. createFilePopover.delegate = self
  656. createFilePopover.animates = true
  657. createFilePopover.behavior = .semitransient
  658. createFilePopover.setValue(true, forKey: "shouldHideAnchor")
  659. createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .minY)
  660. vc.downCallback = { [unowned self] (downEntered: Bool, count: String) -> Void in
  661. if count == NSLocalizedString("New Blank Page", comment: "") {
  662. self.openBlankPage()
  663. } else if count == NSLocalizedString("Import From Camera", comment: "") {
  664. self.importFromCamera()
  665. } else if count == NSLocalizedString("Import From Scanner", comment: "") {
  666. self.importFromScanner()
  667. } else if count == NSLocalizedString("New From Web Page", comment: "") {
  668. self.importFromWebPage()
  669. } else if count == NSLocalizedString("New From Images", comment: "") {
  670. self.newFromImages()
  671. }
  672. createFilePopover.close()
  673. }
  674. }
  675. func openBlankPage() {
  676. // let fileName: NSString = String(format: "%@.pdf", NSLocalizedString("Untitled", comment: "")) as NSString
  677. // let savePath = fetchUniquePath(fileName.kUrlToPDFFolderPath() as String)
  678. // let filePath = savePath.deletingLastPathComponent
  679. // if FileManager.default.fileExists(atPath: filePath) == false {
  680. // try?FileManager.default.createDirectory(atPath: filePath, withIntermediateDirectories: false)
  681. // }
  682. //
  683. // let pdfDocument = CPDFDocument()
  684. // pdfDocument?.insertPage(CGSize(width: 595, height: 842), at: 0)
  685. // pdfDocument?.write(to: URL(fileURLWithPath: savePath))
  686. // let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
  687. // if controll?.browser?.tabCount() ?? 0 > 1 && KMPreference.shared.openDocumentType == .newWindow{
  688. // self.reopenDocument(forPaths: URL(fileURLWithPath: savePath))
  689. // }else {
  690. // NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: savePath), display: true) { document, documentWasAlreadyOpen, error in
  691. // if error != nil {
  692. // NSApp.presentError(error!)
  693. // } else {
  694. // if document is KMMainDocument {
  695. // let newDocument = document
  696. // (newDocument as! KMMainDocument).isNewCreated = true
  697. // }
  698. // }
  699. // // self.homeContentView?.reloadData()
  700. // }
  701. // }
  702. NSApplication.newBlankDocument()
  703. }
  704. func importFromWebPage() {
  705. self.urlToPDFWindowController = KMURLToPDFWindowController.init(windowNibName: NSNib.Name("KMURLToPDFWindowController"))
  706. self.urlToPDFWindowController?.beginSheetModalForWindow(NSWindow.currentWindow(), completionHandler: { filePath in
  707. if FileManager.default.fileExists(atPath: filePath) {
  708. NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: filePath), display: true) { document, documentWasAlreadyOpen, error in
  709. if error != nil {
  710. NSApp.presentError(error!)
  711. } else {
  712. if document is KMMainDocument {
  713. (document as! KMMainDocument).isNewCreated = true
  714. }
  715. }
  716. // self.homeContentView.reloadData()
  717. }
  718. }
  719. })
  720. }
  721. func importFromScanner() {
  722. let vc = KMDeviceBrowserWindowController.shared
  723. vc.type = .scanner
  724. vc.importScannerFileCallback = { [weak self](url: NSURL) -> Void in
  725. self?.openFile(withFilePath: url as URL)
  726. }
  727. vc.showWindow(NSApp.mainWindow)
  728. }
  729. func importFromCamera() {
  730. let vc = KMDeviceBrowserWindowController.shared
  731. vc.type = .camera
  732. vc.importCameraFileCallback = { [weak self] (url: NSURL) -> Void in
  733. self?.openFile(withFilePath: url as URL)
  734. }
  735. vc.showWindow(NSApp.mainWindow)
  736. }
  737. func newFromImages() {
  738. fastTool_ImageToPDF()
  739. // let openPanel = NSOpenPanel()
  740. // openPanel.allowedFileTypes = KMImageAccessoryController.supportedImageTypes()
  741. // if IAPProductsManager.defaultManager().isAvailableAllFunction {
  742. // openPanel.allowsMultipleSelection = true
  743. // } else {
  744. // openPanel.allowsMultipleSelection = false
  745. // }
  746. // openPanel.message = NSLocalizedString("Select images to create a new document. To select multiple files press cmd ⌘ button on the keyboard and click on the target files one by one.", comment: "")
  747. // openPanel.beginSheetModal(for: NSApp.mainWindow!) { result in
  748. // if result == .OK {
  749. // DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
  750. // debugPrint("缺少图片转PDF")
  751. // let baseWindowController = KMBatchOperateBaseWindowController(windowNibName: "KMBatchOperateBaseWindowController")
  752. // var arr: [KMBatchOperateFile] = []
  753. // for url in openPanel.urls {
  754. // let file = KMBatchOperateFile(filePath: url.path, type: .createPDF)
  755. // arr.append(file)
  756. // }
  757. //
  758. // if #available(macOS 10.13, *) {
  759. // baseWindowController.window?.makeKeyAndOrderFront(nil)
  760. // } else {
  761. // baseWindowController.showWindow(nil)
  762. // }
  763. // baseWindowController.checkNeedPasswordSwitch(toOperateType: .createPDF, files: arr)
  764. // if #available(macOS 10.13, *) {
  765. // baseWindowController.release()
  766. // }
  767. // }
  768. // }
  769. // }
  770. }
  771. //MARK: Purchase
  772. @objc func purchaseStateUpdateNoti() {
  773. if IAPProductsManager.default().isAvailableAllFunction() {
  774. self.advertisementShowView.isHidden = true
  775. let content = self.advertisementTableView.inputData
  776. let item = content?.recommondContentPDFPro
  777. var infos: [KMAdvertisementItemInfo] = []
  778. for info in item?.content ?? [] {
  779. if info.version == "recommondPDF-PDFtoOfficePack" {
  780. if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() == false {
  781. infos.append(info)
  782. }
  783. } else {
  784. infos.append(info)
  785. }
  786. }
  787. item?.content = infos
  788. self.advertisementTableView.inputData = content
  789. }
  790. }
  791. //MARK: - AI
  792. func showAITypeChooseView() -> Void {
  793. let windowVC: AINewConfigWindowController = AINewConfigWindowController.currentWC()
  794. windowVC.chooseCurFileHandle = {[unowned self] windowVC in
  795. if AIChatInfoManager.defaultManager.currentFilePath.isEmpty == false {
  796. let documentArray = NSDocumentController.shared.documents
  797. var didFileEdit: Bool = false
  798. var curDoc: KMMainDocument!
  799. for document in documentArray {
  800. if document.fileURL?.path == AIChatInfoManager.defaultManager.currentFilePath {
  801. didFileEdit = document.isDocumentEdited
  802. curDoc = document as! KMMainDocument
  803. break
  804. }
  805. }
  806. if didFileEdit {
  807. let tempFileURL = FileManager.default.temporaryDirectory.appendingPathComponent(AIChatInfoManager.defaultManager.currentFilePath.lastPathComponent)
  808. if FileManager.default.fileExists(atPath: tempFileURL.path) {
  809. do {
  810. try FileManager.default.removeItem(at: tempFileURL)
  811. } catch {
  812. }
  813. }
  814. if curDoc != nil {
  815. curDoc.mainViewController?.SaveTempPDFDocumentToURLPath(tempPath: tempFileURL.path)
  816. }
  817. }
  818. windowVC.window?.becomeMain()
  819. }
  820. }
  821. if windowVC.window?.isVisible == true && windowVC.didSetOriginFrame == true {
  822. } else {
  823. windowVC.window?.center()
  824. windowVC.didSetOriginFrame = true
  825. }
  826. windowVC.eventLabel = "AITools_Onboard"
  827. windowVC.showWindow(nil)
  828. }
  829. func loadAITipIconGuide() {
  830. if KMGuideInfoWindowController.availableShow(.aiTipIconInfo) {
  831. let guideWC = KMGuideInfoWindowController.currentWC()
  832. guideWC.type = .aiTipIconInfo
  833. guideWC.window?.collectionBehavior = [.canJoinAllSpaces]
  834. guideWC.finishHandle = { [weak self] windowVC, type in
  835. }
  836. if self.view.window != nil {
  837. var rect = self.view.window?.frame
  838. rect!.size.height -= 20
  839. guideWC.window?.setFrame(rect!, display: true)
  840. guideWC.window?.minSize = rect!.size
  841. guideWC.window?.maxSize = rect!.size
  842. self.view.window?.addChildWindow(guideWC.window!, ordered: .above)
  843. guideWC.show()
  844. }
  845. }
  846. }
  847. //MARK: - 引导
  848. func loadFunctionGuide() -> Void {
  849. DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
  850. self.loadNewUserGuide()
  851. }
  852. }
  853. // MARK: - what's New
  854. func loadNewUserGuide() -> Void {
  855. if KMFunctionGuideWindowController.availableShow(.functionMultiAIGuide) {
  856. guideWindowVC = KMFunctionGuideWindowController.init(windowNibName: "KMFunctionGuideWindowController")
  857. guideWindowVC.type = .functionMulti
  858. guideWindowVC.showWindow(nil)
  859. guideWindowVC.window?.orderFront(nil)
  860. KMFunctionGuideWindowController.setDidShowFor(.functionMultiAIGuide)
  861. }
  862. }
  863. func checkRepeatTrialExpiredController() -> Void {
  864. //试用过期提示比较表弹窗
  865. if didTrialExpiredLoad == true {
  866. return
  867. }
  868. didTrialExpiredLoad = true
  869. let singleTon = KMPurchaseCompareDMGWindowController.init()
  870. singleTon.showWindow(nil)
  871. if singleTon.className == KMPurchaseCompareDMGWindowController.className() {
  872. singleTon.updateTitle(NSLocalizedString("Trial Expired, Upgrade to Pro Version", comment: ""), andColor: NSColor(red: 1, green: 59/255, blue: 47/255, alpha: 1))
  873. }
  874. }
  875. func checkRepeatTrialAlertController() -> Void {
  876. //允许二次试用时弹出二次试用引导弹窗
  877. if repeatTrialAlertLoad == true {
  878. return
  879. }
  880. repeatTrialAlertLoad = true
  881. let vc = KMVerificationWindowController.verification(with:.repeatTrialGuide)
  882. vc?.showWindow(nil)
  883. }
  884. //MARK: 试用到期优惠券弹窗
  885. func checkTrialEndCouponInfo() {
  886. KMRequestServerManager.manager.getDeviceRetensionCoupon {[weak self] success, result in
  887. if success == true {
  888. if result != nil {
  889. guard let dataDict = result!["data"] as? NSDictionary else {
  890. return
  891. }
  892. // if dataDict!["pop_up"] as? Bool == true {
  893. let discount = dataDict["discount"] as? Int
  894. let coupon_code = dataDict["coupon_code"] as? String
  895. let end_up_at = dataDict["end_up_at"] as? String
  896. let pop_up = dataDict["pop_up"] as? Bool
  897. if pop_up == true {
  898. if let versionKey = KMAdsInfoManager.shareInstance.couponInfo?.versionKey {
  899. if KMAdsInfoManager.shareInstance.couponInfo?.show == true {
  900. if (UserDefaults.standard.object(forKey: versionKey) != nil) {
  901. } else {
  902. UserDefaults.standard.set("Show", forKey: versionKey)
  903. UserDefaults.standard.synchronize()
  904. self?.showCouponInfoWindow(discount: discount, couponCode: coupon_code, endUpAt: end_up_at)
  905. }
  906. }
  907. }
  908. }
  909. }
  910. } else {
  911. #if VERSION_DMG
  912. if KMVerificationWindowController.allowsShowExpired() {
  913. self?.checkRepeatTrialExpiredController()
  914. } else if KMVerificationWindowController.allowRepeatTrialAlertShow() {
  915. self?.checkRepeatTrialAlertController()
  916. }
  917. #endif
  918. }
  919. }
  920. }
  921. func showCouponInfoWindow(discount: Int?, couponCode: String?, endUpAt: String?) {
  922. if self.couponDueWindowVC == nil {
  923. self.couponDueWindowVC = KMCouponDueWindowController(windowNibName: "KMCouponDueWindowController")
  924. }
  925. self.couponDueWindowVC.disCount = discount ?? 20
  926. self.couponDueWindowVC.couponCode = couponCode ?? ""
  927. self.couponDueWindowVC.endUpAt = endUpAt ?? ""
  928. self.couponDueWindowVC.showWindow(nil)
  929. self.couponDueWindowVC.reloadData()
  930. }
  931. // MARK: - Noti Actions
  932. func deviceVerifyFinishNotification(_ sender: Notification) {
  933. #if VERSION_DMG
  934. #endif
  935. }
  936. @objc func aiTipIconViewShowStateChangeNoti() {
  937. }
  938. }