暫無描述

AppLegalURLs.swift 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // AppLegalURLs.swift
  3. // App for Indeed
  4. //
  5. import AppKit
  6. import Foundation
  7. /// Legal, support, and marketing pages hosted on Google Sites.
  8. enum AppLegalURLs {
  9. private static let siteRoot = "https://sites.google.com/view/app-for-indeed"
  10. static let marketingHome = URL(string: "\(siteRoot)/home")!
  11. static let privacyPolicy = URL(string: "\(siteRoot)/privacy")!
  12. static let termsOfUse = URL(string: "\(siteRoot)/terms")!
  13. static let support = URL(string: "\(siteRoot)/support")!
  14. /// Opens the URL in Safari when available; otherwise uses the system default browser.
  15. static func openInSafari(_ url: URL) {
  16. let safariApp = URL(fileURLWithPath: "/Applications/Safari.app")
  17. guard FileManager.default.fileExists(atPath: safariApp.path) else {
  18. NSWorkspace.shared.open(url)
  19. return
  20. }
  21. NSWorkspace.shared.open(
  22. [url],
  23. withApplicationAt: safariApp,
  24. configuration: NSWorkspace.OpenConfiguration()
  25. ) { _, error in
  26. if error != nil {
  27. NSWorkspace.shared.open(url)
  28. }
  29. }
  30. }
  31. }