feat: api地址变更
This commit is contained in:
parent
8c4713d92e
commit
ea4a5617ec
@ -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 {
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user