Просмотр исходного кода

系统菜单栏-帮助菜单新增交互

tangchao 2 лет назад
Родитель
Сommit
44990a85b1

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
PDF Office/PDF Office/AppDelegate.swift

@@ -243,7 +243,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
     // MARK: help Menu
     
     @IBAction func menuItemAction_quickStudy(_ sender: NSMenuItem) -> Void {
-        
+        KMTools.openQuickStartStudy()
     }
     
     @IBAction func menuItemAction_onlineHelp(_ sender: NSMenuItem) -> Void {

+ 64 - 1
PDF Office/PDF Office/Class/Common/Tools/KMTools.swift

@@ -87,29 +87,92 @@ import Cocoa
     @objc class func openURL(_ url: URL) {
         NSWorkspace.shared.open(url)
     }
+    
+    // MARK: -
+    // MARK: 获取 App 版本号
+    @objc class func getAppVersion() -> String {
+        let infoDictionary = Bundle.main.infoDictionary
+        if (infoDictionary == nil) {
+            return "1.0.0"
+        }
+        
+        var version = infoDictionary!["CFBundleShortVersionString"]
+        if (version != nil && (version is String) && (version as! String).isEmpty == false) {
+            return version as! String
+        }
+        
+        version = infoDictionary!["CFBundleVersion"]
+        if (version != nil && (version is String) && (version as! String).isEmpty == false) {
+            return version as! String
+        }
+        
+        return "1.0.0"
+    }
 }
 
 // MARK: -
 // MARK: PDFOffice
 
 extension KMTools {
+    // 打开 [快速教学]
+    @objc class func openQuickStartStudy() {
+        // MARK: -
+        // MARK: 内嵌文档需要替换
+        var fileName = "Quick Start Guide"
+        let fileType = "pdf"
+        
+        let path = Bundle.main.path(forResource: fileName, ofType: fileType)
+        if (path == nil || FileManager.default.fileExists(atPath: path!) == false) {
+            // MARK: -
+            // MARK: url需要替换
+            KMTools.openURL(URL(string: "https://www.pdfreaderpro.com/help")!)
+            return
+        }
+        
+        let infoDictionary = Bundle.main.infoDictionary
+        let version = KMTools.getAppVersion()
+        fileName.append(" v\(version).\(fileType)")
+        
+        let folderPath = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).last?.appending("/\(Bundle.main.bundleIdentifier!)")
+        if (FileManager.default.fileExists(atPath: folderPath!) == false) {
+            try?FileManager.default.createDirectory(atPath: folderPath!, withIntermediateDirectories: false)
+        }
+        
+        let toPath = "\(folderPath!)/\(fileName)"
+        if (FileManager.default.fileExists(atPath: toPath)) {
+            try?FileManager.default.removeItem(atPath: toPath)
+        }
+        try?FileManager.default.copyItem(atPath: path!, toPath: toPath)
+        NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: toPath), display: true) { document, result, error in
+            if (error != nil) {
+                NSApp.presentError(error!)
+            }
+        }
+    }
+    
     // 打开 [FAQ] 网站
     @objc class func openFAQWebsite() {
-        KMTools.openURL(URL(string: "")!)
+//        KMTools.openURL(URL(string: "")!)
     }
     
     // 打开 [更多产品] 网站
     @objc class func openMoreProductWebsite() {
+        // MARK: -
+        // MARK: url需要替换
         KMTools.openURL(URL(string: "https://www.pdfreaderpro.com/product?utm_source=MacApp&utm_campaign=ProductLink&utm_medium=PdfProduct")!)
     }
     
     // 打开 [免费 PDF 模板] 网站
     @objc class func openFreePDFTemplatesWebsite() {
+        // MARK: -
+        // MARK: url需要替换
         KMTools.openURL(URL(string: "https://www.pdfreaderpro.com/templates?utm_source=MacApp&utm_campaign=TemplatesLink&utm_medium=PdfTemplates")!)
     }
     
     // 打开 [ComPDFKit 授权] 网站
     @objc class func openComPDFKitPowerWebsite() {
+        // MARK: -
+        // MARK: url需要替换
         KMTools.openURL(URL(string: "https://www.compdf.com/?utm_source=macapp&utm_medium=pdfmac&utm_campaign=compdfkit-promp")!)
     }
 }