Merge pull request #21 from hkgood/cursor/simplify-polish-context-6baf

统一润色逻辑:全自动场景,移除润色场景与自定义提示词
This commit is contained in:
cursor[bot]
2026-07-03 09:33:52 +00:00
committed by GitHub
17 changed files with 31 additions and 844 deletions
-59
View File
@@ -1,59 +0,0 @@
// ScenarioPickerRow.swift
// OSGKeyboard · Main App
//
// Single-row polish scenario picker. Maps menu choices to
// `ProviderConfig.polishScenarioId`. Custom scenario uses the existing
// system prompt editor (linked from Settings when selected).
import SwiftUI
import OSGKeyboardShared
struct ScenarioPickerRow: View {
@Environment(\.themePalette) private var palette: ThemePalette
@ObservedObject var config: ProviderConfig
var isVisible: Bool = true
var body: some View {
if isVisible {
HStack {
Text("settings.polishScenario.title")
.font(TypeStyle.body)
.foregroundStyle(palette.textPrimary)
Spacer()
Menu {
ForEach(PolishScenarioCatalog.all) { scenario in
Button {
config.polishScenarioId = scenario.id
} label: {
if config.polishScenarioId == scenario.id {
Label(displayLabel(for: scenario), systemImage: "checkmark")
} else {
Text(displayLabel(for: scenario))
}
}
}
} label: {
HStack(spacing: 6) {
Text(currentLabel)
.font(TypeStyle.body)
.foregroundStyle(palette.textPrimary)
Image(systemName: "chevron.up.chevron.down")
.font(.system(size: 11, weight: .bold))
.foregroundStyle(palette.textTertiary)
}
}
}
.padding(.horizontal, Spacing.md)
.frame(minHeight: SettingsListMetrics.singleLineMinHeight)
}
}
private var currentLabel: String {
displayLabel(for: PolishScenarioCatalog.resolve(config.polishScenarioId))
}
private func displayLabel(for scenario: PolishScenario) -> String {
PolishScenarioCatalog.displayName(for: scenario.id, language: config.uiLanguage)
}
}
+2 -15
View File
@@ -135,22 +135,9 @@ struct SettingsView: View {
set: { config.localeId = $0 }
)
)
if config.isPolishScenarioRowVisible {
if config.isTranslationRowVisible {
Divider().background(palette.divider)
ScenarioPickerRow(config: config, isVisible: true)
if config.engineMode == "cloud", config.isTranslationRowVisible {
Divider().background(palette.divider)
TranslationPickerRow(config: config, isVisible: true)
}
if config.isCustomPolishScenario {
Divider().background(palette.divider)
NavigationLink {
SystemPromptSettingsView(config: config)
} label: {
footerNavigationRow(title: "settings.systemPrompt.edit")
}
.buttonStyle(.plain)
}
TranslationPickerRow(config: config, isVisible: true)
}
}
.background(palette.surface, in: RoundedRectangle(cornerRadius: Radius.large, style: .continuous))
@@ -1,60 +0,0 @@
// SystemPromptSettingsView.swift
// OSGKeyboard · Main App
//
// Cloud-engine system prompt editor. Reached from Settings when the
// user picks the cloud recognition path.
import SwiftUI
import OSGKeyboardShared
struct SystemPromptSettingsView: View {
@Environment(\.themePalette) private var palette: ThemePalette
@ObservedObject var config: ProviderConfig
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: Spacing.sm) {
Text("settings.systemPrompt.hint")
.font(TypeStyle.caption2)
.foregroundStyle(palette.textTertiary)
.fixedSize(horizontal: false, vertical: true)
if config.isCustomPolishScenario {
Text("settings.polishScenario.customHint")
.font(TypeStyle.caption2)
.foregroundStyle(palette.textTertiary)
.fixedSize(horizontal: false, vertical: true)
}
TextEditor(text: $config.systemPrompt)
.font(TypeStyle.mono)
.scrollContentBackground(.hidden)
.frame(minHeight: 320)
.padding(Spacing.sm)
.background(palette.surface, in: RoundedRectangle(cornerRadius: Radius.large, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: Radius.large, style: .continuous)
.stroke(palette.divider, lineWidth: 0.5)
)
}
.padding(.horizontal, Spacing.md)
.padding(.vertical, Spacing.md)
}
.background(palette.background.ignoresSafeArea())
.navigationTitle("settings.systemPrompt.title")
.navigationBarTitleDisplayMode(.inline)
.toolbar(.visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("common.reset") {
config.systemPrompt = config.defaultSystemPrompt
}
.font(TypeStyle.body)
.foregroundStyle(palette.accent)
}
}
.toolbarBackground(palette.background, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
}
}