KMHomeViewController.swift 46 KB

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