KMHomeViewController.swift 45 KB

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