feat: 删除接口

This commit is contained in:
jinyaqiu 2025-09-01 11:46:08 +08:00
parent aa954ddfb9
commit 2caf82318a
2 changed files with 14 additions and 1 deletions

View File

@ -491,6 +491,10 @@ class NetworkService {
headers: [String: String]? = nil,
completion: @escaping (Result<T, NetworkError>) -> Void
) {
var headers = headers ?? [:]
if let token = KeychainHelper.getAccessToken() {
headers["Authorization"] = "Bearer \(token)"
}
request("DELETE", path: path, parameters: parameters, headers: headers, completion: completion)
}

View File

@ -106,10 +106,19 @@ struct AccountView: View {
Button(action: {
//
NetworkService.shared.delete(path: "/iam/delete-user", parameters: nil) { result in
switch result {
case .success(let data):
print("删除账号成功: \(data)")
case .failure(let error):
print("删除账号失败: \(error)")
}
}
//
withAnimation {
showDeleteConfirmation = false
}
// TODO: API
}) {
Text("Confirm")
.foregroundColor(.themeTextMessage)