mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-22 13:34:00 +00:00
主窗口服务器分区(D11,issue #32):NavigationSplitView 分组树(订阅子树 只读、仅启用开关;行内 checkbox;右键激活/启停/重命名/新建分组/移动/删除, 非空手动组二次确认;拖拽移动,跨来源拒绝;空组保留可编辑)、服务器详情 表单(插件区只读展示「本版本未提供」状态)、分组详情。添加三入口(剪贴板 ss://、导入 URL、二维码图片识别:文件选择 + 拖图入窗)共用批量导入落点, 每次新建身份不去重;分享区二维码弹窗 + 复制 ss://。SsUri 按 SIP002 编解码 (含 legacy base64 兼容、SIP022 明文 userinfo、IPv6、插件 name;opts 逐字节 同构),二维码走 CoreImage 生成 + Vision 识别。目录提交后接 postCommit 钩 子,代理运行时立即重展开(#27 catalogDidCommit)。
64 lines
1.8 KiB
Swift
64 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
/// 分组详情(issue #32):名称编辑(手动组)、直接子节点数与激活入口。
|
|
/// 订阅固定分组名称由远端管理,只读。空组保留可编辑(可先搭结构再填内容)。
|
|
struct GroupDetailView: View {
|
|
let viewModel: CatalogViewModel
|
|
let groupID: NodeID
|
|
let proxyController: ProxyRuntimeController
|
|
|
|
@State private var name = ""
|
|
|
|
private var entry: CatalogEntry? { viewModel.entry(for: groupID) }
|
|
private var isManual: Bool { entry?.source == .manual }
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section("分组") {
|
|
TextField("名称", text: $name)
|
|
.disabled(!isManual)
|
|
if isManual {
|
|
Button("保存名称") { saveName() }
|
|
}
|
|
}
|
|
Section {
|
|
LabeledContent("直接子节点", value: "\(directChildCount)")
|
|
LabeledContent("来源", value: isManual ? "手动" : "订阅")
|
|
Button {
|
|
Task { await proxyController.activate(groupID) }
|
|
} label: {
|
|
Label("激活此分组", systemImage: "bolt.fill")
|
|
}
|
|
.disabled(directChildCount == 0)
|
|
if directChildCount == 0 {
|
|
Text("空分组保留可编辑,但不能激活。")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
}
|
|
.formStyle(.grouped)
|
|
.navigationTitle(viewModel.displayName(for: groupID))
|
|
.onAppear(perform: loadName)
|
|
.onChange(of: groupID) { _, _ in loadName() }
|
|
}
|
|
|
|
private var directChildCount: Int {
|
|
(try? viewModel.catalog.children(of: groupID))?.count ?? 0
|
|
}
|
|
|
|
private func loadName() {
|
|
name = viewModel.displayName(for: groupID)
|
|
}
|
|
|
|
private func saveName() {
|
|
Task {
|
|
do {
|
|
try await viewModel.renameGroup(groupID, to: name)
|
|
} catch {
|
|
viewModel.presentedError = error.presentableMessage
|
|
}
|
|
}
|
|
}
|
|
}
|