- 添加API客户端、加密存储和provision/token激活逻辑 - WebSocket改用Bearer令牌认证,移除REGISTER请求 - 设备ID改为服务端下发,支持令牌刷新和强制下线处理 - 新增deviceSecret加密存储和accessToken自动刷新 - 更新设备ID获取方式为出厂SN,添加安全存储依赖
68 lines
2.5 KiB
Swift
68 lines
2.5 KiB
Swift
import SwiftUI
|
||
|
||
/// 设置面板:未连接时显示,用于查看本机设备 ID、配置信令服务器与连接目标。
|
||
struct SetupPanelView: View {
|
||
@ObservedObject var viewModel: ControllerViewModel
|
||
|
||
var body: some View {
|
||
NavigationView {
|
||
Form {
|
||
Section("本机信息") {
|
||
HStack {
|
||
Text("本机设备 ID")
|
||
Spacer()
|
||
Text(viewModel.myDeviceId)
|
||
.font(.system(.body, design: .monospaced))
|
||
.foregroundColor(.secondary)
|
||
.textSelection(.enabled)
|
||
}
|
||
}
|
||
|
||
Section("连接设置") {
|
||
TextField("信令服务器地址 (wss://...)", text: $viewModel.serverUrl)
|
||
.keyboardType(.URL)
|
||
.autocapitalization(.none)
|
||
.disableAutocorrection(true)
|
||
TextField("目标设备 ID", text: $viewModel.targetDeviceId)
|
||
.autocapitalization(.allCharacters)
|
||
.disableAutocorrection(true)
|
||
}
|
||
|
||
Section {
|
||
Button {
|
||
viewModel.requestConnect()
|
||
} label: {
|
||
HStack {
|
||
Spacer()
|
||
if viewModel.isConnecting {
|
||
ProgressView()
|
||
.padding(.trailing, 8)
|
||
}
|
||
Text(viewModel.isConnecting ? "连接中..." : "连接")
|
||
.font(.system(size: 15, weight: .semibold))
|
||
Spacer()
|
||
}
|
||
}
|
||
.disabled(viewModel.isConnecting)
|
||
|
||
if viewModel.isConnecting {
|
||
Button(role: .destructive) {
|
||
viewModel.disconnect()
|
||
} label: {
|
||
HStack {
|
||
Spacer()
|
||
Text("取消")
|
||
Spacer()
|
||
}
|
||
}
|
||
}
|
||
} footer: {
|
||
Text(viewModel.statusText)
|
||
}
|
||
}
|
||
.navigationTitle("WebRTC 控制端")
|
||
}
|
||
.navigationViewStyle(.stack)
|
||
}
|
||
}
|