// // AccountPwdChangedWindowController.swift // PDF Reader Pro // // Created by User-Tangchao on 2024/10/31. // import Cocoa class AccountPwdChangedWindowController: NSWindowController { @IBOutlet weak var contentBox: NSBox! @IBOutlet weak var iconIv: NSImageView! @IBOutlet weak var iconIv2: NSImageView! @IBOutlet weak var tipLabel: NSTextField! @IBOutlet weak var okButton: NSButton! var itemClick: KMCommonClickBlock? convenience init() { self.init(windowNibName: "AccountPwdChangedWindowController") } static let shared = AccountPwdChangedWindowController() override func windowDidLoad() { super.windowDidLoad() // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. self.window?.appearance = NSAppearance(named: .aqua) self.window?.backgroundColor = .clear self.window?.contentView?.wantsLayer = true self.window?.contentView?.layer?.backgroundColor = .clear self.window?.isMovableByWindowBackground = true self.contentBox.borderWidth = 0 self.contentBox.cornerRadius = 8 self.contentBox.fillColor = .white self.iconIv.image = NSImage(named: "KMImageNamePwdChangedIcon") self.iconIv2.image = NSImage(named: "KMImageNamePwdChangedIcon2") 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: "") tipLabel.isEditable = false tipLabel.isSelectable = true tipLabel.allowsEditingTextAttributes = true tipLabel.textColor = NSColor.black tipLabel.font = NSFont.SFProTextRegularFont(11.0) let localizedString = NSLocalizedString("Your account has been logged in on another device. If you do not request the login, %@", comment: "") let linkString = NSLocalizedString("please change your password.", comment: "") let fullString1 = String(format: localizedString, linkString) let attributedString1 = NSMutableAttributedString(string: fullString1) let Range = (fullString1 as NSString).range(of: linkString) let linkColor1 = KMAppearance.themeColor() let font1 = NSFont.SFProTextRegularFont(11.0) // 与普通文本相同的字体 attributedString1.addAttributes([ // .foregroundColor: NSColor(hex: "#999999"), .font: font1 ], range: (fullString1 as NSString).range(of: fullString1)) attributedString1.addAttributes([ .foregroundColor: linkColor1, .link: NSLocalizedString(kResetpasswordUrlString, comment: ""), .font: font1 ], range: Range) self.tipLabel.attributedStringValue = attributedString1 self.okButton.title = NSLocalizedString("OK", comment: "") self.okButton.setTitleColor(.white) self.okButton.wantsLayer = true self.okButton.layer?.cornerRadius = 4 self.okButton.layer?.backgroundColor = KMAppearance.themeColor().cgColor self.okButton.target = self self.okButton.action = #selector(okAction) } @objc func okAction() { self.itemClick?(1) self.window?.orderOut(nil) VerificationManager.default().unactivateDeviceWithcomplention { status, infoDict, err in VerificationManager.default().verification {status1 , infoDict1, err1 in } } } }