fix models
This commit is contained in:
parent
943eee00b1
commit
16cb06f5d1
@ -45,12 +45,12 @@ class AppContext {
|
||||
}
|
||||
|
||||
enum Credit {
|
||||
case token(token: String, session: SDLAPIClient.NetworkSession)
|
||||
case accountAndPasword(account: String, password: String, session: SDLAPIClient.NetworkSession)
|
||||
case token(token: String, session: NetworkSession)
|
||||
case accountAndPasword(account: String, password: String, session: NetworkSession)
|
||||
}
|
||||
|
||||
@ObservationIgnored
|
||||
var networkSession: SDLAPIClient.NetworkSession? {
|
||||
var networkSession: NetworkSession? {
|
||||
guard let loginCredit = self.loginCredit else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ struct AppRootView: View {
|
||||
|
||||
// 将遮罩抽离,保持 body 清爽
|
||||
@ViewBuilder
|
||||
private func updateOverlay(info: SDLAPIClient.AppUpgradeInfo) -> some View {
|
||||
private func updateOverlay(info: AppUpgradeInfo) -> some View {
|
||||
ZStack {
|
||||
Color.black.opacity(0.4)
|
||||
.ignoresSafeArea()
|
||||
|
||||
@ -21,12 +21,12 @@ final class NetworkModel {
|
||||
var showMode: NetworkShowMode = .resource
|
||||
var phase: NetworkConnectionPhase = .disconnected
|
||||
|
||||
var networkSession: SDLAPIClient.NetworkSession?
|
||||
var networkContext: SDLAPIClient.NetworkContext?
|
||||
var networkSession: NetworkSession?
|
||||
var networkContext: NetworkContext?
|
||||
var selectedExitNodeIp: String?
|
||||
var selectedNodeId: Int?
|
||||
|
||||
private(set) var nodeResourcesById: [Int: [SDLAPIClient.NetworkContext.Resource]] = [:]
|
||||
private(set) var nodeResourcesById: [Int: [NetworkContext.Resource]] = [:]
|
||||
private(set) var loadingNodeIDs: Set<Int> = []
|
||||
private(set) var isUpdatingExitNode: Bool = false
|
||||
private(set) var errorMessage: String?
|
||||
@ -57,15 +57,15 @@ final class NetworkModel {
|
||||
self.phase == .connected
|
||||
}
|
||||
|
||||
var resourceList: [SDLAPIClient.NetworkContext.Resource] {
|
||||
var resourceList: [NetworkContext.Resource] {
|
||||
self.networkContext?.resourceList ?? []
|
||||
}
|
||||
|
||||
var nodeList: [SDLAPIClient.NetworkContext.Node] {
|
||||
var nodeList: [NetworkContext.Node] {
|
||||
self.networkContext?.nodeList ?? []
|
||||
}
|
||||
|
||||
var selectedNode: SDLAPIClient.NetworkContext.Node? {
|
||||
var selectedNode: NetworkContext.Node? {
|
||||
self.networkContext?.getNode(id: self.selectedNodeId)
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ final class NetworkModel {
|
||||
}
|
||||
}
|
||||
|
||||
func resources(for nodeId: Int) -> [SDLAPIClient.NetworkContext.Resource] {
|
||||
func resources(for nodeId: Int) -> [NetworkContext.Resource] {
|
||||
self.nodeResourcesById[nodeId] ?? []
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ final class NetworkModel {
|
||||
self.syncSharedStateFromAppContext()
|
||||
}
|
||||
|
||||
private func applyNetworkContext(_ newContext: SDLAPIClient.NetworkContext?) async {
|
||||
private func applyNetworkContext(_ newContext: NetworkContext?) async {
|
||||
let contextChanged = self.contextIdentity(self.networkContext) != self.contextIdentity(newContext)
|
||||
|
||||
self.networkContext = newContext
|
||||
@ -407,7 +407,7 @@ final class NetworkModel {
|
||||
}
|
||||
}
|
||||
|
||||
private func contextIdentity(_ context: SDLAPIClient.NetworkContext?) -> String? {
|
||||
private func contextIdentity(_ context: NetworkContext?) -> String? {
|
||||
guard let context else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ struct NetworkDeviceGroupView: View {
|
||||
|
||||
// MARK: - 子组件
|
||||
struct NetworkNodeHeadView: View {
|
||||
var node: SDLAPIClient.NetworkContext.Node
|
||||
var node: NetworkContext.Node
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 10) {
|
||||
@ -389,7 +389,7 @@ struct NetworkNodeHeadView: View {
|
||||
|
||||
struct NetworkNodeDetailView: View {
|
||||
var model: NetworkModel
|
||||
var node: SDLAPIClient.NetworkContext.Node
|
||||
var node: NetworkContext.Node
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
@ -428,7 +428,7 @@ struct NetworkNodeDetailView: View {
|
||||
}
|
||||
|
||||
struct ResourceItemCard: View {
|
||||
let resource: SDLAPIClient.NetworkContext.Resource
|
||||
let resource: NetworkContext.Resource
|
||||
@State private var isHovered = false
|
||||
|
||||
var body: some View {
|
||||
|
||||
@ -10,12 +10,12 @@ struct SettingsAboutView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
|
||||
@State private var isShowingFeedbackSheet = false
|
||||
@State private var appPoliciesInfo: SDLAPIClient.AppPoliciesInfo?
|
||||
@State private var appPoliciesInfo: AppPoliciesInfo?
|
||||
|
||||
// 检查更新逻辑
|
||||
@State private var updateManager = AppUpdateManager.shared
|
||||
@State private var showNoUpdateAlert = false
|
||||
@State private var manualUpdateInfo: SDLAPIClient.AppUpgradeInfo?
|
||||
@State private var manualUpdateInfo: AppUpgradeInfo?
|
||||
|
||||
var body: some View {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
|
||||
@ -11,7 +11,7 @@ import Observation
|
||||
class AppUpdateManager {
|
||||
static let shared = AppUpdateManager()
|
||||
|
||||
var updateInfo: SDLAPIClient.AppUpgradeInfo?
|
||||
var updateInfo: AppUpgradeInfo?
|
||||
var isChecking = false
|
||||
var showUpdateOverlay = false // 用于启动时的全局遮罩
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct AppUpdateView: View {
|
||||
let info: SDLAPIClient.AppUpgradeInfo
|
||||
let info: AppUpgradeInfo
|
||||
var dismissAction: () -> Void
|
||||
|
||||
var body: some View {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user