Parcourir la source

【综合】整理代码

tangchao il y a 1 an
Parent
commit
76f01ac7aa

+ 0 - 52
PDF Office/PDF Master/AppDelegate.swift

@@ -266,7 +266,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
                 if (appTarget == .pro) {
                     appName = "PDF Master Pro"
                 } else if (appTarget == .DMG) {
-                    //                    appName = "PDF Master DMG"
                     appName = "PDF Master"
                 }
                 if let _range = ranges.range.first {
@@ -523,57 +522,6 @@ extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
         KMPrint("更新菜单栏")
     }
     
-    func menuNeedsUpdate(_ menu: NSMenu) {
-        KMPrint("menuNeedsUpdate")
-//            menu.removeAllItems()
-//
-//            var item = NSMenuItem()
-//            item = menu.addItem(withTitle: NSLocalizedString("Insert", comment: ""), action: nil, target: self)
-//            item.representedObject = row
-//
-//            var subMenu = NSMenu()
-//            var subitem = NSMenuItem()
-//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert File", comment: ""), action: #selector(insertPageItemAction), target: self, tag:0)
-//            subitem.representedObject = row
-//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert blank page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:1)
-//            subitem.representedObject = row
-//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:2)
-//            subitem.representedObject = row
-//            item.submenu = subMenu
-//
-//            item = menu.addItem(withTitle: NSLocalizedString("Extract", comment: ""), action: #selector(extractPageItemAction), target: self)
-//            item.representedObject = row
-//            item = menu.addItem(withTitle: NSLocalizedString("Delete Page", comment: ""), action: #selector(deletePageItemAction), target: self)
-//            item.representedObject = row
-//            item = menu.addItem(withTitle: NSLocalizedString("Page Edit", comment: ""), action: #selector(pageEditItemAction), target: self)
-//            item.representedObject = row
-//
-//            menu.addItem(NSMenuItem.separator())
-//
-//            item = menu.addItem(withTitle: NSLocalizedString("90 Rotate", comment: ""), action: #selector(rotatePageItemAction), target: self)
-//            item.representedObject = row
-//            item = menu.addItem(withTitle: NSLocalizedString("-90 Rotate", comment: ""), action: #selector(leftRotatePageItemAction), target: self)
-//            item.representedObject = row
-//
-//            menu.addItem(NSMenuItem.separator())
-//
-//            item = menu.addItem(withTitle: NSLocalizedString("copy", comment: ""), action: #selector(copyItemAction), target: self)
-//            item.representedObject = row
-//            item = menu.addItem(withTitle: NSLocalizedString("cut", comment: ""), action: #selector(cutItemAction), target: self)
-//            item.representedObject = row
-//            item = menu.addItem(withTitle: NSLocalizedString("paste", comment: ""), action: #selector(pastePageItemAction), target: self)
-//
-//            menu.addItem(NSMenuItem.separator())
-//
-//            item = menu.addItem(withTitle: NSLocalizedString("print", comment: ""), action: #selector(printItemAction), target: self)
-//
-//            item = menu.addItem(withTitle: NSLocalizedString("Share", comment: ""), action: nil, target: self)
-//
-//            item.submenu = NSSharingServicePicker.menu(forSharingItems: [self.listView.document.documentURL ?? ""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
-    
-//        }
-    }
-    
     func menu(_ menu: NSMenu, update item: NSMenuItem, at index: Int, shouldCancel: Bool) -> Bool {
         return true
     }

+ 15 - 21
PDF Office/PDF Master/Class/Analytics/KMAnalytics.swift

@@ -100,36 +100,30 @@ extension KMAnalytics.Parameter {
         
         if (appTarget.contains(.free)) {
 #if VERSION_FREE
-            if (platform == .firebase) {
-                Analytics.logEvent(eventName, parameters: parameters)
-            } else if (platform == .AppCenter) {
-                if let data = parameters as? [String : String] {
-                    Analytics.trackEvent(eventName, withProperties: data)
-                }
-            }
+            self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
 #endif
         }
         if (appTarget.contains(.pro)) {
 #if VERSION_PRO
-            if (platform == .firebase) {
-                Analytics.logEvent(eventName, parameters: parameters)
-            } else if (platform == .AppCenter) {
-                if let data = parameters as? [String : String] {
-                    Analytics.trackEvent(eventName, withProperties: data)
-                }
-            }
+            self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
 #endif
         }
         if (appTarget.contains(.dmg)) {
 #if VERSION_DMG
-            if (platform == .firebase) {
-                Analytics.logEvent(eventName, parameters: parameters)
-            } else if (platform == .AppCenter) {
-                if let data = parameters as? [String : String] {
-                    Analytics.trackEvent(eventName, withProperties: data)
-                }
-            }
+            self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
 #endif
         }
     }
+    
+    // MARK: - Private Methods
+    // 发送事件
+    fileprivate static func _trackEvent(eventName: String, parameters: [String : Any]? = nil, platform: KMAnalyticsPlatform = .firebase) {
+        if (platform == .firebase) {
+            Analytics.logEvent(eventName, parameters: parameters)
+        } else if (platform == .AppCenter) {
+            if let data = parameters as? [String : String] {
+                Analytics.trackEvent(eventName, withProperties: data)
+            }
+        }
+    }
 }

+ 0 - 94
PDF Office/PDF Master/Class/Common/KMEnumExtensions.swift

@@ -11,32 +11,6 @@ protocol KMSubscribeWaterMarkTypeConvertProtocol {
     func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType
 }
 
-/*
- @objc enum KMToolbarType: Int {
-     /// conversion
-     case word = 3000
-     case excel = 3001
-     case ppt = 3002
-     case rtf = 3003
-     case csv = 3004
-     case html = 3005
-     case conversion_text = 3006
-     case conversion_image = 3007
-     
-     /// tool
-     case compress = 8000
-     case merge = 8001
-     case fileCompare = 8002
-     case secure = 8003
-     case redact = 8004
-     case watermark = 8005
-     case background = 8006
-     case headerAndFooter = 8007
-     case bates = 8008
-     case crop = 8009
- }
- */
-
 extension KMToolbarType: KMSubscribeWaterMarkTypeConvertProtocol {
     func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
         switch self {
@@ -66,28 +40,6 @@ extension KMToolbarType: KMSubscribeWaterMarkTypeConvertProtocol {
     }
 }
 
-/*
- enum KMPDFConvertType: Int {
-     case word = 0
-     case excel = 1
-     case ppt = 2
-     case rtf = 3
-     case csv = 4
-     case html = 5
-     case text = 6
-     case jpeg = 7
-     case jpg = 8
-     case png = 9
-     case gif = 10
-     case tiff = 11
-     case tga = 12
-     case bmp = 13
-     case jp2 = 14
-     
-     static let image: KMPDFConvertType = .jpeg
- }
- */
-
 extension KMPDFConvertType: KMSubscribeWaterMarkTypeConvertProtocol {
     func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
         switch self {
@@ -113,17 +65,6 @@ extension KMPDFConvertType: KMSubscribeWaterMarkTypeConvertProtocol {
     }
 }
 
-/*
- @objc enum KMItemKey: Int {
-     case print = 0 // 打印
-     case delete
-     case leftRotate
-     case rightRotate
-     case cut
-     case paste
- }
- */
-
 extension KMItemKey: KMSubscribeWaterMarkTypeConvertProtocol {
     func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
         switch self {
@@ -141,41 +82,6 @@ extension KMItemKey: KMSubscribeWaterMarkTypeConvertProtocol {
     }
 }
 
-/*
- enum KMPageEditType: Int {
-     case pageRange = 1
-     case leftRotate
-     case rightRotate
-     case insert
-     case extract
-     case replace
-     case split
-     case reverse
-     case delete
-     
-     case zoomOut
-     case zoomIn
-     
-     static let none: KMPageEditType = KMPageEditType(rawValue: 0)!
-     
-     static var insert_files: Int {
-         get {
-             return self.insert.rawValue + 1000
-         }
-     }
-     static var insert_blank_page: Int {
-         get {
-             return self.insert.rawValue  + 1001
-         }
-     }
-     static var insert_custom_page: Int {
-         get {
-             return self.insert.rawValue + 1002
-         }
-     }
- }
- */
-
 extension KMPageEditType: KMSubscribeWaterMarkTypeConvertProtocol {
     func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
         switch self {