Implement send notification

This commit is contained in:
世界
2024-11-07 16:52:14 +08:00
parent c72167b0dc
commit 348f2809a1
6 changed files with 102 additions and 25 deletions
+1 -13
View File
@@ -14,8 +14,6 @@ public class CommandClient: ObservableObject {
private let logMaxLines: Int
private var commandClient: LibboxCommandClient?
private var connectTask: Task<Void, Error>?
private var openURLFunc: ((String) -> Void)?
@Published public var isConnected: Bool
@Published public var status: LibboxStatusMessage?
@Published public var groups: [LibboxOutboundGroup]?
@@ -31,15 +29,13 @@ public class CommandClient: ObservableObject {
public init(_ connectionType: ConnectionType, logMaxLines: Int = 300) {
self.connectionType = connectionType
self.logMaxLines = logMaxLines
openURLFunc = nil
logList = []
clashModeList = []
clashMode = ""
isConnected = false
}
public func connect(_ openURLFunc: ((String) -> Void)? = nil) {
self.openURLFunc = openURLFunc
public func connect() {
if isConnected {
return
}
@@ -52,7 +48,6 @@ public class CommandClient: ObservableObject {
}
public func disconnect() {
openURLFunc = nil
if let connectTask {
connectTask.cancel()
self.connectTask = nil
@@ -227,13 +222,6 @@ public class CommandClient: ObservableObject {
commandClient.connections = connections
}
}
func openURL(_ url: String?) {
guard let url else {
return
}
commandClient.openURLFunc?(url)
}
}
}