feat: api地址变更

This commit is contained in:
Junhui Chen 2025-09-05 18:28:52 +08:00
parent 8c4713d92e
commit ea4a5617ec
4 changed files with 16 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import Foundation
/// API /// API
public enum APIConfig { public enum APIConfig {
/// API URL /// API URL
public static let baseURL = "https://api.memorywake.com:31274/api/v1" public static let baseURL = "https://api.memorywake.com/api/v1"
/// token - Keychain /// token - Keychain
public static var authToken: String { public static var authToken: String {

View File

@ -11,7 +11,7 @@ import Foundation
//enum AnyCodable: Codable {} //enum AnyCodable: Codable {}
func passwordLogin(username: String, password: String) { func passwordLogin(username: String, password: String) {
guard let url = URL(string: "https://api.memorywake.com:31274/api/v1/iam/login/password-login") else { guard let url = URL(string: "https://api.memorywake.com/api/v1/iam/login/password-login") else {
print("❌ 无效的URL") print("❌ 无效的URL")
return return
} }

View File

@ -48,6 +48,19 @@ extension NetworkService: NetworkServiceProtocol {
post(path: path, parameters: parameters, headers: headers, completion: completion) post(path: path, parameters: parameters, headers: headers, completion: completion)
} }
public func getWithToken<T: Decodable>(
path: String,
parameters: [String: Any]? = nil,
completion: @escaping (Result<T, NetworkError>) -> Void
) {
var headers = [String: String]()
if let token = KeychainHelper.getAccessToken() {
headers["Authorization"] = "Bearer \(token)"
}
get(path: path, parameters: parameters, headers: headers, completion: completion)
}
@discardableResult @discardableResult
public func upload( public func upload(
request: URLRequest, request: URLRequest,

View File

@ -7,7 +7,7 @@ struct LoginResponse: Codable {
func callLoginAPI() { func callLoginAPI() {
// 1. URL // 1. URL
let urlString = "https://api.memorywake.com:31274/api/v1/iam/login/password-login" let urlString = "https://api.memorywake.com/api/v1/iam/login/password-login"
guard let url = URL(string: urlString) else { guard let url = URL(string: urlString) else {
print("Invalid URL") print("Invalid URL")
return return