mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
修复发送到其他设备快捷指令异常的问题
This commit is contained in:
parent
786e5f2232
commit
2bc0eb33b8
@ -41,15 +41,16 @@ struct PushToCurrentIntent: AppIntent {
|
|||||||
var group: String?
|
var group: String?
|
||||||
|
|
||||||
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
|
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
|
||||||
let url = ServerManager.shared.currentServer.address + "/\(ServerManager.shared.currentServer.key)"
|
guard let address = URL(string: address) else {
|
||||||
|
throw "Invalid URL"
|
||||||
|
}
|
||||||
|
|
||||||
var params: [String: Any] = [:]
|
var params: [String: Any] = [:]
|
||||||
|
|
||||||
if let title {
|
if let title, !title.isEmpty {
|
||||||
params["title"] = title.urlDecoded()
|
params["title"] = title.urlDecoded()
|
||||||
}
|
}
|
||||||
if let body {
|
if let body, !body.isEmpty {
|
||||||
// url解码 body
|
|
||||||
params["body"] = body.urlDecoded()
|
params["body"] = body.urlDecoded()
|
||||||
}
|
}
|
||||||
if title == nil, body == nil {
|
if title == nil, body == nil {
|
||||||
@ -64,17 +65,17 @@ struct PushToCurrentIntent: AppIntent {
|
|||||||
if isCall {
|
if isCall {
|
||||||
params["call"] = 1
|
params["call"] = 1
|
||||||
}
|
}
|
||||||
if let sound {
|
if let sound, !sound.isEmpty {
|
||||||
params["sound"] = sound
|
params["sound"] = sound
|
||||||
}
|
}
|
||||||
if let icon {
|
if let icon {
|
||||||
params["icon"] = icon.absoluteString
|
params["icon"] = icon.absoluteString
|
||||||
}
|
}
|
||||||
if let group {
|
if let group, !group.isEmpty {
|
||||||
params["group"] = group
|
params["group"] = group
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = await AF.request(url, method: .post, parameters: params, encoding: JSONEncoding.default)
|
let response = await AF.request(address, method: .post, parameters: params, encoding: JSONEncoding.default)
|
||||||
.serializingDecodable(PushResponse.self)
|
.serializingDecodable(PushResponse.self)
|
||||||
.response
|
.response
|
||||||
|
|
||||||
|
|||||||
@ -40,15 +40,17 @@ struct PushToOtherIntent: AppIntent {
|
|||||||
var group: String?
|
var group: String?
|
||||||
|
|
||||||
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
|
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
|
||||||
let url = ServerManager.shared.currentServer.address + "/\(ServerManager.shared.currentServer.key)"
|
guard let address = URL(string: address) else {
|
||||||
|
throw "Invalid URL"
|
||||||
|
}
|
||||||
|
|
||||||
var params: [String: Any] = [:]
|
var params: [String: Any] = [:]
|
||||||
|
|
||||||
if let title {
|
if let title, !title.isEmpty {
|
||||||
params["title"] = title
|
params["title"] = title.urlDecoded()
|
||||||
}
|
}
|
||||||
if let body {
|
if let body, !body.isEmpty {
|
||||||
params["body"] = body
|
params["body"] = body.urlDecoded()
|
||||||
}
|
}
|
||||||
if title == nil, body == nil {
|
if title == nil, body == nil {
|
||||||
params["body"] = "Empty Notification"
|
params["body"] = "Empty Notification"
|
||||||
@ -62,17 +64,17 @@ struct PushToOtherIntent: AppIntent {
|
|||||||
if isCall {
|
if isCall {
|
||||||
params["call"] = 1
|
params["call"] = 1
|
||||||
}
|
}
|
||||||
if let sound {
|
if let sound, !sound.isEmpty {
|
||||||
params["sound"] = sound
|
params["sound"] = sound
|
||||||
}
|
}
|
||||||
if let icon {
|
if let icon {
|
||||||
params["icon"] = icon.absoluteString
|
params["icon"] = icon.absoluteString
|
||||||
}
|
}
|
||||||
if let group {
|
if let group, !group.isEmpty {
|
||||||
params["group"] = group
|
params["group"] = group
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = await AF.request(url, method: .post, parameters: params, encoding: JSONEncoding.default)
|
let response = await AF.request(address, method: .post, parameters: params, encoding: JSONEncoding.default)
|
||||||
.serializingDecodable(PushResponse.self)
|
.serializingDecodable(PushResponse.self)
|
||||||
.response
|
.response
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user