- 添加 expiresAt 和 refreshUserSig 参数支持自动续签 - 修改 PushSDK 初始化方式,自动完成设备注册和厂商初始化 - 调整过期续签策略,从提前 15 分钟改为提前 5 分钟触发 - 重构 RN SDK 文档结构,简化安装和使用方式 - 更新统一登录流程,支持 profile 信息传递 - 添加 IM 数据库自动隔离功能 - 修复 Android 群消息聚合问题 - 补充自动化测试验证和错误处理机制
75 行
2.4 KiB
Swift
75 行
2.4 KiB
Swift
import SwiftUI
|
|
import XuqmSDK
|
|
|
|
struct LoginView: View {
|
|
@ObservedObject var viewModel: AuthViewModel
|
|
@State private var userId: String = "user_a"
|
|
@State private var password: String = "123456"
|
|
|
|
var body: some View {
|
|
VStack(spacing: 20) {
|
|
Spacer()
|
|
|
|
Text("XuqmGroup IM")
|
|
.font(.largeTitle)
|
|
.fontWeight(.bold)
|
|
|
|
Text("iOS Demo")
|
|
.font(.subheadline)
|
|
.foregroundStyle(.secondary)
|
|
|
|
Spacer().frame(height: 40)
|
|
|
|
VStack(spacing: 16) {
|
|
TextField("用户 ID", text: $userId)
|
|
.textContentType(.username)
|
|
#if os(iOS)
|
|
.autocapitalization(.none)
|
|
#endif
|
|
.padding()
|
|
.background(Color.gray.opacity(0.15))
|
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
|
|
SecureField("密码", text: $password)
|
|
.textContentType(.password)
|
|
.padding()
|
|
.background(Color.gray.opacity(0.15))
|
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
}
|
|
|
|
if case .error(let msg) = viewModel.state {
|
|
Text(msg)
|
|
.font(.caption)
|
|
.foregroundStyle(.red)
|
|
.multilineTextAlignment(.center)
|
|
}
|
|
|
|
Button {
|
|
viewModel.login(userId: userId.trimmingCharacters(in: .whitespaces), password: password)
|
|
} label: {
|
|
HStack {
|
|
if case .loading = viewModel.state {
|
|
ProgressView()
|
|
.tint(.white)
|
|
}
|
|
Text("登录")
|
|
.fontWeight(.semibold)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding()
|
|
.background(Color.accentColor)
|
|
.foregroundStyle(.white)
|
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
}
|
|
.disabled(viewModel.state == .loading || userId.isEmpty || password.isEmpty)
|
|
|
|
Spacer()
|
|
|
|
Text("演示环境: https://dev.xuqinmin.com")
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
.padding(.horizontal, 32)
|
|
}
|
|
}
|