feat(sample): 添加示例应用的核心功能模块

- 实现环境配置管理,支持外部和本地主机模式切换
- 集成Demo API接口,包含登录、注册、文件上传等功能
- 构建附件处理仓库,支持图片、视频、音频和文件发送
- 开发认证仓库,管理用户会话和IM令牌刷新机制
- 添加语音录制功能,支持实时音频消息录制
- 创建依赖注入容器,统一管理应用组件实例
- 实现登录界面,提供用户认证交互功能
- 开发聊天界面,集成消息收发和媒体处理功能
这个提交包含在:
XuqmGroup 2026-04-28 16:08:06 +08:00
父节点 1ea512ae10
当前提交 f140d8de3a
共有 2 个文件被更改,包括 29 次插入0 次删除

查看文件

@ -45,11 +45,22 @@ public final class ApiClient: @unchecked Sendable {
req.httpBody = try JSONEncoder().encode(b)
}
if config.debug {
print("[XuqmSDK][HTTP] request", method, req.url?.absoluteString ?? path)
}
let (data, response) = try await session.data(for: req)
guard let http = response as? HTTPURLResponse, (200..<300).contains(http.statusCode) else {
if config.debug, let http = response as? HTTPURLResponse {
print("[XuqmSDK][HTTP] response", http.statusCode, req.url?.absoluteString ?? path)
}
throw URLError(.badServerResponse)
}
if config.debug {
print("[XuqmSDK][HTTP] response", http.statusCode, req.url?.absoluteString ?? path)
}
let wrapper = try JSONDecoder().decode(ApiResponse<T>.self, from: data)
if let result = wrapper.data {
return result

查看文件

@ -24,3 +24,21 @@ public struct SDKConfig: Sendable {
self.debug = debug
}
}
public extension SDKConfig {
static func development(
appId: String,
appSecret: String,
appKey: String? = nil,
debug: Bool = false
) -> SDKConfig {
SDKConfig(
appId: appId,
appKey: appKey ?? appId,
appSecret: appSecret,
apiBaseURL: URL(string: "http://192.168.116.9:8081")!,
imWebSocketURL: URL(string: "ws://192.168.116.9:8082/ws/im")!,
debug: debug
)
}
}