KMHomeViewController.swift 46 KB

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