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