mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 06:13:42 +00:00
feat: torrent scheme deep link and file associations (#866)
This commit is contained in:
30 files changed
+464
-79
No files matched your search
@@ -1,8 +1,22 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
import app_links
|
||||
|
||||
@main
|
||||
class AppDelegate: FlutterAppDelegate {
|
||||
public override func application(_ application: NSApplication,
|
||||
continue userActivity: NSUserActivity,
|
||||
restorationHandler: @escaping ([any NSUserActivityRestoring]) -> Void) -> Bool {
|
||||
|
||||
guard let url = AppLinks.shared.getUniversalLink(userActivity) else {
|
||||
return false
|
||||
}
|
||||
|
||||
AppLinks.shared.handleLink(link: url.absoluteString)
|
||||
|
||||
return false // Returning true will stop the propagation to other packages
|
||||
}
|
||||
|
||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return false
|
||||
}
|
||||
@@ -19,4 +33,18 @@ class AppDelegate: FlutterAppDelegate {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override func application(_ sender: NSApplication, openFile filename: String) -> Bool {
|
||||
let url = URL(fileURLWithPath: filename)
|
||||
AppLinks.shared.handleLink(link: url.absoluteString)
|
||||
return false;
|
||||
}
|
||||
|
||||
override func application(_ application: NSApplication, open urls: [URL]) {
|
||||
// Only handle the first file
|
||||
if(urls.isEmpty) {
|
||||
return
|
||||
}
|
||||
AppLinks.shared.handleLink(link: urls.first!.absoluteString)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user