Browse Source

完善 - SDK 在 APP 中切换相关;

zhudongyong 1 year ago
parent
commit
1efd0577c0

BIN
KdanAutoTest/KdanAuto.xcodeproj/project.xcworkspace/xcuserdata/zhudongyong.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 16
KdanAutoTest/KdanAuto.xcodeproj/xcuserdata/zhudongyong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -100,21 +100,5 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "1FAF7F75-A574-4C98-A03F-51E2906B9F80"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "ProcessCheckFile/Process/ProcessThumbnal.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "114"
-            endingLineNumber = "114"
-            landmarkName = "process(_:desPath:outputSize:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 5 - 1
KdanAutoTest/KdanAuto/Class/AutoTestCase/PDFCompareTest.swift

@@ -20,7 +20,11 @@ class PDFCompareTest : AutoTest {
     }
    
     override func process(_ originPath:String, resultPath:String, complention:@escaping (_ status:Int) -> ()) {
-        complention(1)
+        DispatchQueue.global().async {
+            Thread.sleep(forTimeInterval: 0.3);
+            
+            complention(1)
+        }
     }
     
     override func compareFiles(_ fileName: String) -> NSArray? {

+ 43 - 1
KdanAutoTest/KdanAuto/Class/Setting/SettingViewController.swift

@@ -7,6 +7,7 @@
 
 import Foundation
 import AppKit
+import ComPDFKit_Conversion
 
 enum PathType {
     case Origin;
@@ -25,9 +26,11 @@ class SettingViewController : NSViewController, NSTextFieldDelegate, NSWindowDel
     public var delegate : SettingViewControllerDelegate!
     
     @IBOutlet var originPathTF : NSTextField!
-    
     @IBOutlet var originPathBtn : NSButton!
     
+    @IBOutlet var sdkPopBtn : NSPopUpButton!
+    @IBOutlet var sdkChangeAlertLbl : NSTextField!
+    
     class func shared() -> SettingViewController {
         if vc == nil {
             vc = SettingViewController()
@@ -44,6 +47,31 @@ class SettingViewController : NSViewController, NSTextFieldDelegate, NSWindowDel
     
     override func viewWillAppear() {
         self.originPathTF.stringValue = DataModel.shared.directoryPath() ;
+        
+        let items = NSMutableArray()
+        
+        let currentVersion = CPDFConvertKit.sharedInstance().versionNumber!
+        items.add(currentVersion);
+        
+        let path = NSString(string: Bundle.main.sharedFrameworksPath!).deletingLastPathComponent.appending("/Frameworks");
+        NSLog("\(path)")
+        let subpaths = NSArray(array: try! FileManager.default.contentsOfDirectory(atPath: path))
+        for item in subpaths {
+            var subPath = item as! String
+            subPath = NSString(string: subPath).pathComponents.first ?? ""
+            subPath = NSString(string: subPath).deletingPathExtension
+            if (NSString(string: subPath).contains("ComPDFKit_Conversion_")) {
+                let version = NSString(string: subPath).replacingOccurrences(of: "ComPDFKit_Conversion_", with: "")
+                
+                if (NSString(string: version).length > 0 && !items.contains(version)) {
+                    items.add(version)
+                }
+            }
+        }
+        
+        self.sdkPopBtn.removeAllItems()
+        self.sdkPopBtn.addItems(withTitles: (items as! [String]));
+        self.sdkPopBtn.selectItem(withTitle: currentVersion)
     }
     
     // IBAction
@@ -62,6 +90,18 @@ class SettingViewController : NSViewController, NSTextFieldDelegate, NSWindowDel
         
     }
     
+    @IBAction func sdkChangeAction(_ sender:NSButton) {
+        let currentVersion = CPDFConvertKit.sharedInstance().versionNumber!
+        self.sdkChangeAlertLbl.isHidden = NSString(string: currentVersion).isEqual(to: self.sdkPopBtn.titleOfSelectedItem)
+        
+        let path = NSString(string: Bundle.main.sharedFrameworksPath!).deletingLastPathComponent.appending("/Frameworks");
+        let originPath = path.appending("/ComPDFKit_Conversion.framework")
+        let nPath = NSString(string: path).appendingFormat("/ComPDFKit_Conversion_%@.framework", self.sdkPopBtn.titleOfSelectedItem!) as String
+        
+        try? FileManager.default.removeItem(atPath: originPath);
+        try? FileManager.default.copyItem(atPath: nPath, toPath: originPath)
+    }
+    
     // Show
     public func show() {
         window.setIsVisible(true);
@@ -78,4 +118,6 @@ class SettingViewController : NSViewController, NSTextFieldDelegate, NSWindowDel
         return false;
     }
     
+    
+    
 }

+ 46 - 8
KdanAutoTest/KdanAuto/Class/Setting/SettingViewController.xib

@@ -10,6 +10,8 @@
             <connections>
                 <outlet property="originPathBtn" destination="fOa-Eb-YOX" id="WOD-U8-MZj"/>
                 <outlet property="originPathTF" destination="3hj-Iu-skR" id="XBk-z0-ChP"/>
+                <outlet property="sdkChangeAlertLbl" destination="vW8-bS-RTC" id="tQD-On-zg1"/>
+                <outlet property="sdkPopBtn" destination="tBW-EJ-I8e" id="dSF-0I-Yku"/>
                 <outlet property="view" destination="6UO-s2-2gI" id="Anz-wg-Gsp"/>
                 <outlet property="window" destination="Mtt-fY-Y6u" id="ebY-tg-SzD"/>
             </connections>
@@ -19,18 +21,18 @@
         <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="" animationBehavior="default" id="Mtt-fY-Y6u">
             <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="196" y="239" width="479" height="147"/>
+            <rect key="contentRect" x="196" y="239" width="479" height="158"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1175"/>
             <view key="contentView" id="6UO-s2-2gI">
-                <rect key="frame" x="0.0" y="0.0" width="479" height="147"/>
+                <rect key="frame" x="0.0" y="0.0" width="479" height="158"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <view id="oMy-XG-cue">
-                        <rect key="frame" x="0.0" y="0.0" width="479" height="147"/>
+                        <rect key="frame" x="0.0" y="0.0" width="479" height="158"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sGm-pJ-h82">
-                                <rect key="frame" x="18" y="112" width="141" height="22"/>
+                                <rect key="frame" x="18" y="123" width="141" height="22"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="测试文档路径选择:" id="U1q-Rt-Rfs">
                                     <font key="font" metaFont="systemSemibold" size="13"/>
@@ -39,7 +41,7 @@
                                 </textFieldCell>
                             </textField>
                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QzR-fG-S65">
-                                <rect key="frame" x="36" y="72" width="100" height="16"/>
+                                <rect key="frame" x="36" y="83" width="100" height="16"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="原文档路径:" id="1fO-bs-ZOp">
                                     <font key="font" metaFont="system"/>
@@ -48,7 +50,7 @@
                                 </textFieldCell>
                             </textField>
                             <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3hj-Iu-skR">
-                                <rect key="frame" x="142" y="69" width="273" height="21"/>
+                                <rect key="frame" x="142" y="80" width="273" height="21"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                                 <textFieldCell key="cell" lineBreakMode="truncatingHead" selectable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" baseWritingDirection="leftToRight" alignment="left" drawsBackground="YES" id="jaV-R5-1Pd">
                                     <font key="font" metaFont="system"/>
@@ -57,7 +59,7 @@
                                 </textFieldCell>
                             </textField>
                             <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fOa-Eb-YOX">
-                                <rect key="frame" x="412" y="63" width="46" height="32"/>
+                                <rect key="frame" x="412" y="74" width="46" height="32"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                                 <buttonCell key="cell" type="push" title="..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="P1Z-nl-NoM">
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -67,6 +69,42 @@
                                     <action selector="pathSelected:" target="-2" id="AfD-Ba-ABf"/>
                                 </connections>
                             </button>
+                            <textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="vW8-bS-RTC">
+                                <rect key="frame" x="48" y="12" width="405" height="16"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="SDK已切换成功,请重新开启 App." id="N0B-m5-M36">
+                                    <font key="font" metaFont="system"/>
+                                    <color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jkS-4h-DkT">
+                                <rect key="frame" x="35" y="40" width="100" height="16"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="SDK版本:" id="jez-IC-6ZS">
+                                    <font key="font" metaFont="system"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tBW-EJ-I8e">
+                                <rect key="frame" x="138" y="32" width="281" height="25"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="IUB-3x-UlD" id="8j1-xF-LgH">
+                                    <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="menu"/>
+                                    <menu key="menu" id="bAf-r7-Z5G">
+                                        <items>
+                                            <menuItem title="Item 1" state="on" id="IUB-3x-UlD"/>
+                                            <menuItem title="Item 2" id="2Xd-FZ-0CO"/>
+                                            <menuItem title="Item 3" id="G8Y-VS-GyY"/>
+                                        </items>
+                                    </menu>
+                                </popUpButtonCell>
+                                <connections>
+                                    <action selector="sdkChangeAction:" target="-2" id="D3z-rF-TCp"/>
+                                </connections>
+                            </popUpButton>
                         </subviews>
                     </view>
                 </subviews>
@@ -74,7 +112,7 @@
             <connections>
                 <outlet property="delegate" destination="-2" id="lZI-2d-PkW"/>
             </connections>
-            <point key="canvasLocation" x="-73.5" y="-99.5"/>
+            <point key="canvasLocation" x="-73.5" y="-94"/>
         </window>
     </objects>
 </document>

+ 10 - 3
KdanAutoTest/ProcessCheckFile/Process/ProcessThumbnal.swift

@@ -14,6 +14,8 @@ import QuickLookThumbnailing
 import ImageIO
 
 let generate = QLThumbnailGenerator.shared
+let queue = OperationQueue()
+
 
 class ProcessThumbnal : NSObject {
     
@@ -25,10 +27,15 @@ class ProcessThumbnal : NSObject {
     
     class func process(_ filePath:String, desPath:String, outputSize:CGSize, complention:@escaping (_ success:Bool) -> ()) {
         if NSArray(array: ["PDF", "pdf"]).contains(NSString(string: filePath).pathExtension) {
-            return autoreleasepool {
-                let status = FileConverter.shared().converter(filePath, inDesPath: desPath)
-                complention(status == 1)
+            queue.maxConcurrentOperationCount = 1;
+            queue.addOperation {
+                autoreleasepool {
+                    let status = FileConverter.shared().converter(filePath, inDesPath: desPath)
+                    complention(status == 1)
+                }
             }
+            
+            return
         }
         
         if NSArray(array: ["JPG", "jpg"]).contains(NSString(string: filePath).pathExtension) {