wake-ios/wake/Utils/APIConfig.swift
2025-08-22 18:58:08 +08:00

35 lines
978 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Foundation
/// API
public enum APIConfig {
/// API URL
public static let baseURL = "https://api-dev.memorywake.com:31274/api/v1"
/// token - Keychain
public static var authToken: String {
let token = KeychainHelper.getAccessToken() ?? ""
if !token.isEmpty {
print("🔑 [APIConfig] 当前访问令牌: \(token.prefix(10))...") // 10
} else {
print("⚠️ [APIConfig] 未找到访问令牌")
}
return token
}
///
public static var authHeaders: [String: String] {
let token = authToken
var headers = [
"Content-Type": "application/json",
"Accept": "application/json"
]
if !token.isEmpty {
headers["Authorization"] = "Bearer \(token)"
}
return headers
}
}