AccountPwdChangedWindowController.swift 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // AccountPwdChangedWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/10/31.
  6. //
  7. import Cocoa
  8. class AccountPwdChangedWindowController: NSWindowController {
  9. @IBOutlet weak var contentBox: NSBox!
  10. @IBOutlet weak var iconIv: NSImageView!
  11. @IBOutlet weak var iconIv2: NSImageView!
  12. @IBOutlet weak var tipLabel: NSTextField!
  13. @IBOutlet weak var okButton: NSButton!
  14. var itemClick: KMCommonClickBlock?
  15. convenience init() {
  16. self.init(windowNibName: "AccountPwdChangedWindowController")
  17. }
  18. static let shared = AccountPwdChangedWindowController()
  19. override func windowDidLoad() {
  20. super.windowDidLoad()
  21. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  22. self.window?.appearance = NSAppearance(named: .aqua)
  23. self.window?.backgroundColor = .clear
  24. self.window?.contentView?.wantsLayer = true
  25. self.window?.contentView?.layer?.backgroundColor = .clear
  26. self.window?.isMovableByWindowBackground = true
  27. self.contentBox.borderWidth = 0
  28. self.contentBox.cornerRadius = 8
  29. self.contentBox.fillColor = .white
  30. self.iconIv.image = NSImage(named: "KMImageNamePwdChangedIcon")
  31. self.iconIv2.image = NSImage(named: "KMImageNamePwdChangedIcon2")
  32. self.tipLabel.stringValue = NSLocalizedString("Your account has been logged in on another device. If you do not request the login, please change your password.", comment: "")
  33. tipLabel.isEditable = false
  34. tipLabel.isSelectable = true
  35. tipLabel.allowsEditingTextAttributes = true
  36. tipLabel.textColor = NSColor.black
  37. tipLabel.font = NSFont.SFProTextRegularFont(11.0)
  38. let localizedString = NSLocalizedString("Your account has been logged in on another device. If you do not request the login, %@", comment: "")
  39. let linkString = NSLocalizedString("please change your password.", comment: "")
  40. let fullString1 = String(format: localizedString, linkString)
  41. let attributedString1 = NSMutableAttributedString(string: fullString1)
  42. let Range = (fullString1 as NSString).range(of: linkString)
  43. let linkColor1 = KMAppearance.themeColor()
  44. let font1 = NSFont.SFProTextRegularFont(11.0) // 与普通文本相同的字体
  45. attributedString1.addAttributes([
  46. // .foregroundColor: NSColor(hex: "#999999"),
  47. .font: font1
  48. ], range: (fullString1 as NSString).range(of: fullString1))
  49. attributedString1.addAttributes([
  50. .foregroundColor: linkColor1,
  51. .link: NSLocalizedString(kResetpasswordUrlString, comment: ""),
  52. .font: font1
  53. ], range: Range)
  54. self.tipLabel.attributedStringValue = attributedString1
  55. self.okButton.title = NSLocalizedString("OK", comment: "")
  56. self.okButton.setTitleColor(.white)
  57. self.okButton.wantsLayer = true
  58. self.okButton.layer?.cornerRadius = 4
  59. self.okButton.layer?.backgroundColor = KMAppearance.themeColor().cgColor
  60. self.okButton.target = self
  61. self.okButton.action = #selector(okAction)
  62. }
  63. @objc func okAction() {
  64. self.itemClick?(1)
  65. self.window?.orderOut(nil)
  66. VerificationManager.default().unactivateDeviceWithcomplention { status, infoDict, err in
  67. VerificationManager.default().verification {status1 , infoDict1, err1 in
  68. }
  69. }
  70. }
  71. }