|
@@ -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")!)
|
|
|
}
|
|
|
}
|