refactor(ui): 系统代理暂停与不可读文案收成单一呈现常量

This commit is contained in:
Qiu Yuzhou
2026-10-04 12:37:06 +08:00
parent bcede88ea4
commit 7f1dbc6d94
3 changed files with 13 additions and 5 deletions
@@ -3,6 +3,12 @@ import Foundation
// MARK: - 运行时失败事实的呈现(RuntimeFailureFacts / 系统代理应用态)
extension AppPresentation {
/// 系统代理暂停的统一文案:状态菜单、运行控制卡与错误呈现边三面共用。
static let systemProxyPausedNotice = "后台代理不可用,已清除系统代理配置。恢复后将自动应用。"
/// 系统代理配置不可读的统一前缀:状态菜单与运行控制卡差异区共用。
static let systemProxyUnreadablePrefix = "无法读取网络接口的代理配置:"
static func message(for failure: RuntimeFailureFacts) -> String {
switch failure {
case .firewallBlocked(let facts):
@@ -27,7 +33,7 @@ extension AppPresentation {
case .changed: return "系统代理配置已改变"
case .applying: return "系统代理应用中"
case .repairing: return "系统代理修复中"
case .paused: return "后台代理不可用,已清除系统代理配置。恢复后将自动应用。"
case .paused: return systemProxyPausedNotice
}
}
@@ -103,7 +103,7 @@ struct RuntimeControlCard: View {
case .failed, .repairFailed, .clearFailed:
"操作失败,原因见下方"
case .paused:
"后台代理不可用,已清除系统代理配置。恢复后将自动应用。"
AppPresentation.systemProxyPausedNotice
case .changed:
"当前系统代理配置与预期存在差异"
case .unreadable:
@@ -146,7 +146,8 @@ private struct SystemProxyDifferenceView: View {
control.snapshot.systemProxyApplication != .unreadable(failure)
{
Text(
"无法读取网络接口的代理配置:\(AppPresentation.message(for: RuntimeFailureFacts.systemProxy(failure)))"
AppPresentation.systemProxyUnreadablePrefix
+ AppPresentation.message(for: RuntimeFailureFacts.systemProxy(failure))
)
.font(.caption)
.foregroundStyle(.orange)
+3 -2
View File
@@ -97,11 +97,12 @@ enum StatusMenuModel {
case .applying: return ("应用中", nil)
case .repairing: return ("修复中", nil)
case .paused:
return ("已暂停", "后台代理不可用,已清除系统代理配置。恢复后将自动应用。")
return ("已暂停", AppPresentation.systemProxyPausedNotice)
case .unreadable(let facts):
return (
"无法检查",
"无法读取网络接口的代理配置:\(AppPresentation.message(for: RuntimeFailureFacts.systemProxy(facts)))"
AppPresentation.systemProxyUnreadablePrefix
+ AppPresentation.message(for: RuntimeFailureFacts.systemProxy(facts))
)
case .repairFailed(let facts):
return (