- 新增 AppleSpeechASRProvider:包装 SFSpeechRecognizer,on-device 优先, partial / final 走标准 ASRStreamingSession 协议,无需 API key - 新增 ASRProviderRegistry:M1 预设 volcengine / apple-speech - CredentialsVault 增加 activeASRProviderId / configuredASRProviderIds - DictationCoordinator.makeASRProvider 改为按 vault.activeASRProviderId 路由 - 新增 ASR Tab(chip 切换 + 主操作「保存」按钮);侧边栏导航新增 .asr - scripts/build-app.sh Info.plist 加入 NSSpeechRecognitionUsageDescription - Tests/OpenLessCoreTests 新增 ASRProviderRegistryTests
96 lines
2.8 KiB
Swift
96 lines
2.8 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
import OpenLessCore
|
|
import OpenLessHotkey
|
|
import OpenLessPersistence
|
|
import OpenLessRecorder
|
|
import OpenLessASR
|
|
import OpenLessPolish
|
|
|
|
// 设置窗口的根入口:导航枚举 + 模型 + 主分发。
|
|
// 共享组件、侧边栏、各 Tab、遗留 Tab、通知名都在同目录其他文件里。
|
|
|
|
enum OpenLessMainTab: String, CaseIterable, Identifiable {
|
|
case home
|
|
case history
|
|
case dictionary
|
|
case polish
|
|
case asr
|
|
case llm
|
|
case help
|
|
case settings
|
|
|
|
var id: String { rawValue }
|
|
|
|
var title: String {
|
|
switch self {
|
|
case .home: return "首页"
|
|
case .history: return "历史记录"
|
|
case .dictionary: return "词汇表"
|
|
case .polish: return "风格"
|
|
case .asr: return "ASR"
|
|
case .llm: return "LLM Provider"
|
|
case .help: return "帮助中心"
|
|
case .settings: return "设置"
|
|
}
|
|
}
|
|
|
|
var symbol: String {
|
|
switch self {
|
|
case .home: return "chart.line.uptrend.xyaxis"
|
|
case .history: return "clock"
|
|
case .dictionary: return "text.book.closed"
|
|
case .polish: return "paintpalette"
|
|
case .asr: return "waveform"
|
|
case .llm: return "wand.and.stars"
|
|
case .help: return "questionmark.circle"
|
|
case .settings: return "gearshape"
|
|
}
|
|
}
|
|
}
|
|
|
|
@MainActor
|
|
final class SettingsNavigationModel: ObservableObject {
|
|
@Published var selection: OpenLessMainTab
|
|
|
|
init(selection: OpenLessMainTab = .home) {
|
|
self.selection = selection
|
|
}
|
|
}
|
|
|
|
struct SettingsView: View {
|
|
@ObservedObject private var navigation: SettingsNavigationModel
|
|
|
|
init(navigation: SettingsNavigationModel) {
|
|
self.navigation = navigation
|
|
}
|
|
|
|
var body: some View {
|
|
HStack(spacing: 14) {
|
|
FixedSidebar(selection: $navigation.selection)
|
|
Group {
|
|
switch navigation.selection {
|
|
case .home: HomeTab()
|
|
case .history: HistoryTab()
|
|
case .dictionary: DictionaryTab()
|
|
case .polish: StyleTab()
|
|
case .asr: ASRProvidersTab()
|
|
case .llm: LLMProvidersTab()
|
|
case .help: HelpTab()
|
|
case .settings: SettingsHubTab()
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
// 右栏顶部留点空白,避免内容贴到 title bar 区域。
|
|
.padding(.top, 12)
|
|
}
|
|
// 左/下/右用相等 12pt;上方为 0,让侧边栏顶边贴窗口顶,
|
|
// 红绿灯(系统画在 title bar 层)就自然落在侧边栏的圆角矩形内部。
|
|
.padding(.leading, 12)
|
|
.padding(.trailing, 12)
|
|
.padding(.bottom, 12)
|
|
.background(WindowCanvasBackground())
|
|
.frame(minWidth: 1040, minHeight: 700)
|
|
}
|
|
}
|