fix
This commit is contained in:
parent
b067991c8b
commit
4af8993c8f
@ -101,8 +101,7 @@ final class NetworkModel {
|
||||
return ExitNodeOption(
|
||||
id: exitNode.nnid,
|
||||
nodeName: exitNode.nodeName,
|
||||
ip: node.ip,
|
||||
system: node.system
|
||||
ip: node.ip
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -116,43 +115,10 @@ final class NetworkModel {
|
||||
?? ExitNodeOption(
|
||||
id: -1,
|
||||
nodeName: "已保存出口节点",
|
||||
ip: selectedExitNodeIp,
|
||||
system: nil
|
||||
ip: selectedExitNodeIp
|
||||
)
|
||||
}
|
||||
|
||||
var exitNodeTitle: String {
|
||||
if self.isUpdatingExitNode {
|
||||
return "正在切换..."
|
||||
}
|
||||
|
||||
if let selectedExitNode = self.selectedExitNode {
|
||||
return selectedExitNode.nodeName
|
||||
}
|
||||
|
||||
return "未设置"
|
||||
}
|
||||
|
||||
var exitNodeSubtitle: String {
|
||||
if let selectedExitNode = self.selectedExitNode {
|
||||
if let system = selectedExitNode.system, !system.isEmpty {
|
||||
return "\(selectedExitNode.ip) · \(system)"
|
||||
}
|
||||
|
||||
return selectedExitNode.ip
|
||||
}
|
||||
|
||||
if self.networkContext == nil {
|
||||
return "连接后可选择"
|
||||
}
|
||||
|
||||
if self.exitNodeOptions.isEmpty {
|
||||
return "当前网络没有可用节点"
|
||||
}
|
||||
|
||||
return "当前流量保持默认出口"
|
||||
}
|
||||
|
||||
var exitNodeHelpText: String {
|
||||
if self.isUpdatingExitNode {
|
||||
return "正在更新出口节点"
|
||||
@ -421,11 +387,6 @@ extension NetworkModel {
|
||||
let id: Int
|
||||
let nodeName: String
|
||||
let ip: String
|
||||
let system: String?
|
||||
|
||||
var nodeNameWithIp: String {
|
||||
"\(nodeName) (\(ip))"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -168,9 +168,9 @@ private struct NetworkStatusBar: View {
|
||||
}
|
||||
} label: {
|
||||
if self.model.selectedExitNode == nil {
|
||||
Label("不设置出口节点", systemImage: "checkmark")
|
||||
Label("不设置", systemImage: "checkmark")
|
||||
} else {
|
||||
Text("不设置出口节点")
|
||||
Text("不设置")
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,32 +184,46 @@ private struct NetworkStatusBar: View {
|
||||
}
|
||||
} label: {
|
||||
if self.model.selectedExitNode?.ip == option.ip {
|
||||
Label(option.nodeNameWithIp, systemImage: "checkmark")
|
||||
Label(option.nodeName, systemImage: "checkmark")
|
||||
} else {
|
||||
Text(option.nodeNameWithIp)
|
||||
Text(option.nodeName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 10) {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text("出口节点")
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundColor(.secondary)
|
||||
HStack(spacing: 8) {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(Color.blue.opacity(0.1))
|
||||
.frame(width: 24, height: 24)
|
||||
|
||||
Text(self.model.exitNodeTitle)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(self.model.exitNodeSubtitle)
|
||||
.font(.system(size: 10, design: .monospaced))
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
Image(systemName: "arrow.triangle.branch")
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
Text(self.model.selectedExitNode?.nodeName ?? "出口节点")
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
|
||||
if let selectedExitNode = self.model.selectedExitNode {
|
||||
Text(selectedExitNode.ip)
|
||||
.font(.system(size: 10, design: .monospaced))
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 3)
|
||||
.background(
|
||||
Capsule(style: .continuous)
|
||||
.fill(Color.primary.opacity(0.05))
|
||||
)
|
||||
.lineLimit(1)
|
||||
} else {
|
||||
Text("未设置")
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
if self.model.isUpdatingExitNode {
|
||||
ProgressView()
|
||||
@ -220,15 +234,15 @@ private struct NetworkStatusBar: View {
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 8)
|
||||
.frame(width: 220, alignment: .leading)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.frame(minWidth: 156, maxWidth: 210, alignment: .leading)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||
Capsule(style: .continuous)
|
||||
.fill(Color.primary.opacity(0.04))
|
||||
)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||
Capsule(style: .continuous)
|
||||
.stroke(Color.primary.opacity(0.06), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user