Files
ShadowsocksX-NG/ShadowsocksX-NG2/App/UI/Workspace/SidebarRow.swift
T
Qiu Yuzhou fb428f12bc refactor(app): 按分层重组 App/ 源码目录
App/ 根目录原有 73 个散落源文件,已无法从目录读出任何分组信息。

按「目录即分层」重组为 Composition / Application / Presentation / UI /
PlatformEffects / Resources 六个目录,UI 层再按子视图分目录(Workspace、
Home、Servers(含 Plugin)、Subscriptions、Rules、Settings、Diagnostics、
StatusMenu)。纯移动:类型名、模块名与 import 均未改动,App/ 根层不再有
散落文件。

配套改动:

- project.yml:Core 测试镜像的 excludes 由裸文件名改为 `**/` 递归形式。
  XcodeGen 的 exclude 不跨 `/`,裸名只匹配 App 根层;MainApp.swift 下移后
  旧写法会静默失效,把 @main 组合根编进测试镜像。info.path 与
  entitlements.path 指向 App/Resources/;并排除 `**/*.md`——App/ 下任何
  非源码文件都会被 XcodeGen 收进 Resources 阶段并封进签名后的 bundle。
- SkeletonTests 的架构守卫由「默认扫描全部 App/ + 7 个豁免文件 + 1 个豁免
  前缀 + 4 个豁免目录」改为正面圈定 App/UI/,豁免登记全部删除;新增运行时
  适配器放进 Application/ 即自动落在扫描范围外,无需再登记。
- README 工程结构说明同步;根 .gitignore 的生成物路径随 Resources/ 归位。

验证:clean build 0 error;task test 1022 用例全通过(含两个架构守卫);
task format 无改动(证明纯移动);task lint 与移动前同为 21 条内容型
warning;packaging-gate.sh ALL CHECKS PASSED,确认 plist/entitlements 归位
后签名与 entitlements 语义不变。

注意:迁移时须先删旧的生成物再 xcodegen generate,否则遗留的 App/Info.plist
会被当作普通资源扫进 Resources 阶段。
2026-10-05 19:56:18 +08:00

101 lines
3.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import SwiftUI
/// 侧栏树行(issue #41):来源标识、有效性提示、活动目标标记与右键菜单。
/// 数据来自目录工作流 module 的树 projection;激活经 seam 的 typed command,
/// 活动目标标记由父视图传入(运行时事实,不进目录 projection)。删除一律
/// 交父视图确认弹窗(空手动组单次、非空二次,GLOSSARY.md)。
struct SidebarRow: View {
let node: CatalogTreeNode
let workflow: CatalogWorkflow
/// 激活反馈共享状态:命令经它发出(单飞互斥、结果记录在会话反馈里)。
let activation: ActivationFeedbackState
let activeTargetID: NodeID?
let errors: ErrorAlertPresenter
let onRename: (NodeID) -> Void
let onNewGroup: (NodeID?) -> Void
let onMove: (NodeID) -> Void
let onDelete: (NodeID) -> Void
let onExport: (NodeID) -> Void
private var isSubscription: Bool { node.source == .subscription }
var body: some View {
HStack(spacing: 6) {
Image(systemName: node.isGroup ? "folder" : "server.rack")
.foregroundStyle(.secondary)
VStack(alignment: .leading, spacing: 1) {
Text(node.name)
.foregroundStyle(node.isInvalid ? .secondary : .primary)
if node.isGroup {
// 分组行尾数量说明(票 #55):原型「手动分组 · N 项」口径。
Text("\(node.isManual ? "手动分组" : "订阅分组") · \(node.childCount) 项")
.font(.caption)
.foregroundStyle(.tertiary)
}
}
if node.isInvalid {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(.orange)
.help(
node.invalidReasons.first.map {
AppPresentation.message(
for: ActivationFailure.invalidLeaf(node: node.id, reason: $0))
} ?? "服务器存在已知阻塞问题")
} else if node.invalidDescendantCount > 0 {
Image(systemName: "exclamationmark.triangle")
.foregroundStyle(.orange)
.help("包含 \(node.invalidDescendantCount) 个存在已知阻塞问题的服务器")
}
if isSubscription {
Image(systemName: "arrow.triangle.2.circlepath")
.foregroundStyle(.tertiary)
.help("订阅节点:由远端管理")
}
if activeTargetID == node.id {
Image(systemName: "bolt.fill")
.foregroundStyle(.orange)
.help("活动目标")
}
}
.contextMenu { contextMenu }
}
@ViewBuilder
private var contextMenu: some View {
Button("激活") {
Task { @MainActor in
do {
let outcome = try await activation.activate(node.id, via: workflow)
// 右键菜单即关、无内联反馈面:原子拒绝点名弹窗(typed 原因随
// 结果返回);单飞忽略(nil)不呈现。
if case .rejectedActivation(let failure)? = outcome {
errors.present(failure)
}
} catch {
errors.present(error)
}
}
}
if node.isGroup {
Divider()
Button("导出为 SIP-008 JSON…") { onExport(node.id) }
.disabled(!node.containsServerConfiguration)
}
if !isSubscription {
Divider()
if node.isGroup {
Button("重命名…") { onRename(node.id) }
}
Button("新建分组…") {
onNewGroup(node.isGroup ? node.id : node.parentID)
}
Divider()
Button("移动到…") { onMove(node.id) }
Divider()
Button("删除…", role: .destructive) {
onDelete(node.id)
}
}
}
}