Commit 1d312d6e authored by zpc's avatar zpc

Rebuild release workspace with compact summaries and full-height consoles

parent 94f84cae
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.3.1</string> <string>1.3.2</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>8</string> <string>9</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>14.0</string> <string>14.0</string>
<key>LSUIElement</key> <key>LSUIElement</key>
......
...@@ -6,6 +6,7 @@ struct LogTextView: NSViewRepresentable { ...@@ -6,6 +6,7 @@ struct LogTextView: NSViewRepresentable {
let errorLine: Int? let errorLine: Int?
let jumpRequest: Int let jumpRequest: Int
var followsOutput = false var followsOutput = false
var fontSize: CGFloat = 11
final class Coordinator { final class Coordinator {
var text: String? var text: String?
...@@ -41,7 +42,7 @@ struct LogTextView: NSViewRepresentable { ...@@ -41,7 +42,7 @@ struct LogTextView: NSViewRepresentable {
coordinator.text = text coordinator.text = text
coordinator.errorRange = nil coordinator.errorRange = nil
let styled = NSMutableAttributedString(string: text, attributes: [ let styled = NSMutableAttributedString(string: text, attributes: [
.font: NSFont.monospacedSystemFont(ofSize: 11, weight: .regular), .font: NSFont.monospacedSystemFont(ofSize: fontSize, weight: .regular),
.foregroundColor: NSColor(srgbRed: 0.78, green: 0.83, blue: 0.90, alpha: 1) .foregroundColor: NSColor(srgbRed: 0.78, green: 0.83, blue: 0.90, alpha: 1)
]) ])
if let errorLine, let range = lineRange(at: errorLine) { if let errorLine, let range = lineRange(at: errorLine) {
......
...@@ -10,16 +10,24 @@ struct SplitReleasePanel: View { ...@@ -10,16 +10,24 @@ struct SplitReleasePanel: View {
private var columnWidth: CGFloat { private var columnWidth: CGFloat {
let available = (NSScreen.main?.visibleFrame.width ?? 1440) - 32 let available = (NSScreen.main?.visibleFrame.width ?? 1440) - 32
return min(383, max(310, floor((available - 2) / CGFloat(max(1, model.panes.count))))) return min(
383,
max(
310,
floor(
(available - CGFloat(max(1, model.panes.count)))
/ CGFloat(max(1, model.panes.count)))))
} }
private var width: CGFloat { private var width: CGFloat {
let desired = CGFloat(max(1, model.panes.count)) * columnWidth + 2 let desired =
CGFloat(max(1, model.panes.count)) * columnWidth
+ CGFloat(max(0, model.panes.count - 1))
return min(desired, (NSScreen.main?.visibleFrame.width ?? 1440) - 32) return min(desired, (NSScreen.main?.visibleFrame.width ?? 1440) - 32)
} }
private var columnHeight: CGFloat { private var columnHeight: CGFloat {
min(700, max(470, (NSScreen.main?.visibleFrame.height ?? 900) - 145)) min(650, max(380, (NSScreen.main?.visibleFrame.height ?? 900) - 160))
} }
var body: some View { var body: some View {
...@@ -33,14 +41,14 @@ struct SplitReleasePanel: View { ...@@ -33,14 +41,14 @@ struct SplitReleasePanel: View {
) )
.rotationEffect(.degrees(-90)) .rotationEffect(.degrees(-90))
} }
.frame(width: 26, height: 26) .frame(width: 32, height: 32)
Text("Java 发布").font(.system(size: 18, weight: .semibold)) Text("Java 发布").font(.system(size: 23, weight: .semibold))
Spacer() Spacer()
Button(action: model.add) { Button(action: model.add) {
Label("增加窗口", systemImage: "plus") Label("增加窗口", systemImage: "plus")
.font(ReleaseTypography.action) .font(ReleaseTypography.action)
.padding(.horizontal, 10) .padding(.horizontal, 10)
.frame(height: 29) .frame(height: 35)
} }
.disabled( .disabled(
model.isRunning || model.panes.count >= 4 model.isRunning || model.panes.count >= 4
...@@ -64,7 +72,7 @@ struct SplitReleasePanel: View { ...@@ -64,7 +72,7 @@ struct SplitReleasePanel: View {
.accessibilityLabel("项目设置") .accessibilityLabel("项目设置")
} }
.padding(.horizontal, 18) .padding(.horizontal, 18)
.frame(height: 58) .frame(height: 70)
Rectangle().fill(ReleaseColors.border).frame(height: 1) Rectangle().fill(ReleaseColors.border).frame(height: 1)
...@@ -87,7 +95,8 @@ struct SplitReleasePanel: View { ...@@ -87,7 +95,8 @@ struct SplitReleasePanel: View {
} }
} }
} }
.scrollIndicators(.automatic) .frame(height: columnHeight)
.scrollIndicators(.hidden)
Rectangle().fill(ReleaseColors.border).frame(height: 1) Rectangle().fill(ReleaseColors.border).frame(height: 1)
HStack { HStack {
if model.isRunning { if model.isRunning {
...@@ -100,18 +109,18 @@ struct SplitReleasePanel: View { ...@@ -100,18 +109,18 @@ struct SplitReleasePanel: View {
Spacer() Spacer()
Button(action: model.publishAll) { Button(action: model.publishAll) {
Text("一起发布 \(model.panes.count) 个项目") Text("一起发布 \(model.panes.count) 个项目")
.font(.system(size: 14, weight: .semibold)) .font(.system(size: 18, weight: .semibold))
.foregroundStyle(.white) .foregroundStyle(.white)
.padding(.horizontal, 23) .padding(.horizontal, 36)
.frame(height: 40) .frame(height: 46)
} }
.disabled(model.isRunning || model.panes.count < 2) .disabled(model.isRunning || model.panes.count < 2)
.buttonStyle(ReleaseButtonStyle(base: ReleaseColors.action, prominent: true)) .buttonStyle(ReleaseButtonStyle(base: ReleaseColors.action, prominent: true))
} }
.font(ReleaseTypography.detail) .font(.system(size: 16))
.foregroundStyle(ReleaseColors.muted) .foregroundStyle(.white.opacity(0.9))
.padding(.horizontal, 18) .padding(.horizontal, 18)
.frame(height: 66) .frame(height: 78)
} }
if let error = model.error { if let error = model.error {
Text(error).font(.caption).foregroundStyle(.red) Text(error).font(.caption).foregroundStyle(.red)
...@@ -119,7 +128,17 @@ struct SplitReleasePanel: View { ...@@ -119,7 +128,17 @@ struct SplitReleasePanel: View {
} }
} }
.frame(width: width) .frame(width: width)
.background(ReleaseColors.panel) .background {
LinearGradient(
colors: [
Color(red: 0.15, green: 0.16, blue: 0.18),
Color(red: 0.105, green: 0.115, blue: 0.135),
], startPoint: .topLeading, endPoint: .bottomTrailing)
}
.overlay {
RoundedRectangle(cornerRadius: 14).strokeBorder(Color.white.opacity(0.18))
.allowsHitTesting(false)
}
.environment(\.colorScheme, .dark) .environment(\.colorScheme, .dark)
.tint(ReleaseColors.blue) .tint(ReleaseColors.blue)
} }
...@@ -131,6 +150,9 @@ private struct ProjectReleaseColumn: View { ...@@ -131,6 +150,9 @@ private struct ProjectReleaseColumn: View {
let height: CGFloat let height: CGFloat
@State private var configurationDraft: DeployProfile? @State private var configurationDraft: DeployProfile?
@State private var showsModules = false @State private var showsModules = false
@State private var showsConfiguration = false
@State private var showsProjects = false
@FocusState private var moduleSearchFocused: Bool
private var project: ReleaseProject? { model.project(for: pane) } private var project: ReleaseProject? { model.project(for: pane) }
private var profile: DeployProfile? { project?.profiles.first { $0.id == pane.profileID } } private var profile: DeployProfile? { project?.profiles.first { $0.id == pane.profileID } }
...@@ -145,284 +167,221 @@ private struct ProjectReleaseColumn: View { ...@@ -145,284 +167,221 @@ private struct ProjectReleaseColumn: View {
} }
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(alignment: .leading, spacing: 18) {
ScrollView(.vertical) { HStack(spacing: 8) {
VStack(alignment: .leading, spacing: 12) { Button {
HStack(spacing: 8) { showsProjects.toggle()
Image(systemName: "folder") } label: {
.foregroundStyle(ReleaseColors.muted) Text(project?.name ?? "选择项目")
Menu { .font(.system(size: 20, weight: .semibold))
ForEach( .foregroundStyle(.white)
model.settings.projects.filter { candidate in .lineLimit(1)
!model.panes.contains { .minimumScaleFactor(0.75)
$0.id != pane.id && $0.projectID == candidate.id .frame(maxWidth: .infinity, alignment: .leading)
} .contentShape(Rectangle())
}
.buttonStyle(ReleaseButtonStyle())
.disabled(!editable)
.popover(isPresented: $showsProjects) {
VStack(alignment: .leading, spacing: 8) {
Text("选择项目").font(.headline).padding(.bottom, 4)
ForEach(
model.settings.projects.filter { candidate in
!model.panes.contains {
$0.id != pane.id && $0.projectID == candidate.id
} }
) { candidate in
Button(candidate.name) { model.replace(pane, with: candidate) }
} }
} label: { ) { candidate in
HStack { Button(candidate.name) {
Text(project?.name ?? "选择项目") showsProjects = false
.lineLimit(1) model.replace(pane, with: candidate)
.frame(maxWidth: .infinity, alignment: .leading)
Image(systemName: "chevron.down")
.font(.system(size: 10, weight: .semibold))
} }
.font(.system(size: 16, weight: .semibold)) .buttonStyle(ReleaseButtonStyle())
}
.menuStyle(.borderlessButton)
.menuIndicator(.hidden)
.disabled(!editable)
Button {
model.remove(pane)
} label: {
Image(systemName: "xmark")
.font(.system(size: 11, weight: .semibold))
.frame(width: 24, height: 24)
} }
.buttonStyle(ReleaseButtonStyle())
.overlay { Circle().strokeBorder(ReleaseColors.border) }
.disabled(!editable)
.help("减少窗口")
} }
.frame(height: 28) .padding(16)
.frame(minWidth: 220, alignment: .leading)
.environment(\.colorScheme, .dark)
}
Button {
model.remove(pane)
} label: {
Label("减少窗口", systemImage: "xmark")
.font(.system(size: 11))
.padding(.horizontal, 8)
.frame(height: 26)
}
.buttonStyle(ReleaseButtonStyle())
.overlay {
RoundedRectangle(cornerRadius: 7).strokeBorder(Color.white.opacity(0.35))
}
.disabled(!editable)
.help("减少窗口")
}
.frame(height: 28)
if let project { if project != nil {
if project.type == .cityKeeper { Button {
menuRow("发布配置", value: profile?.title ?? "选择配置文件") { showsConfiguration.toggle()
let files = } label: {
(try? project.configurationFiles()) HStack(spacing: 4) {
?? project.profiles.map(\.file) Text(configurationSummary).lineLimit(1).truncationMode(.middle)
ForEach(files, id: \.self) { file in Image(systemName: "chevron.down").font(.system(size: 9))
Button( }
project.profiles.first(where: { $0.file == file })?.title .foregroundStyle(Color.white.opacity(0.85))
?? file .frame(maxWidth: .infinity, alignment: .leading)
) { .contentShape(Rectangle())
selectConfiguration(file, in: project) }
} .buttonStyle(.plain)
} .disabled(!editable)
Divider() .help("选择发布配置、服务器和 Maven")
Button("浏览其他 YAML…") { browseConfiguration(in: project) } .popover(isPresented: $showsConfiguration) {
} configurationControls
menuRow( }
"服务器",
value: pane.servers.first(where: { $0.name == pane.server })?
.displayName ?? "选择服务器"
) {
ForEach(pane.servers, id: \.name) { target in
Button(target.displayName) {
pane.server = target.name
model.save()
}
}
}
menuRow("Maven", value: pane.mavenCommand.title) {
ForEach(MavenCommand.allCases) { command in
Button(command.title) {
pane.mavenCommand = command
model.save()
}
}
}
HStack(spacing: 12) {
Toggle("VPC", isOn: $pane.useVPC)
if project.supportsVerifiedRelease(profile) {
Toggle("验证发布", isOn: $pane.verified)
Spacer(minLength: 0)
Button("预检") { model.publish(pane, action: .preflight) }
.buttonStyle(ReleaseButtonStyle())
.disabled(!editable || pane.modules.isEmpty)
} else {
Spacer(minLength: 0)
}
if let profile {
Button {
configurationDraft = profile
} label: {
Image(systemName: "slider.horizontal.3")
}
.buttonStyle(ReleaseButtonStyle())
.help("编辑配置别名和 SSH 目标")
.disabled(!editable)
}
}
.toggleStyle(.checkbox)
.font(ReleaseTypography.detail)
.disabled(!editable)
.onChange(of: pane.useVPC) { model.save() }
.onChange(of: pane.verified) { model.save() }
}
HStack { HStack(spacing: 7) {
Text("模块").font(.system(size: 13, weight: .medium)) Image(systemName: "magnifyingglass")
Spacer() .foregroundStyle(ReleaseColors.muted)
Text("已选 \(pane.selectedCount) 个") TextField("搜索模块…", text: $pane.search)
.foregroundStyle(ReleaseColors.muted) .textFieldStyle(.plain)
.onChange(of: pane.search) { showsModules = true }
if !pane.search.isEmpty {
Button {
pane.search = ""
} label: {
Image(systemName: "xmark.circle.fill")
} }
.font(ReleaseTypography.detail) .buttonStyle(.plain)
.padding(.top, 4) }
Button {
showsModules.toggle()
} label: {
Image(systemName: showsModules ? "chevron.up" : "chevron.down")
}
.buttonStyle(.plain)
.help("选择模块")
}
.font(ReleaseTypography.body)
.padding(.horizontal, 11)
.frame(height: 34)
.background(ReleaseColors.surface, in: RoundedRectangle(cornerRadius: 7))
.overlay {
RoundedRectangle(cornerRadius: 7).strokeBorder(Color.white.opacity(0.32))
}
.disabled(!editable)
.popover(isPresented: $showsModules, arrowEdge: .bottom) {
modulePicker
}
HStack(spacing: 7) { if !pane.modules.isEmpty {
Image(systemName: "magnifyingglass") ScrollView(.horizontal) {
.foregroundStyle(ReleaseColors.muted) HStack(spacing: 6) {
TextField("搜索模块…", text: $pane.search) ForEach(pane.modules, id: \.self) { module in
.textFieldStyle(.plain)
.onChange(of: pane.search) { showsModules = true }
if !pane.search.isEmpty {
Button { Button {
pane.search = "" pane.toggle(module)
} label: { } label: {
Image(systemName: "xmark.circle.fill") HStack(spacing: 5) {
} Text(module).lineLimit(1)
.buttonStyle(.plain) Image(systemName: "xmark")
} .font(.system(size: 9, weight: .semibold))
Button {
showsModules.toggle()
} label: {
Image(systemName: showsModules ? "chevron.up" : "chevron.down")
}
.buttonStyle(.plain)
.help("选择模块")
}
.font(ReleaseTypography.body)
.padding(.horizontal, 11)
.frame(height: 35)
.background(ReleaseColors.surface, in: RoundedRectangle(cornerRadius: 7))
.overlay {
RoundedRectangle(cornerRadius: 7).strokeBorder(ReleaseColors.border)
}
.disabled(!editable)
if showsModules {
ScrollView {
LazyVStack(spacing: 2) {
ForEach(matches, id: \.self) { module in
Button {
pane.toggle(module)
} label: {
HStack(spacing: 8) {
Image(
systemName: pane.modules.contains(module)
? "checkmark.square.fill" : "square"
)
.foregroundStyle(
pane.modules.contains(module)
? ReleaseColors.blue : ReleaseColors.muted)
Text(module).lineLimit(1)
Spacer()
}
.padding(.horizontal, 10)
.frame(height: 29)
}
.buttonStyle(
ReleaseButtonStyle(
base: pane.modules.contains(module)
? ReleaseColors.blue.opacity(0.12) : .clear))
}
if matches.isEmpty {
Text("没有匹配的模块")
.foregroundStyle(ReleaseColors.muted).padding(8)
}
}
.padding(4)
}
.frame(height: min(112, CGFloat(matches.count) * 31 + 8))
.background(
ReleaseColors.terminal, in: RoundedRectangle(cornerRadius: 7))
}
if !pane.modules.isEmpty {
ScrollView(.horizontal) {
HStack(spacing: 6) {
ForEach(pane.modules, id: \.self) { module in
Button {
pane.toggle(module)
} label: {
HStack(spacing: 5) {
Text(module).lineLimit(1)
Image(systemName: "xmark")
.font(.system(size: 9, weight: .semibold))
}
.font(ReleaseTypography.detail)
.foregroundStyle(ReleaseColors.blue)
.padding(.horizontal, 10)
.frame(height: 27)
.background(
ReleaseColors.blue.opacity(0.15),
in: Capsule())
}
.buttonStyle(.plain)
.disabled(!editable)
} }
.font(ReleaseTypography.detail)
.foregroundStyle(.white)
.padding(.horizontal, 10)
.frame(height: 30)
.background(
ReleaseColors.action,
in: Capsule())
} }
.buttonStyle(.plain)
.disabled(!editable)
} }
.scrollIndicators(.hidden)
.frame(height: 30)
} }
}
.scrollIndicators(.hidden)
.frame(height: 32)
} else {
Text("请选择模块").foregroundStyle(ReleaseColors.muted)
.frame(height: 32)
}
VStack(spacing: 0) { VStack(spacing: 0) {
HStack { HStack {
Text("实时输出 · \(paneTitle)") Text("实时输出 · \(paneTitle)")
.font(.system(size: 12, weight: .medium)) .font(.system(size: 14, weight: .medium))
Spacer() .lineLimit(1)
if pane.state == .running { Spacer()
Button(pane.paused ? "继续" : "暂停") { model.togglePause(pane) } if pane.state == .running {
.disabled(pane.stopping) Button(pane.paused ? "继续" : "暂停") { model.togglePause(pane) }
Button("停止") { model.stop(pane) } .disabled(pane.stopping)
.disabled(pane.stopping) Button("停止") { model.stop(pane) }
} .disabled(pane.stopping)
}
.foregroundStyle(ReleaseColors.muted)
.padding(.horizontal, 11)
.frame(height: 34)
.background(ReleaseColors.surface)
LogTextView(
text: pane.log.isEmpty
? (pane.state == .queued ? "等待构建资源…" : "等待发布,命令和输出将在这里显示。")
: pane.log,
errorLine: nil, jumpRequest: 0,
followsOutput: pane.state == .running
)
.frame(height: 195)
}
.buttonStyle(ReleaseButtonStyle())
.background(ReleaseColors.terminal, in: RoundedRectangle(cornerRadius: 8))
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay {
RoundedRectangle(cornerRadius: 8).strokeBorder(ReleaseColors.border)
}
if let result = pane.result {
Button("打开完整日志") {
NSWorkspace.shared.open(model.logURL(for: result))
}
.font(ReleaseTypography.detail)
.buttonStyle(ReleaseButtonStyle())
}
if let issue = pane.error ?? pane.result?.message, !issue.isEmpty {
Text(issue).font(.caption).foregroundStyle(.red).lineLimit(2)
} }
} }
.foregroundStyle(.white.opacity(0.9))
.padding(.horizontal, 11)
.frame(height: 34)
.background(ReleaseColors.surface)
LogTextView(
text: pane.log.isEmpty
? (pane.state == .queued ? "等待构建资源…" : "等待发布,命令和输出将在这里显示。")
: pane.log,
errorLine: nil, jumpRequest: 0,
followsOutput: pane.state == .running, fontSize: 13
)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.layoutPriority(1)
}
.buttonStyle(ReleaseButtonStyle())
.frame(maxHeight: .infinity)
.background(ReleaseColors.terminal, in: RoundedRectangle(cornerRadius: 8))
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay {
RoundedRectangle(cornerRadius: 8).strokeBorder(ReleaseColors.border)
}
if let result = pane.result {
Button("打开完整日志") {
NSWorkspace.shared.open(model.logURL(for: result))
}
.font(ReleaseTypography.detail)
.buttonStyle(ReleaseButtonStyle())
}
if let issue = pane.error ?? pane.result?.message, !issue.isEmpty {
Text(issue).font(.caption).foregroundStyle(.red).lineLimit(2)
} }
.padding(18)
} }
Button(action: { model.publish(pane) }) { Button(action: { model.publish(pane) }) {
Text("发布此项目") Text("发布此项目")
.font(.system(size: 13, weight: .semibold)) .font(.system(size: 15, weight: .medium))
.foregroundStyle(editable ? ReleaseColors.blue : ReleaseColors.muted) .foregroundStyle(
editable && !pane.modules.isEmpty ? .white : ReleaseColors.muted
)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: 39) .frame(height: 40)
} }
.disabled(model.isRunning || pane.modules.isEmpty) .disabled(model.isRunning || pane.modules.isEmpty)
.buttonStyle(ReleaseButtonStyle()) .buttonStyle(ReleaseButtonStyle())
.overlay { .overlay {
RoundedRectangle(cornerRadius: 8) RoundedRectangle(cornerRadius: 8)
.strokeBorder(editable ? ReleaseColors.blue : ReleaseColors.border) .strokeBorder(Color.white.opacity(0.4))
.allowsHitTesting(false) .allowsHitTesting(false)
} }
.padding(.horizontal, 18)
.padding(.bottom, 18)
} }
.padding(18)
.frame(height: height) .frame(height: height)
.background {
if pane.state == .running {
LinearGradient(
colors: [ReleaseColors.blue.opacity(0.18), ReleaseColors.blue.opacity(0.07)],
startPoint: .top, endPoint: .bottom)
}
}
.overlay {
if pane.state == .running {
RoundedRectangle(cornerRadius: 7).strokeBorder(ReleaseColors.blue.opacity(0.45))
.allowsHitTesting(false)
}
}
.font(ReleaseTypography.body) .font(ReleaseTypography.body)
.popover(item: $configurationDraft) { draft in .popover(item: $configurationDraft) { draft in
ConfigurationEditor(profile: draft) { updated in ConfigurationEditor(profile: draft) { updated in
...@@ -432,6 +391,144 @@ private struct ProjectReleaseColumn: View { ...@@ -432,6 +391,144 @@ private struct ProjectReleaseColumn: View {
} }
} }
private var modulePicker: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text("选择模块").font(.headline)
Spacer()
Button("完成") { showsModules = false }
}
ScrollView {
LazyVStack(spacing: 2) {
ForEach(matches, id: \.self) { module in
Button {
pane.toggle(module)
} label: {
HStack(spacing: 8) {
Image(
systemName: pane.modules.contains(module)
? "checkmark.square.fill" : "square"
)
.foregroundStyle(
pane.modules.contains(module)
? ReleaseColors.blue : ReleaseColors.muted)
Text(module).lineLimit(1)
Spacer()
}
.padding(.horizontal, 10)
.frame(height: 29)
}
.buttonStyle(
ReleaseButtonStyle(
base: pane.modules.contains(module)
? ReleaseColors.blue.opacity(0.12) : .clear))
}
if matches.isEmpty {
Text("没有匹配的模块")
.foregroundStyle(ReleaseColors.muted).padding(8)
}
}
.padding(4)
}
.frame(height: max(44, min(220, CGFloat(matches.count) * 31 + 8)))
.background(
ReleaseColors.terminal, in: RoundedRectangle(cornerRadius: 7))
}
.padding(12)
.frame(width: 310)
.environment(\.colorScheme, .dark)
}
private var configurationSummary: String {
let destination =
pane.servers.first(where: { $0.name == pane.server })?.displayName ?? "选择服务器"
let configuration = profile?.title ?? "选择配置"
return "\(configuration) · \(destination) · \(pane.selectedCount) 个模块"
}
private var configurationControls: some View {
VStack(alignment: .leading, spacing: 14) {
Text("发布选项").font(.headline)
if let project {
if project.type == .cityKeeper {
menuRow("发布配置", value: profile?.title ?? "选择配置文件") {
let files =
(try? project.configurationFiles())
?? project.profiles.map(\.file)
ForEach(files, id: \.self) { file in
Button(
project.profiles.first(where: { $0.file == file })?.title
?? file
) {
selectConfiguration(file, in: project)
}
}
Divider()
Button("浏览其他 YAML…") { browseConfiguration(in: project) }
}
menuRow(
"服务器",
value: pane.servers.first(where: { $0.name == pane.server })?
.displayName ?? "选择服务器"
) {
ForEach(pane.servers, id: \.name) { target in
Button(target.displayName) {
pane.server = target.name
model.save()
}
}
}
menuRow("Maven", value: pane.mavenCommand.title) {
ForEach(MavenCommand.allCases) { command in
Button(command.title) {
pane.mavenCommand = command
model.save()
}
}
}
HStack(spacing: 12) {
Toggle("VPC", isOn: $pane.useVPC)
if project.supportsVerifiedRelease(profile) {
Toggle("验证发布", isOn: $pane.verified)
Spacer(minLength: 0)
Button("预检") { model.publish(pane, action: .preflight) }
.buttonStyle(ReleaseButtonStyle())
.disabled(!editable || pane.modules.isEmpty)
} else {
Spacer(minLength: 0)
}
if let profile {
Button {
configurationDraft = profile
} label: {
Image(systemName: "slider.horizontal.3")
}
.buttonStyle(ReleaseButtonStyle())
.help("编辑配置别名和 SSH 目标")
.disabled(!editable)
}
}
.toggleStyle(.checkbox)
.font(ReleaseTypography.detail)
.disabled(!editable)
.onChange(of: pane.useVPC) { model.save() }
.onChange(of: pane.verified) { model.save() }
}
if project.type != .cityKeeper {
Text("自定义项目使用项目设置中的发布脚本。")
.foregroundStyle(ReleaseColors.muted)
}
}
Button("完成") { showsConfiguration = false }
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding(18)
.frame(width: 360)
.environment(\.colorScheme, .dark)
}
private var paneTitle: String { private var paneTitle: String {
switch pane.state { switch pane.state {
case .idle: "等待发布" case .idle: "等待发布"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment