mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-22 13:34:00 +00:00
建立目录工作流深 module(App/CatalogWorkflow/),收窄主窗口与配置 UI 对 配置目录、凭据存储、订阅快照、Legacy 导入与运行时收敛的访问: - UI-facing interface:非敏感树/编辑面/订阅 projection、opaque NodeID 查询、 typed command(ServerEditDraft 等)、typed error 与 structured outcome (BatchImportOutcome 逐行点名、RemovalOutcome selection invalidation); 秘密值只在显式编辑/分享/订阅 URL 命令中出现。 - 服务器编辑:配置与凭据作为一个逻辑变更,CredentialWriteJournal 保证目录 持久化失败时旧配置与旧凭据都保持有效(story 12/13,含测试)。 - 提交与收敛分离:目录提交成功与 runtimeSync 收敛阶段是独立观察面,运行时 失败不回滚已提交目录(story 38/39,含测试)。 - 订阅:创建/刷新/换址/删除沿用原子快照、last-good 保留与凭据回滚;卡片 projection 只含 host,结构化刷新状态由呈现层本地化。 - Legacy 导入端到端编排:不驱动运行时收敛、不自动重复、显式再导入创建独立 分组;handoff 仍经组合根注入的独立边界。 - Deletion test:删除 CatalogViewModel/Types/+Subscriptions 旧 facade,全部 视图与状态菜单迁移到新 seam;选择、pane、sheet、alert 状态收归 UI 持有 (ErrorAlertPresenter)。导入失败行以行号点名,不再回显 ss:// 行内容。 测试经 module interface 观察(395 项全部通过):持久化失败凭据回滚、提交/ 收敛阶段分离、收敛失败不回滚、导入不触发运行时等新增场景;既有 Domain、 协调器与运行时测试保持不变。 Out of scope(spec #41):设置编辑、ProxyRuntimeController、Legacy handoff、 新视觉设计、独立编译 target。
78 lines
2.6 KiB
Swift
78 lines
2.6 KiB
Swift
import SwiftUI
|
|
|
|
/// 分组详情(issue #32/#41):名称编辑(手动组)、直接子节点数与激活入口。
|
|
/// 数据来自目录工作流 module 的树 projection;订阅固定分组名称由远端管理,
|
|
/// 只读。空组保留可编辑(可先搭结构再填内容)。
|
|
struct GroupDetailView: View {
|
|
let workflow: CatalogWorkflow
|
|
let groupID: NodeID
|
|
let proxyController: ProxyRuntimeController
|
|
let errors: ErrorAlertPresenter
|
|
|
|
@State private var name = ""
|
|
|
|
private var node: CatalogTreeNode? { workflow.tree.node(withID: groupID) }
|
|
private var isManual: Bool { node?.isManual ?? false }
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section("分组") {
|
|
TextField("名称", text: $name)
|
|
.disabled(!isManual)
|
|
if isManual {
|
|
Button("保存名称") { saveName() }
|
|
}
|
|
}
|
|
Section {
|
|
LabeledContent("直接子节点", value: "\(directChildCount)")
|
|
if invalidServerCount > 0 {
|
|
LabeledContent("已知无效服务器", value: "\(invalidServerCount)")
|
|
}
|
|
LabeledContent("来源", value: isManual ? "手动" : "订阅")
|
|
Button {
|
|
Task { await proxyController.activate(groupID) }
|
|
} label: {
|
|
Label("激活此分组", systemImage: "bolt.fill")
|
|
}
|
|
.disabled(validServerCount == 0)
|
|
if directChildCount == 0 {
|
|
Text("空分组保留可编辑,但不能激活。")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
} else if validServerCount == 0 {
|
|
Text("分组中没有可激活的有效服务器。")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
} else if invalidServerCount > 0 {
|
|
Text("激活时将跳过 \(invalidServerCount) 个存在已知阻塞问题的服务器。")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
}
|
|
.formStyle(.grouped)
|
|
.navigationTitle(workflow.displayName(for: groupID))
|
|
.onAppear(perform: loadName)
|
|
.onChange(of: groupID) { _, _ in loadName() }
|
|
}
|
|
|
|
private var directChildCount: Int { node?.childCount ?? 0 }
|
|
private var invalidServerCount: Int { node?.invalidServerCount ?? 0 }
|
|
private var serverCount: Int { node?.serverCount ?? 0 }
|
|
private var validServerCount: Int { serverCount - invalidServerCount }
|
|
|
|
private func loadName() {
|
|
name = workflow.displayName(for: groupID)
|
|
}
|
|
|
|
private func saveName() {
|
|
Task {
|
|
do {
|
|
try await workflow.renameGroup(groupID, to: name)
|
|
} catch {
|
|
errors.present(error)
|
|
}
|
|
}
|
|
}
|
|
}
|