Files
VibeCoding/webrtc_controller_ios/web_rtc_controller_ios/Views/LoginView.swift
tongtongstudio 6eb2c7321a feat(controlled): 实现设备激活与安全认证流程
- 添加API客户端、加密存储和provision/token激活逻辑
- WebSocket改用Bearer令牌认证,移除REGISTER请求
- 设备ID改为服务端下发,支持令牌刷新和强制下线处理
- 新增deviceSecret加密存储和accessToken自动刷新
- 更新设备ID获取方式为出厂SN,添加安全存储依赖
2026-08-01 15:13:12 +08:00

52 lines
1.9 KiB
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 SwiftUI
/// / ViewModel.login
struct LoginView: View {
@ObservedObject var viewModel: ControllerViewModel
@State private var username: String = ""
@State private var password: String = ""
var body: some View {
NavigationView {
Form {
Section("账号登录") {
TextField("用户名", text: $username)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
SecureField("密码", text: $password)
}
if let err = viewModel.loginError, !err.isEmpty {
Section {
Text(err).foregroundColor(.red)
}
}
Section {
Button {
Task {
await viewModel.login(username: username, password: password)
}
} label: {
HStack {
Spacer()
if viewModel.isLoggingIn {
ProgressView().padding(.trailing, 8)
}
Text(viewModel.isLoggingIn ? "登录中..." : "登录")
.font(.system(size: 15, weight: .semibold))
Spacer()
}
}
.disabled(viewModel.isLoggingIn || username.isEmpty || password.isEmpty)
} footer: {
Text("登录后才能连接信令服务器并发起远程控制。账号由服务端统一创建与管控。")
}
}
.navigationTitle("WebRTC 控制端")
}
.navigationViewStyle(.stack)
}
}