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
public enum APIConfig {
/// 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
public static var authToken: String {

View File

@ -11,7 +11,7 @@ import Foundation
//enum AnyCodable: Codable {}
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")
return
}

View File

@ -48,6 +48,19 @@ extension NetworkService: NetworkServiceProtocol {
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
public func upload(
request: URLRequest,

View File

@ -7,7 +7,7 @@ struct LoginResponse: Codable {
func callLoginAPI() {
// 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 {
print("Invalid URL")
return