mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-30 22:39:04 +00:00
added url scheme
This commit is contained in:
parent
75fb10a673
commit
a75ca179ce
2 changed files with 34 additions and 0 deletions
|
|
@ -2,6 +2,19 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>me.cranci.scheme</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>sora</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,27 @@ struct SoraApp: App {
|
|||
.onAppear {
|
||||
settings.updateAppearance()
|
||||
}
|
||||
.onOpenURL { url in
|
||||
handleURL(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleURL(_ url: URL) {
|
||||
guard url.scheme == "sora",
|
||||
url.host == "module",
|
||||
let components = URLComponents(url: url, resolvingAgainstBaseURL: true),
|
||||
let moduleURL = components.queryItems?.first(where: { $0.name == "url" })?.value else {
|
||||
return
|
||||
}
|
||||
|
||||
Task {
|
||||
do {
|
||||
let module = try await moduleManager.addModule(metadataUrl: moduleURL)
|
||||
DropManager.shared.showDrop(title: "Module Added!", subtitle: "Check settings to select it", duration: 2.0, icon: UIImage(systemName: "app.badge.checkmark"))
|
||||
} catch {
|
||||
Logger.shared.log("Failed to add module from URL scheme: \(error.localizedDescription)", type: "Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue