feat(ios): add device details and reliable ipa build
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
final class DeviceViewModel: ObservableObject {
|
||||
@Published var snapshot: DeviceSnapshot?
|
||||
@Published var isLoading = false
|
||||
@Published var errorMessage: String?
|
||||
|
||||
let instance: Instance
|
||||
private let service: DeviceService
|
||||
|
||||
init(instance: Instance, service: DeviceService) {
|
||||
self.instance = instance
|
||||
self.service = service
|
||||
}
|
||||
|
||||
func refresh() async {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
do {
|
||||
snapshot = try await service.snapshot(instance)
|
||||
} catch DeviceServiceError.unauthorized {
|
||||
errorMessage = "需要实例密码登录后才能读取设备数据。"
|
||||
} catch {
|
||||
errorMessage = "无法加载设备数据。"
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user