Browse Source

【2025】【批量】安全功能完善

lizhe 2 months ago
parent
commit
25328dfc5b

+ 16 - 3
PDF Office/PDF Master/Class/PDFTools/AddPassword/View/KMSecurityContentView.swift

@@ -10,16 +10,19 @@ import KMComponentLibrary
 
 class KMSecurityContentView: BaseXibView {
 
+    @IBOutlet weak var titleLabel: NSTextField!
     @IBOutlet var openPwdCheckBox: ComponentCheckBox!
     @IBOutlet var openPasswordView: ComponentPasswordView!
+    @IBOutlet weak var openPwdCheckBoxWidthConstraint: NSLayoutConstraint!
     
     @IBOutlet var ownerPwdCheckBox: ComponentCheckBox!
     @IBOutlet var ownerPasswordView: ComponentPasswordView!
+    @IBOutlet weak var ownerPwdCheckBoxWidthConstraint: NSLayoutConstraint!
     
     @IBOutlet var notPrintCheckBox: ComponentCheckBox!
     @IBOutlet var notCopyCheckBox: ComponentCheckBox!
     
-    private var model: KMSecureEncryptModel = KMSecureEncryptModel()
+    var model: KMSecureEncryptModel = KMSecureEncryptModel()
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -34,9 +37,15 @@ class KMSecurityContentView: BaseXibView {
     }
     
     func updateLanguage() {
-         
+        titleLabel.stringValue = KMLocalizedString("Password Security Settings")
+        titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
+        titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-medium")
+        
         openPwdCheckBox.properties = ComponentCheckBoxProperty(size: .s, state: .normal, showhelp: true, text: KMLocalizedString("Require a password to open the document.", comment: ""), checkboxType: .normal)
         openPwdCheckBox.setTarget(self, action: #selector(openPasswordButtonAction(_:)))
+        openPwdCheckBox.reloadData()
+        
+        openPwdCheckBoxWidthConstraint.constant = openPwdCheckBox.properties.propertyInfo.viewWidth
         
         openPasswordView.properties = ComponentPasswordProperty(size: .m,
                                                                 state: .normal,
@@ -45,7 +54,9 @@ class KMSecurityContentView: BaseXibView {
                                                                 text: "",
                                                                 isDisabled: false,
                                                                 errorText: "Here is the error message description.")
+        openPasswordView.toolTip = KMLocalizedString("Here is the error message description.")
         openPasswordView.delegate = self
+        openPasswordView.reloadData()
         
         ownerPwdCheckBox.properties = ComponentCheckBoxProperty(size: .s, state: .normal, showhelp: true, text: KMLocalizedString("Require a password to open the document.", comment: ""), checkboxType: .normal)
         ownerPwdCheckBox.setTarget(self, action: #selector(ownerPaasswordButtonAction(_:)))
@@ -57,7 +68,9 @@ class KMSecurityContentView: BaseXibView {
                                                                  text: "",
                                                                  isDisabled: false,
                                                                  errorText: "Here is the error message description.")
+        openPasswordView.toolTip = KMLocalizedString("Here is the error message description.")
         ownerPasswordView.delegate = self
+        ownerPwdCheckBoxWidthConstraint.constant = openPwdCheckBox.properties.propertyInfo.viewWidth
         
         notPrintCheckBox.properties = ComponentCheckBoxProperty(size: .s, state: .normal, text: KMLocalizedString("Restrict document printing", comment: ""), checkboxType: .normal)
         notPrintCheckBox.setTarget(self, action: #selector(printButtonAction(_:)))
@@ -120,7 +133,7 @@ extension KMSecurityContentView {
     
     @objc func ownerPaasswordButtonAction(_ sender: Any) {
         self.model.ownerPasswordOn = self.ownerPwdCheckBox.properties.checkboxType == .selected ? true:false
-//        self.updateOwnerButtonState()
+        self.updateOwnerButtonState()
     }
     
     @objc func printButtonAction(_ sender: Any) {

+ 12 - 9
PDF Office/PDF Master/Class/PDFTools/AddPassword/View/KMSecurityContentView.xib

@@ -12,8 +12,11 @@
                 <outlet property="notPrintCheckBox" destination="ZSr-rb-gs5" id="69A-bw-6Gm"/>
                 <outlet property="openPasswordView" destination="PtN-Hn-IB7" id="vXT-2g-YNp"/>
                 <outlet property="openPwdCheckBox" destination="l54-C4-3kg" id="OuL-Mg-iNd"/>
+                <outlet property="openPwdCheckBoxWidthConstraint" destination="zEj-Zz-gDs" id="jqT-1z-nhN"/>
                 <outlet property="ownerPasswordView" destination="Y9S-Xp-aqI" id="Qoc-tc-1P2"/>
                 <outlet property="ownerPwdCheckBox" destination="Gnr-oV-Gj2" id="Le3-id-Oo2"/>
+                <outlet property="ownerPwdCheckBoxWidthConstraint" destination="pFf-3D-IcM" id="cmF-DA-I0F"/>
+                <outlet property="titleLabel" destination="y6f-Nd-ccg" id="tyZ-jj-LYy"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -29,38 +32,39 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="l54-C4-3kg" customClass="ComponentCheckBox" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="190" width="379" height="32"/>
+                                <rect key="frame" x="0.0" y="202" width="379" height="20"/>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="32" id="Xqt-ZP-6xR"/>
+                                    <constraint firstAttribute="height" constant="20" id="Xqt-ZP-6xR"/>
+                                    <constraint firstAttribute="width" constant="379" id="zEj-Zz-gDs"/>
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="PtN-Hn-IB7" customClass="ComponentPasswordView" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="150" width="379" height="32"/>
+                                <rect key="frame" x="0.0" y="162" width="379" height="32"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="32" id="QIn-0v-2Tz"/>
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Gnr-oV-Gj2" customClass="ComponentCheckBox" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="114" width="269" height="20"/>
+                                <rect key="frame" x="0.0" y="126" width="379" height="20"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="20" id="1qs-wC-ppd"/>
-                                    <constraint firstAttribute="width" constant="269" id="9B8-0q-3Vg"/>
+                                    <constraint firstAttribute="width" constant="379" id="pFf-3D-IcM"/>
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="ZSr-rb-gs5" customClass="ComponentCheckBox" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="42" width="379" height="32"/>
+                                <rect key="frame" x="0.0" y="54" width="379" height="32"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="32" id="fWG-mn-Dov"/>
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="o5a-YI-2ZF" customClass="ComponentCheckBox" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="10" width="379" height="32"/>
+                                <rect key="frame" x="0.0" y="22" width="379" height="32"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="32" id="2vX-oX-hF5"/>
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Y9S-Xp-aqI" customClass="ComponentPasswordView" customModule="KMComponentLibrary">
-                                <rect key="frame" x="0.0" y="74" width="379" height="32"/>
+                                <rect key="frame" x="0.0" y="86" width="379" height="32"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="32" id="HGD-UE-gTQ"/>
                                 </constraints>
@@ -79,7 +83,6 @@
                             <constraint firstItem="l54-C4-3kg" firstAttribute="top" secondItem="WNK-v5-8Tj" secondAttribute="top" id="bhb-h1-c5w"/>
                             <constraint firstItem="ZSr-rb-gs5" firstAttribute="top" secondItem="Y9S-Xp-aqI" secondAttribute="bottom" id="dQ4-eE-sCe"/>
                             <constraint firstItem="PtN-Hn-IB7" firstAttribute="leading" secondItem="WNK-v5-8Tj" secondAttribute="leading" id="hAc-JW-IPm"/>
-                            <constraint firstAttribute="trailing" secondItem="l54-C4-3kg" secondAttribute="trailing" id="qhJ-oN-Deu"/>
                             <constraint firstItem="PtN-Hn-IB7" firstAttribute="top" secondItem="l54-C4-3kg" secondAttribute="bottom" constant="8" id="r5k-w9-eRf"/>
                             <constraint firstAttribute="trailing" secondItem="PtN-Hn-IB7" secondAttribute="trailing" id="u83-Kt-XHk"/>
                             <constraint firstItem="o5a-YI-2ZF" firstAttribute="top" secondItem="ZSr-rb-gs5" secondAttribute="bottom" id="wIT-Hc-JAf"/>

+ 4 - 28
PDF Office/PDF Master/Class/PDFTools/AddPassword/View/KMSecurityView.swift

@@ -15,7 +15,6 @@ typealias KMSecurityViewDoneAction = (_ view: KMSecurityView, _ model: KMSecureE
 class KMSecurityView: BaseXibView {
     
     @IBOutlet weak var box1: NSBox!
-    @IBOutlet weak var boxLabel1: NSTextField!
     
     @IBOutlet var batchButton: ComponentButton!
     @IBOutlet var cancelButton: ComponentButton!
@@ -25,6 +24,7 @@ class KMSecurityView: BaseXibView {
     @IBOutlet var cancelWidthConst: NSLayoutConstraint!
     @IBOutlet var doneWidthConst: NSLayoutConstraint!
     
+    @IBOutlet weak var securityContentView: KMSecurityContentView!
     
     var batchAction: KMSecurityViewBatchAction?
     var cancelAction: KMSecurityViewCancelAction?
@@ -45,19 +45,13 @@ class KMSecurityView: BaseXibView {
     }
     
     override func setup() {
+        self.securityContentView.model = self.model
         
         updateLanguage()
-        
-        self.updateOwnerButtonState()
-        
     }
     
     func updateLanguage() {
         box1.fillColor = NSColor.clear
-         
-        boxLabel1.stringValue = KMLocalizedString("Password Security Settings")
-        boxLabel1.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
-        boxLabel1.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-medium")
                 
         batchButton.properties = ComponentButtonProperty(type: .default_tertiary,
                                                          size: .s,
@@ -86,6 +80,7 @@ class KMSecurityView: BaseXibView {
     }
     
     func reloadData() {
+        
         self.updateEncryptButtonEnabledState()
     }
     
@@ -127,25 +122,6 @@ extension KMSecurityView {
         }
         doneButton.reloadData()
     }
-    
-    func updatePasswordState() {
-        self.reloadData()
-    }
-    
-    func updateOwnerButtonState() {
-        if self.model.ownerPasswordOn {
-            self.model.printEnabled = true
-            self.model.editEnabled = true
-            self.model.printAllowed = false
-            self.model.editAllowed = false
-        } else {
-            self.model.printEnabled = false
-            self.model.editEnabled = false
-            self.model.printAllowed = true
-            self.model.editAllowed = true
-        }
-        self.reloadData()
-    }
 }
 
 extension KMSecurityView {
@@ -166,7 +142,7 @@ extension KMSecurityView {
     }
     
     @objc func doneButtonAction(_ sender: Any) {
-        self.updatePasswordState()
+        self.securityContentView.updatePasswordState()
         
         if model.ownerPassword == model.openPassword {
             let alert = NSAlert()

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/AddPassword/View/KMSecurityView.xib

@@ -15,6 +15,7 @@
                 <outlet property="cancelWidthConst" destination="xKm-qz-lkn" id="WpQ-bX-gLt"/>
                 <outlet property="doneButton" destination="nBe-xF-dqG" id="Agv-Be-fCG"/>
                 <outlet property="doneWidthConst" destination="Vbh-dU-jah" id="iva-pB-Vnz"/>
+                <outlet property="securityContentView" destination="6hv-cP-65h" id="r7J-OW-bjt"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>

+ 5 - 4
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/KMBatchSettingView.swift

@@ -177,7 +177,7 @@ extension KMBatchSettingView: KMBatchSettingViewExport {
                         fileName = NSLocalizedString("Untitled", comment: "")
                     }
                     
-                    var convert = self.addConvertParameter(settingData)
+                    let convert = self.addConvertParameter(settingData)
                     
                     //获取page
                     var pages:[Int] = []
@@ -404,7 +404,7 @@ extension KMBatchSettingView: KMBatchSettingViewExport {
                     //权限密码
                     if data.isPermission &&
                         !data.permissionString.isEmpty {
-                        options.updateValue(data.permissionString, forKey: .userPasswordOption)
+                        options.updateValue(data.permissionString, forKey: .ownerPasswordOption)
                     }
                         
                     // 限制打印
@@ -421,8 +421,9 @@ extension KMBatchSettingView: KMBatchSettingViewExport {
                         options.updateValue(true, forKey: .allowsCopyingOption)
                     }
                     
-                        
-                    let result = docuemt!.write(to: URL(fileURLWithPath: path), withOptions: options)
+                    
+                    let result = docuemt!.write(toFile: path, withOptions: options)
+//                    let result = docuemt!.write(to: URL(fileURLWithPath: path), withOptions: options)
                     if result {
                         KMPrint("成功")
                     } else {

+ 41 - 138
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/Security/KMBatchSecurityView.swift

@@ -11,19 +11,8 @@ import KMComponentLibrary
 class KMBatchSecurityView: KMBatchSettingItemView {
     @IBOutlet weak var titleLabel: NSTextField!
     @IBOutlet weak var titleContentView: NSView!
-    //    @IBOutlet weak var titleLabel: NSTextField!
-//    @IBOutlet weak var openPasswordButton: KMImageTitleButton!
-//    
-//    @IBOutlet weak var openPasswordTextFieldContentView: NSView!
-////    @IBOutlet weak var openPasswordTextField: FocusAwareSecureTextField!
-//    @IBOutlet weak var permissionButton: KMImageTitleButton!
-//    
-//    @IBOutlet weak var permissionTextFieldContentView: NSView!
-////    @IBOutlet weak var permissionTextfield: FocusAwareSecureTextField!
-//    @IBOutlet weak var documentPrintButton: KMImageTitleButton!
-//    @IBOutlet weak var contentCopyButton: KMImageTitleButton!
-    
-    @IBOutlet weak var encryptButton: NSButton!
+    @IBOutlet weak var encryptButton: ComponentButton!
+    @IBOutlet weak var securityContentView: KMSecurityContentView!
     
     var data: KMBatchSecurityViewModel = KMBatchSecurityViewModel()
     var presenter: KMBatchSecurityViewPresenter = KMBatchSecurityViewPresenter()
@@ -39,129 +28,61 @@ class KMBatchSecurityView: KMBatchSettingItemView {
         
         self.titleContentView.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
         
-        self.presenter.initPresenter(view: self)
-        
-//        self.openPasswordButton.title = NSLocalizedString("Document Open Password", comment: "")
-//        self.openPasswordButton.imageName = "btn_checkbox_unsel_on"
-//        self.openPasswordButton.action = { [unowned self] (view, button) in
-//            self.presenter.openPasswordButtonAction(sender: button)
-//        }
-//        
-//        self.permissionButton.title = NSLocalizedString("Document Permission Password", comment: "")
-//        self.permissionButton.imageName = "btn_checkbox_unsel_on"
-//        self.permissionButton.action = { [unowned self] (view, button) in
-//            self.presenter.permissionButtonAction(sender: button)
-//        }
-//        
-//        //
-//        self.openPasswordTextFieldContentView.border()
-//        self.openPasswordTextFieldContentView.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
-//        //
-////        self.openPasswordTextField.placeholderAttributedString = NSAttributedString.init(string: "Open Password", attributes: [NSAttributedString.Key.font: NSFont.SFProTextRegularFont(14), NSAttributedString.Key.foregroundColor: NSColor.km_init(hex: "#94989C")])
-////        self.openPasswordTextField.textColor = NSColor.km_init(hex: "#252629")
-////        self.openPasswordTextField.font = NSFont.SFProTextRegularFont(14.0)
-//        //
-//        self.permissionTextFieldContentView.border()
-//        self.permissionTextFieldContentView.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
-//        //
-////        self.permissionTextfield.placeholderAttributedString = NSAttributedString.init(string: "Permission Password", attributes: [NSAttributedString.Key.font: NSFont.SFProTextRegularFont(14), NSAttributedString.Key.foregroundColor: NSColor.km_init(hex: "#94989C")])
-////        self.permissionTextfield.textColor = NSColor.km_init(hex: "#252629")
-////        self.permissionTextfield.font = NSFont.SFProTextRegularFont(14.0)
-//        //
-//        self.documentPrintButton.title = NSLocalizedString("Restrict document printing", comment: "")
-//        self.documentPrintButton.imageName = "btn_checkbox_unsel_on"
-//        self.documentPrintButton.action = { [unowned self] (view, button) in
-//            self.presenter.documentPrintButtonAction(sender: button)
-//        }
-//        
-//        self.contentCopyButton.title = NSLocalizedString("Restrict content copying", comment: "")
-//        self.contentCopyButton.imageName = "btn_checkbox_unsel_on"
-//        self.contentCopyButton.action = { [unowned self] (view, button) in
-//            self.presenter.contentCopyButtonAction(sender: button)
-//        }
-        
-//        self.titleLabel.textColor = NSColor.km_init(hex: "#252629")
-//        self.titleLabel.stringValue = NSLocalizedString("Settings", comment: "")
-//        self.titleLabel.font = NSFont.SFProTextRegularFont(16.0)
-        
-        self.encryptButton.wantsLayer = true
-        self.encryptButton.layer?.cornerRadius = 4
-        self.encryptButton.contentTintColor = NSColor.km_init(hex: "#FFFFFF")
-        self.encryptButton.stringValue = NSLocalizedString("Compress", comment: "")
-        self.encryptButton.font = NSFont.SFProTextRegularFont(14.0)
-        self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
+        self.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
+        self.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-bold")
         
-//        self.openPasswordButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
-//        self.openPasswordButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
+        self.presenter.initPresenter(view: self)
         
-//        self.permissionButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
-//        self.permissionButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
-//        
-//        self.documentPrintButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
-//        self.documentPrintButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
-//        
-//        self.contentCopyButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
-//        self.contentCopyButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
+        self.encryptButton.properties = ComponentButtonProperty(type: .primary,
+                                                                size: .m,
+                                                                state: .normal,
+                                                                buttonText: KMLocalizedString("Apply"),
+                                                                keepPressState: false)
+        self.encryptButton.setTarget(self, action: #selector(encryptButtonAction(_:)))
+        self.encryptButton.reloadData()
     }
     
     override func reloadData() {
-        
-//        if data.isOpenPassword {
-//            self.openPasswordButton.imageName = "btn_checkbox_sel_on"
-////            self.openPasswordTextField.isEnabled = true
-//        } else {
-//            self.openPasswordButton.imageName = "btn_checkbox_unsel_on"
-////            self.openPasswordTextField.isEnabled = false
-//        }
-//        
-//        if data.isPermission {
-//            self.permissionButton.imageName = "btn_checkbox_sel_on"
-////            self.permissionTextfield.isEnabled = true
-//            self.documentPrintButton.isEnabled = true
-//            self.contentCopyButton.isEnabled = true
-//        } else {
-//            self.permissionButton.imageName = "btn_checkbox_unsel_on"
-////            self.permissionTextfield.isEnabled = false
-//            self.documentPrintButton.isEnabled = false
-//            self.contentCopyButton.isEnabled = false
-//        }
-//        
-//        if data.restrictOptions.contains(.print) {
-//            self.documentPrintButton.imageName = "btn_checkbox_sel_on"
-//        } else {
-//            self.documentPrintButton.imageName = "btn_checkbox_unsel_on"
-//        }
-//        
-//        if data.restrictOptions.contains(.copy) {
-//            self.contentCopyButton.imageName = "btn_checkbox_sel_on"
-//        } else {
-//            self.contentCopyButton.imageName = "btn_checkbox_unsel_on"
-//        }
-        
         if (self.filesData.count != 0) {
-            self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#1770F4").cgColor
-            self.encryptButton.isEnabled = true
+            self.encryptButton.properties.isDisabled = false
         } else {
-            self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
-            self.encryptButton.isEnabled = false
+            self.encryptButton.properties.isDisabled = true
         }
     }
 }
 
 protocol KMBatchSecurityViewAction { }
 extension KMBatchSecurityView: KMBatchCompressViewAction {
-    @IBAction func encryptButtonAction(_ sender: NSButton) {
-//        guard self.presenter.changePermissionString(self.permissionTextfield.stringValue) else {
-//            return
-//        }
+    func encryptButtonAction(_ sender: ComponentButton) {
+        self.securityContentView.updatePasswordState()
+        
+        self.data.openPasswordString = self.securityContentView.model.openPassword
+        self.data.isOpenPassword = self.securityContentView.model.openPasswordOn
+        
+        self.data.permissionString = self.securityContentView.model.ownerPassword
+        self.data.isPermission = self.securityContentView.model.ownerPasswordOn
         
-//        guard self.presenter.changeOpenPasswordString(self.openPasswordTextField.stringValue) else {
-//            return
-//        }
+        if self.securityContentView.model.printAllowed {
+            self.data.restrictOptions.insert(.print)
+        } else {
+            self.data.restrictOptions.remove(.print)
+        }
+        
+        if self.securityContentView.model.editAllowed {
+            self.data.restrictOptions.insert(.copy)
+        } else {
+            self.data.restrictOptions.remove(.copy)
+        }
         
-        if self.batchExport != nil {
-            self.batchExport!(self, self.data)
+        if self.data.openPasswordString == self.data.permissionString {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = KMLocalizedString("The Open and Owner passwords cannot be the same. Please change either the Open or the Owner Password.", comment: "")
+            alert.runModal()
+            return
         }
+        
+        self.batchExport?(self, self.data)
     }
 }
 
@@ -171,21 +92,3 @@ extension KMBatchSecurityView: KMBatchSecurityViewPresenterDelegate {
         self.reloadData()
     }
 }
-
-
-//class FocusAwareSecureTextField: NSSecureTextField {
-//    var onFocus: () -> Void = {}
-//    var onUnfocus: () -> Void = {}
-//
-//    override func becomeFirstResponder() -> Bool {
-//        onFocus()
-//        let textView = window?.fieldEditor(true, for: nil) as? NSTextView
-//        textView?.insertionPointColor = NSColor.km_init(hex: "#252629")
-//        return super.becomeFirstResponder()
-//    }
-//
-//    override func resignFirstResponder() -> Bool {
-//        onUnfocus()
-//        return super.resignFirstResponder()
-//    }
-//}

+ 22 - 19
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/Security/KMBatchSecurityView.xib

@@ -8,7 +8,8 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMBatchSecurityView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
-                <outlet property="encryptButton" destination="uB2-GY-4bP" id="hGh-IZ-jCW"/>
+                <outlet property="encryptButton" destination="IjA-2x-uRm" id="4gJ-wy-7OQ"/>
+                <outlet property="securityContentView" destination="U3c-lO-kzl" id="yR3-6R-WS0"/>
                 <outlet property="titleContentView" destination="FHv-rX-2ri" id="QFV-zH-XgX"/>
                 <outlet property="titleLabel" destination="yqu-HU-Iat" id="UXB-Sa-LNl"/>
             </connections>
@@ -19,19 +20,6 @@
             <rect key="frame" x="0.0" y="0.0" width="246" height="533"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
-                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uB2-GY-4bP">
-                    <rect key="frame" x="16" y="16" width="214" height="32"/>
-                    <buttonCell key="cell" type="square" title="Encrypt" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="pr4-to-5LQ">
-                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                        <font key="font" metaFont="system"/>
-                    </buttonCell>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="32" id="aZB-z9-HS0"/>
-                    </constraints>
-                    <connections>
-                        <action selector="encryptButtonAction:" target="-2" id="Vcp-TS-4Ur"/>
-                    </connections>
-                </button>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="FHv-rX-2ri">
                     <rect key="frame" x="0.0" y="493" width="246" height="40"/>
                     <subviews>
@@ -51,20 +39,35 @@
                     </constraints>
                 </customView>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="U3c-lO-kzl" customClass="KMSecurityContentView" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                    <rect key="frame" x="16" y="48" width="214" height="445"/>
+                    <rect key="frame" x="16" y="72" width="214" height="421"/>
+                </customView>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="Shd-Wd-Epd">
+                    <rect key="frame" x="0.0" y="0.0" width="246" height="72"/>
+                    <subviews>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="IjA-2x-uRm" customClass="ComponentButton" customModule="KMComponentLibrary">
+                            <rect key="frame" x="16" y="16" width="214" height="40"/>
+                        </customView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstAttribute="trailing" secondItem="IjA-2x-uRm" secondAttribute="trailing" constant="16" id="Cem-BT-b3L"/>
+                        <constraint firstItem="IjA-2x-uRm" firstAttribute="leading" secondItem="Shd-Wd-Epd" secondAttribute="leading" constant="16" id="Pvk-WV-kXy"/>
+                        <constraint firstAttribute="bottom" secondItem="IjA-2x-uRm" secondAttribute="bottom" constant="16" id="dMa-jm-mVa"/>
+                        <constraint firstAttribute="height" constant="72" id="kiR-0e-aHU"/>
+                        <constraint firstItem="IjA-2x-uRm" firstAttribute="top" secondItem="Shd-Wd-Epd" secondAttribute="top" constant="16" id="vgL-jU-vKF"/>
+                    </constraints>
                 </customView>
             </subviews>
             <constraints>
                 <constraint firstItem="U3c-lO-kzl" firstAttribute="top" secondItem="FHv-rX-2ri" secondAttribute="bottom" id="5uq-z4-stt"/>
                 <constraint firstItem="FHv-rX-2ri" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="9Ek-Q1-Atq"/>
-                <constraint firstItem="uB2-GY-4bP" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="16" id="FfM-WA-JMc"/>
-                <constraint firstAttribute="trailing" secondItem="uB2-GY-4bP" secondAttribute="trailing" constant="16" id="Sl4-Oi-Irp"/>
-                <constraint firstAttribute="bottom" secondItem="uB2-GY-4bP" secondAttribute="bottom" constant="16" id="pL8-sI-T5n"/>
+                <constraint firstAttribute="trailing" secondItem="Shd-Wd-Epd" secondAttribute="trailing" id="AE3-BF-73O"/>
+                <constraint firstAttribute="bottom" secondItem="Shd-Wd-Epd" secondAttribute="bottom" id="R0R-bz-unb"/>
+                <constraint firstItem="Shd-Wd-Epd" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="fXd-o3-cwP"/>
+                <constraint firstItem="Shd-Wd-Epd" firstAttribute="top" secondItem="U3c-lO-kzl" secondAttribute="bottom" id="fuG-oT-CNE"/>
                 <constraint firstItem="FHv-rX-2ri" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="qA6-X0-IUM"/>
                 <constraint firstAttribute="trailing" secondItem="U3c-lO-kzl" secondAttribute="trailing" constant="16" id="qWx-3O-XXW"/>
                 <constraint firstAttribute="trailing" secondItem="FHv-rX-2ri" secondAttribute="trailing" id="sbe-NC-2Xr"/>
                 <constraint firstItem="U3c-lO-kzl" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="16" id="uBS-gQ-39c"/>
-                <constraint firstItem="uB2-GY-4bP" firstAttribute="top" secondItem="U3c-lO-kzl" secondAttribute="bottom" id="zsz-0V-Mz5"/>
             </constraints>
             <point key="canvasLocation" x="-150" y="244.5"/>
         </customView>

+ 1 - 0
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/Security/Model/KMBatchSecurityViewModel.swift

@@ -43,6 +43,7 @@ struct KMBatchSecurityRestrictOptions: OptionSet {
     static let none = KMBatchSecurityRestrictOptions(rawValue: 1 << 0) //无
     static let print = KMBatchSecurityRestrictOptions(rawValue: 1 << 1) //打印
     static let copy = KMBatchSecurityRestrictOptions(rawValue: 1 << 2) //复制
+//    static let edit = KMBatchSecurityRestrictOptions(rawValue: 1 << 3) //编辑
 
     static let all: KMBatchSecurityRestrictOptions = [.print, .copy]
 }