From 0847f9cf2c61c436568242c8dcfd7323c9cf1ae2 Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Sun, 4 Oct 2026 11:45:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E5=8F=82=E6=95=B0=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=88=97=E5=AE=BD=E6=94=B9=E7=94=A8=20TableColumn.wid?= =?UTF-8?q?th=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 照评审示例补齐全部列:TableColumn 实例方法 width(min:ideal:max:) 不走初值重载决议,无排序 Table 亦可设置列宽。类型/操作列与只读 类型列定宽,参数名列限宽(编辑 72–140 / 只读 72–220),值列保持 无约束弹性吸收剩余宽度;同时移除先前经内容 frame 表达宽度的 补丁(选择器 .frame(width:)、参数名 .frame(maxWidth:))。 --- ShadowsocksX-NG2/App/ServerPluginSection.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ShadowsocksX-NG2/App/ServerPluginSection.swift b/ShadowsocksX-NG2/App/ServerPluginSection.swift index e5b59c55..909480fd 100644 --- a/ShadowsocksX-NG2/App/ServerPluginSection.swift +++ b/ShadowsocksX-NG2/App/ServerPluginSection.swift @@ -175,9 +175,9 @@ private struct PluginOptionsEditor: View { // MARK: - 参数列表(Table 布局) private var tableView: some View { - // 无排序 Table 的列泛型固定为 Never,width:/value: 变体一概接不上 - // (实测 macOS 15 SDK),列宽经内容约束表达:类型列定宽、参数名列 - // 限宽、值列弹性吸收剩余宽度。 + // 无排序 Table 的列泛型固定为 Never,TableColumn 初值的 width:/value: + // 参数接不上(实测 macOS 15 SDK);列宽经实例方法 width(min:ideal:max:) + // 表达:类型/操作列定宽、参数名列限宽、值列无约束弹性吸收剩余宽度。 Table(draft.rows) { TableColumn("类型") { row in Picker( @@ -192,8 +192,8 @@ private struct PluginOptionsEditor: View { .labelsHidden() .pickerStyle(.segmented) .controlSize(.small) - .frame(width: 96) } + .width(min: 96, ideal: 96, max: 96) TableColumn("参数名") { row in HStack(spacing: 4) { TextField( @@ -203,7 +203,6 @@ private struct PluginOptionsEditor: View { set: { draft.updateKey($0, of: row.id) }) ) .textFieldStyle(.plain) - .frame(maxWidth: 140, alignment: .leading) .focused($focusedRowID, equals: row.id) if row.isUnfinished { Image(systemName: "exclamationmark.circle.fill") @@ -213,6 +212,7 @@ private struct PluginOptionsEditor: View { } } } + .width(min: 72, ideal: 96, max: 140) TableColumn("值") { row in TextField( "值", @@ -243,6 +243,7 @@ private struct PluginOptionsEditor: View { .buttonStyle(.borderless) } } + .width(min: 150, ideal: 156, max: 176) } .tableStyle(.inset) .frame(height: editTableHeight) @@ -305,9 +306,9 @@ private struct PluginOptionsReadOnlyEditor: View { Text(row.keyText) .lineLimit(1) .truncationMode(.tail) - .frame(maxWidth: 220, alignment: .leading) .textSelection(.enabled) } + .width(min: 72, ideal: 120, max: 220) TableColumn("值") { row in // 值单元格单行展示、尾部省略;完整内容保留在草稿与无障碍读取中。 Text(row.valueText) @@ -319,6 +320,7 @@ private struct PluginOptionsReadOnlyEditor: View { Text(row.kind == .flag ? "开关" : "值") .foregroundStyle(.secondary) } + .width(min: 48, ideal: 56, max: 64) } .tableStyle(.inset) .frame(height: readOnlyTableHeight)