KMGuideInfoWindowController.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. //
  2. // KMGuideInfoWindowController.swift
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2023/12/5.
  6. //
  7. import Cocoa
  8. class KMGuideInfoWindowController: NSWindowController {
  9. @IBOutlet weak var contendBox: NSBox!
  10. @objc var coverView: KMGuideCoverView!
  11. @objc var openFileGuidePanel: KMOpenFileGuidePanel!
  12. @objc var openFileGuideProperty: KMOpenFileGuideProperty!
  13. @objc var openFileGuideToolbar: KMOpenFileGuideToolbar!
  14. @objc var openFileFunctionView: KMOpenFileFunctionView!
  15. @objc var convertGuideView: KMConvertGuideView!
  16. @objc var customColorGuideView: KMCustomColorGuideView!
  17. @objc var aiIconGuideView: KMAIIconGuideView!
  18. @objc var editPDFPopGuideView: KMEditPDFPopGuideView?
  19. @objc var _type: KMGuideInfoType = .none
  20. @objc var openPanelRect: CGRect = .zero
  21. @objc var rightPanelRect: CGRect = .zero
  22. @objc var _digitalBoxRect: CGRect = .zero
  23. @objc var compareItemRect: CGRect = .zero
  24. @objc var aiToolsItemRect: CGRect = .zero
  25. var targetRect: NSRect = .zero
  26. @objc var purchaseHandle: ((_ view: KMGuideInfoWindowController)->Void)?
  27. @objc var normalGuideFinishHandle: ((_ view: KMGuideInfoWindowController)->Void)?
  28. @objc var finishHandle: ((_ view: KMGuideInfoWindowController, _ actionType: KMGuideActionType)->Void)?
  29. @objc var openFileToggleHandle: ((_ view: KMGuideInfoWindowController, _ infoType: KMGuideInfoType)->Void)?
  30. @objc var settingCallback: (()->Void)?
  31. var editPDFPopWindowFlag: Bool = false
  32. var autoClose = false
  33. var autoCloseTimeInterval: CGFloat = 0
  34. private var autoCloseTimer_: Timer?
  35. //MARK: Static Method
  36. @objc static func availableShow(_ type: KMGuideInfoType) -> Bool {
  37. if type == .openFileNormal {
  38. if Self._isArabicLanguage() {
  39. return false
  40. }
  41. if (UserDefaults.standard.object(forKey: kKMGuideInfoOpenFileNormalKey) == nil) {
  42. return true
  43. }
  44. } else if type == .digitalSignGuide {
  45. if Self._isArabicLanguage() {
  46. return false
  47. }
  48. if (UserDefaults.standard.object(forKey: kKMGuideInfoDigitalSignKey) == nil) {
  49. return true
  50. }
  51. } else if type == .pdfCompareGuide {
  52. if Self._isArabicLanguage() {
  53. return false
  54. }
  55. if (UserDefaults.standard.object(forKey: kKMGuideInfoPDFCompareKey) == nil) {
  56. return true
  57. }
  58. } else if type == .convertGuide {
  59. if (UserDefaults.standard.object(forKey: kKMGuideInfoFileConvertKey) == nil) {
  60. return true
  61. }
  62. } else if type == .customColor {
  63. if (UserDefaults.standard.object(forKey: kKMGuideInfoCustomColorKey) == nil) {
  64. return true
  65. }
  66. } else if type == .aiTipIconInfo {
  67. if (UserDefaults.standard.object(forKey: kKMGuideInfoAITipIconViewKey) == nil) {
  68. return true
  69. }
  70. } else if type == .editPDFPopWindow {
  71. if (UserDefaults.standard.object(forKey: kKMGuideInfoEditPDFPopWindowKey) == nil) {
  72. return true
  73. }
  74. } else if type == .measureGuide {
  75. if Self._isArabicLanguage() {
  76. return false
  77. }
  78. if (UserDefaults.standard.object(forKey: kKMGuideInfoMeasureKey) == nil) {
  79. return true
  80. }
  81. } else if type == .aiToolForCheckIn {
  82. if (UserDefaults.standard.object(forKey: kKMGuideInfoAIToolsForCheckInKey) == nil) {
  83. return true
  84. }
  85. } else if type == .messageDiscount {
  86. #if DEBUG
  87. return true
  88. #endif
  89. if (UserDefaults.standard.object(forKey: kKMGuideInfoMessageDiscountKey) == nil) {
  90. return true
  91. }
  92. }
  93. return false
  94. }
  95. static func setDidShowFor(_ type: KMGuideInfoType) -> Void {
  96. if type == .openFileNormal {
  97. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoOpenFileNormalKey)
  98. UserDefaults.standard.synchronize()
  99. } else if type == .digitalSignGuide {
  100. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoDigitalSignKey)
  101. UserDefaults.standard.synchronize()
  102. } else if type == .pdfCompareGuide {
  103. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoPDFCompareKey)
  104. UserDefaults.standard.synchronize()
  105. } else if type == .convertGuide {
  106. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoFileConvertKey)
  107. UserDefaults.standard.synchronize()
  108. } else if type == .customColor {
  109. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoCustomColorKey)
  110. UserDefaults.standard.synchronize()
  111. } else if type == .aiTipIconInfo {
  112. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoAITipIconViewKey)
  113. UserDefaults.standard.synchronize()
  114. } else if type == .editPDFPopWindow {
  115. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoEditPDFPopWindowKey)
  116. UserDefaults.standard.synchronize()
  117. } else if type == .measureGuide {
  118. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoMeasureKey)
  119. UserDefaults.standard.synchronize()
  120. } else if type == .aiToolForCheckIn {
  121. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoAIToolsForCheckInKey)
  122. UserDefaults.standard.synchronize()
  123. } else if type == .messageDiscount {
  124. UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoMessageDiscountKey)
  125. UserDefaults.standard.synchronize()
  126. }
  127. }
  128. static var currentWindowController: KMGuideInfoWindowController!
  129. @objc static func currentWC() -> KMGuideInfoWindowController {
  130. if currentWindowController != nil {
  131. return currentWindowController
  132. } else {
  133. let guideInfoWC: KMGuideInfoWindowController = KMGuideInfoWindowController.init(windowNibName: "KMGuideInfoWindowController")
  134. currentWindowController = guideInfoWC;
  135. return guideInfoWC
  136. }
  137. }
  138. deinit {
  139. print("deinit Action")
  140. }
  141. //MARK: SystemMethod
  142. override func showWindow(_ sender: Any?) {
  143. super.showWindow(sender)
  144. self.show()
  145. }
  146. override func windowDidLoad() {
  147. super.windowDidLoad()
  148. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  149. self.window?.backgroundColor = NSColor.clear
  150. self.window?.contentView?.wantsLayer = true
  151. self.window?.contentView?.layer?.backgroundColor = NSColor.clear.cgColor;
  152. self.window?.isOpaque = false
  153. self.contendBox.fillColor = NSColor.clear
  154. self.coverView = KMGuideCoverView.createFromNib()
  155. self.coverView.frame = self.contendBox.bounds
  156. self.contendBox.contentView = self.coverView
  157. }
  158. //MARK: Setter
  159. @objc var type: KMGuideInfoType {
  160. set {
  161. _type = newValue;
  162. }
  163. get {
  164. return _type;
  165. }
  166. }
  167. @objc var digitalBoxRect: CGRect {
  168. set {
  169. _digitalBoxRect = newValue;
  170. }
  171. get {
  172. return _digitalBoxRect;
  173. }
  174. }
  175. // MARK: Private Methods
  176. // 是否阿拉伯语言
  177. private static func _isArabicLanguage() -> Bool {
  178. return NSLocalizedString("Right click a color and select “Change Color...“.", comment: "") == "انقر بزر الماوس الأيمن فوق اللون وحدد \"تغيير اللون...\"."
  179. }
  180. // MARK: - 定时保存
  181. private func _startTimer() {
  182. _stopTimer()
  183. if autoClose == false {
  184. return
  185. }
  186. self.autoCloseTimer_ = Timer.scheduledTimer(withTimeInterval: autoCloseTimeInterval, repeats: true, block: { [weak self] timer in
  187. self?.closeAction()
  188. if let data = self {
  189. self?.finishHandle?(data, .skip)
  190. }
  191. })
  192. }
  193. private func _stopTimer() {
  194. if (self.autoCloseTimer_ != nil) {
  195. self.autoCloseTimer_?.invalidate()
  196. self.autoCloseTimer_ = nil
  197. }
  198. }
  199. //MARK: Public Method
  200. @objc func show() {
  201. if self.type == .openFileNormal {
  202. self.type = .openFileNormalPanel
  203. }
  204. self.loadGuideInfoView()
  205. }
  206. func clearViews() {
  207. let viewsArr = NSArray.init(array: self.coverView.subviews)
  208. for view in viewsArr {
  209. if view is KMOpenFileGuidePanel {
  210. (view as AnyObject).removeFromSuperview()
  211. } else if view is KMOpenFileGuideProperty {
  212. (view as AnyObject).removeFromSuperview()
  213. } else if view is KMOpenFileGuideToolbar {
  214. (view as AnyObject).removeFromSuperview()
  215. } else if view is KMOpenFileFunctionView {
  216. (view as AnyObject).removeFromSuperview()
  217. } else if view is KMConvertGuideView {
  218. (view as AnyObject).removeFromSuperview()
  219. } else if view is KMCustomColorGuideView {
  220. (view as AnyObject).removeFromSuperview()
  221. } else if view is KMAIIconGuideView {
  222. (view as AnyObject).removeFromSuperview()
  223. } else if view is KMEditPDFPopGuideView {
  224. (view as AnyObject).removeFromSuperview()
  225. } else if view is KMAIToolsForCheckInGuideView {
  226. (view as AnyObject).removeFromSuperview()
  227. } else if view is KMMessageDiscountGuideView {
  228. (view as AnyObject).removeFromSuperview()
  229. }
  230. }
  231. self.coverView.display()
  232. if self.window != nil {
  233. var rect = self.window?.frame
  234. rect?.size.width += 1
  235. self.window?.setFrame(rect!, display: true)
  236. }
  237. }
  238. func loadGuideInfoView() {
  239. DispatchQueue.main.async {
  240. self.clearViews()
  241. self.contendBox.contentView = self.coverView
  242. if self.type == .openFileNormalPanel {
  243. if self.openFileGuidePanel == nil {
  244. self.openFileGuidePanel = KMOpenFileGuidePanel.createFromNib()
  245. }
  246. self.openFileGuidePanel.frame = self.coverView.bounds
  247. self.openFileGuidePanel.autoresizingMask = [.width, .height]
  248. self.openFileGuidePanel.clickHandle = {[weak self] view, actionType in
  249. guard let self = self else { return }
  250. if actionType == .skip {
  251. //Skip->数字签名
  252. //Skip->
  253. guard let callBack = self.normalGuideFinishHandle else {
  254. return
  255. }
  256. callBack(self)
  257. if KMGuideInfoWindowController.availableShow(.digitalSignGuide) &&
  258. (NSWidth(self.window!.frame) > NSMinX(self.digitalBoxRect) + 260) &&
  259. NSMinX(self.digitalBoxRect) > 450 {
  260. self.type = .digitalSignGuide
  261. self.loadGuideInfoView()
  262. } else {
  263. guard let callBack = self.finishHandle else {
  264. return
  265. }
  266. callBack(self, .windowNewFinish)
  267. self.closeAction()
  268. }
  269. } else if actionType == .next {
  270. //Next
  271. self.type = .openFileNormalProperty
  272. self.loadGuideInfoView()
  273. // guard let callBack = self.openFileToggleHandle else {
  274. // return
  275. // }
  276. // callBack(self, .openFileNormalProperty)
  277. // self.closeAction()
  278. }
  279. }
  280. self.openFileGuidePanel.circleRect = self.openPanelRect
  281. self.coverView.addSubview(self.openFileGuidePanel)
  282. self.openFileGuidePanel.updateViewColor()
  283. KMGuideInfoWindowController.setDidShowFor(.openFileNormal)//记录布局介绍
  284. } else if self.type == .openFileNormalProperty {
  285. guard let callBack = self.normalGuideFinishHandle else {
  286. return
  287. }
  288. callBack(self)
  289. if self.openFileGuideProperty == nil {
  290. self.openFileGuideProperty = KMOpenFileGuideProperty.createFromNib()
  291. }
  292. self.openFileGuideProperty.frame = self.coverView.bounds
  293. self.openFileGuideProperty.autoresizingMask = [.width, .height]
  294. self.openFileGuideProperty.clickHandle = {[weak self] view, actionType in
  295. guard let self = self else { return }
  296. if actionType == .skip {
  297. //Skip->数字签名
  298. //Skip->
  299. guard let callBack = self.normalGuideFinishHandle else {
  300. return
  301. }
  302. callBack(self)
  303. if KMGuideInfoWindowController.availableShow(.digitalSignGuide) &&
  304. (NSWidth(self.window!.frame) > NSMinX(self.digitalBoxRect) + 260) &&
  305. NSMinX(self.digitalBoxRect) > 450 {
  306. self.type = .digitalSignGuide
  307. self.loadGuideInfoView()
  308. } else {
  309. guard let callBack = self.finishHandle else {
  310. return
  311. }
  312. callBack(self, .windowNewFinish)
  313. self.closeAction()
  314. }
  315. } else if actionType == .previous {
  316. //Previous
  317. self.type = .openFileNormalPanel
  318. self.loadGuideInfoView()
  319. guard let callBack = self.normalGuideFinishHandle else {
  320. return
  321. }
  322. callBack(self)
  323. // guard let callBack = self.openFileToggleHandle else {
  324. // return
  325. // }
  326. // callBack(self, .openFileNormalPanel)
  327. // self.closeAction()
  328. } else if actionType == .next {
  329. //Next
  330. self.type = .openFileNormalToolbar
  331. self.loadGuideInfoView()
  332. // guard let callBack = self.openFileToggleHandle else {
  333. // return
  334. // }
  335. // callBack(self, .openFileNormalToolbar)
  336. // self.closeAction()
  337. }
  338. }
  339. self.openFileGuideProperty.circleRect = self.rightPanelRect
  340. self.coverView.addSubview(self.openFileGuideProperty)
  341. self.openFileGuideProperty.updateViewColor()
  342. } else if self.type == .openFileNormalToolbar {
  343. if self.openFileGuideToolbar == nil {
  344. self.openFileGuideToolbar = KMOpenFileGuideToolbar.createFromNib()
  345. }
  346. self.openFileGuideToolbar.frame = self.coverView.bounds
  347. self.openFileGuideToolbar.autoresizingMask = [.width, .height]
  348. self.openFileGuideToolbar.clickHandle = {[weak self] view, actionType in
  349. guard let self = self else { return }
  350. if actionType == .skip {
  351. //Skip->数字签名
  352. //Skip->
  353. guard let callBack = self.normalGuideFinishHandle else {
  354. return
  355. }
  356. callBack(self)
  357. if KMGuideInfoWindowController.availableShow(.digitalSignGuide) &&
  358. (NSWidth(self.window!.frame) > NSMinX(self.digitalBoxRect) + 260) &&
  359. NSMinX(self.digitalBoxRect) > 450 {
  360. self.type = .digitalSignGuide
  361. self.loadGuideInfoView()
  362. } else {
  363. guard let callBack = self.finishHandle else {
  364. return
  365. }
  366. callBack(self, .windowNewFinish)
  367. self.closeAction()
  368. }
  369. } else if actionType == .previous {
  370. //Next
  371. self.type = .openFileNormalProperty
  372. self.loadGuideInfoView()
  373. // guard let callBack = self.openFileToggleHandle else {
  374. // return
  375. // }
  376. // callBack(self, .openFileNormalProperty)
  377. // self.closeAction()
  378. } else if actionType == .finish {
  379. guard let callBack = self.normalGuideFinishHandle else {
  380. return
  381. }
  382. callBack(self)
  383. if KMGuideInfoWindowController.availableShow(.digitalSignGuide) &&
  384. (NSWidth(self.window!.frame) > NSMinX(self.digitalBoxRect) + 260) &&
  385. NSMinX(self.digitalBoxRect) > 450 {
  386. self.type = .digitalSignGuide
  387. self.loadGuideInfoView()
  388. } else {
  389. guard let callBack = self.finishHandle else {
  390. return
  391. }
  392. callBack(self, .windowNewFinish)
  393. self.closeAction()
  394. }
  395. }
  396. }
  397. self.coverView.addSubview(self.openFileGuideToolbar)
  398. } else if self.type == .digitalSignGuide || self.type == .pdfCompareGuide {
  399. if self.type == .digitalSignGuide {
  400. KMGuideInfoWindowController.setDidShowFor(.digitalSignGuide)//记录数字签名介绍
  401. } else if self.type == .pdfCompareGuide {
  402. KMGuideInfoWindowController.setDidShowFor(.pdfCompareGuide)//记录文件对比介绍
  403. }
  404. if self.openFileFunctionView == nil {
  405. self.openFileFunctionView = KMOpenFileFunctionView.createFromNib()
  406. }
  407. self.openFileFunctionView.circleRect = self.digitalBoxRect
  408. self.openFileFunctionView.frame = self.coverView.bounds
  409. self.openFileFunctionView.autoresizingMask = [.width, .height]
  410. self.openFileFunctionView.type = self.type
  411. self.openFileFunctionView.clickHandle = {[weak self] view, actionType in
  412. guard let self = self else { return }
  413. if self.type == .digitalSignGuide {
  414. guard let callBack = self.finishHandle else {
  415. return
  416. }
  417. callBack(self, .windowDigitalFinish)
  418. if actionType == .getIt {
  419. self.closeAction()
  420. }
  421. } else if self.type == .pdfCompareGuide {
  422. guard let callBack = self.finishHandle else {
  423. return
  424. }
  425. callBack(self, .windowNewFinish)
  426. if actionType == .getIt {
  427. self.closeAction()
  428. }
  429. }
  430. }
  431. self.coverView.addSubview(self.openFileFunctionView)
  432. self.openFileFunctionView.updateViewColor()
  433. } else if self.type == .measureGuide {
  434. KMGuideInfoWindowController.setDidShowFor(.measureGuide)
  435. if self.openFileFunctionView == nil {
  436. self.openFileFunctionView = KMOpenFileFunctionView.createFromNib()
  437. }
  438. self.openFileFunctionView.circleRect = self.digitalBoxRect
  439. self.openFileFunctionView.frame = self.coverView.bounds
  440. self.openFileFunctionView.autoresizingMask = [.width, .height]
  441. self.openFileFunctionView.type = self.type
  442. self.openFileFunctionView.clickHandle = {[weak self] view, actionType in
  443. guard let self = self else { return }
  444. // guard let callBack = self.finishHandle else {
  445. // return
  446. // }
  447. // callBack(self, .windowDigitalFinish)
  448. if actionType == .getIt {
  449. self.closeAction()
  450. }
  451. }
  452. self.coverView.addSubview(self.openFileFunctionView)
  453. self.openFileFunctionView.updateViewColor()
  454. } else if self.type == .convertGuide {
  455. if self.convertGuideView == nil {
  456. self.convertGuideView = KMConvertGuideView.createFromNib()
  457. }
  458. self.convertGuideView.frame = self.coverView.bounds
  459. self.convertGuideView.autoresizingMask = [.width, .height]
  460. self.convertGuideView.clickHandle = {[weak self] view, actionType in
  461. guard let self = self else { return }
  462. if actionType == .skip {
  463. self.closeAction()
  464. } else if actionType == .purchase {
  465. guard let callBack = self.purchaseHandle else {
  466. return
  467. }
  468. callBack(self)
  469. self.closeAction()
  470. }
  471. }
  472. self.convertGuideView.circleRect = self.digitalBoxRect
  473. self.coverView.addSubview(self.convertGuideView)
  474. self.convertGuideView.updateViewColor()
  475. KMGuideInfoWindowController.setDidShowFor(.convertGuide)//记录转档介绍
  476. } else if self.type == .customColor {
  477. if self.customColorGuideView == nil {
  478. self.customColorGuideView = KMCustomColorGuideView.createFromNib()
  479. }
  480. self.customColorGuideView.frame = self.coverView.bounds
  481. self.customColorGuideView.autoresizingMask = [.width, .height]
  482. self.customColorGuideView.clickHandle = {[weak self] view, actionType in
  483. if actionType == .getIt {
  484. self?.closeAction()
  485. }
  486. }
  487. self.customColorGuideView.circleRect = self.digitalBoxRect
  488. self.customColorGuideView.updateViewColor()
  489. self.coverView.addSubview(self.customColorGuideView)
  490. KMGuideInfoWindowController.setDidShowFor(.customColor)//记录自定义颜色介绍
  491. } else if self.type == .aiTipIconInfo {
  492. if self.aiIconGuideView == nil {
  493. self.aiIconGuideView = KMAIIconGuideView.createFromNib()
  494. }
  495. self.aiIconGuideView.frame = self.coverView.bounds
  496. self.aiIconGuideView.autoresizingMask = [.width, .height]
  497. self.aiIconGuideView.clickHandle = {[weak self] view, actionType in
  498. guard let self = self else { return }
  499. if actionType == .getIt {
  500. self.closeAction()
  501. }
  502. }
  503. self.aiIconGuideView.updateViewColor()
  504. self.aiIconGuideView.wantsLayer = true
  505. self.coverView.addSubview(self.aiIconGuideView)
  506. KMGuideInfoWindowController.setDidShowFor(.aiTipIconInfo)//记录自定义颜色介绍
  507. } else if self.type == .editPDFPopWindow {
  508. self.editPDFPopGuideView = KMEditPDFPopGuideView(contentTop: self.editPDFPopWindowFlag)
  509. self.editPDFPopGuideView?.frame.origin = self.digitalBoxRect.origin
  510. // self.editPDFPopGuideView?.autoresizingMask = [.width, .height]
  511. self.editPDFPopGuideView?.itemClick = { [weak self] idx, _ in
  512. self?.closeAction()
  513. if idx == 0 { // 去设置
  514. self?.settingCallback?()
  515. }
  516. }
  517. // self.aiIconGuideView.updateViewColor()
  518. // self.aiIconGuideView.wantsLayer = true
  519. self.coverView.addSubview(self.editPDFPopGuideView!)
  520. KMGuideInfoWindowController.setDidShowFor(.editPDFPopWindow)//记录
  521. } else if self.type == .aiToolForCheckIn {
  522. let view = KMAIToolsForCheckInGuideView()
  523. let originP = self.aiToolsItemRect.origin
  524. let point = NSMakePoint(originP.x-view.viewSize.width*0.5+20, originP.y-60)
  525. view.frame.origin = point
  526. view.frame.size = view.viewSize
  527. view.itemClick = { [weak self] idx, _ in
  528. self?.closeAction()
  529. if idx == 1 { // try to
  530. if let data = self {
  531. self?.finishHandle?(data, .getIt)
  532. }
  533. }
  534. }
  535. self.coverView.addSubview(view)
  536. // KMGuideInfoWindowController.setDidShowFor(.aiToolForCheckIn)//记录
  537. } else if self.type == .messageDiscount {
  538. let view = KMMessageDiscountGuideView()
  539. let originP = self.targetRect.origin
  540. let point = NSMakePoint(originP.x-40, originP.y-view.viewSize.height+40)
  541. view.frame.origin = point
  542. view.frame.size = view.viewSize
  543. view.itemClick = { [weak self] idx, _ in
  544. self?.closeAction()
  545. }
  546. self.coverView.addSubview(view)
  547. KMGuideInfoWindowController.setDidShowFor(.messageDiscount)//记录
  548. }
  549. if self.autoClose && self.autoCloseTimeInterval > 0 {
  550. self._startTimer()
  551. }
  552. }
  553. }
  554. func closeAction() {
  555. self.clearViews()
  556. self.close()
  557. _stopTimer()
  558. }
  559. }
  560. extension KMGuideInfoWindowController: KMInterfaceThemeChangedProtocol {
  561. func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
  562. self.editPDFPopGuideView?.interfaceThemeDidChanged(appearance)
  563. }
  564. }