Add support for openURL event

This commit is contained in:
世界
2024-11-04 23:04:58 +08:00
parent 59aebddaa4
commit 2b33d09134
2 changed files with 17 additions and 2 deletions
@@ -4,7 +4,9 @@ import SwiftUI
public struct ExtensionStatusView: View {
@Environment(\.scenePhase) private var scenePhase
@Environment(\.openURL) private var openURL
@StateObject private var commandClient = CommandClient(.status)
@State private var columnCount: Int = 4
@State private var alert: Alert?
@@ -89,7 +91,9 @@ public struct ExtensionStatusView: View {
.padding([.top, .leading, .trailing])
}
.onAppear {
commandClient.connect()
commandClient.connect { urlString in
openURL(URL(string: urlString)!)
}
}
.onDisappear {
commandClient.disconnect()