KMHomeViewController.swift 46 KB

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