知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
feat: rework the panel's display section and let recordings capture the notes window
wquguruf45afcb911a2
diff --git a/AGENTS.md b/AGENTS.mdindex dbf170f..ba2b16a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -13,7 +13,7 @@ Cicada (知了, formerly Live Subs): a macOS menu bar app that turns what the Ma- The Ling key lives only in the 0600 `ling-api-key` file (`AIKey`): never UserDefaults, logs or exports.- Every Ling call goes through `LingClient` (rate gate, priorities, `thinking: disabled`, content in the system message). Partial text is translated by Google, never Ling.- Never speak untranslated text into the room. Never bundle the GPL BlackHole driver; download it and check its pinned SHA-256.-- The notes window is a non-activating panel with `sharingType = .none`: it must never take focus or show in screen captures.+- The notes window is a non-activating panel with `sharingType = .none`: it must never take focus, and stays out of screen captures unless the user turns on 共享屏幕时让对方看到 (then it shows a badge).- UI and engine state are `@MainActor`; audio callbacks hand buffers to `AudioRouter`'s queue.- Don't change the release bundle id `com.wquguru.cicada` or the ad-hoc designated requirement: permissions are tied to them.- No third-party dependencies, no `.xcodeproj`; Command Line Tools only.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dbf4bec..2294a40 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,8 +5,10 @@ the release workflow publishes it as the release notes.## Unreleased+- Changed: the menu bar panel's display section is easier to read. 显示方式 is three tiles with a small picture each (实时纪要, 字幕条, 不显示), and under them one card holds only the chosen mode's settings: for the notes, whether the window is open with an 打开 / 收起 button (收起 hides it without opening the records window) and 共享屏幕时让对方看到 (formerly 录屏时显示纪要窗口); for the subtitle bar, when it appears and how long it waits; for 不显示, a line saying the transcript is still saved. The ⌃⌥S shortcut sits beside the title, and the 字幕 row above (原文 + 译文) is now called 内容 so 字幕 no longer means two things. The segmented choices left in system blue (the subtitle bar's timing in the panel and Settings, 显示方式 in Settings, 双语 / 原文 / 译文 in the records window) now use the app's own grey track with a white thumb, and the two subtitle bar choices in the panel line up at the same width.- New: turning on 同声传译 switches the Mac's system microphone to BlackHole 2ch and switches it back when 同声传译 is turned off or Cicada quits, so a meeting page in Chrome (or any app left on the default microphone) hears the translation with no setup. Cicada itself keeps recording from your real microphone (Settings › 同声传译 › 系统麦克风 lets you pin one). If Cicada didn't get to switch back (it crashed), or AirPods or something else took over the system mic while you were speaking, the menu bar panel says so with a 还原 / 换回 button; the panel's ⋯ menu also has 同声传译设置…, 试一句 and 还原系统麦克风. The switch can be turned off in Settings.- Changed: the installer window explains the first-open warning. While the developer certificate is pending, macOS says Apple can't verify Cicada; the window, now a little taller, says this is expected and shows the three screens to click through in miniature, each with the button ringed: 完成 (not 移到废纸篓), 隐私与安全性 in System Settings, then 仍要打开 under 安全性.+- New: 共享屏幕时让对方看到 lets screen recordings capture the live notes window, for demos and tutorials. It is off by default; turn it on in Settings › 显示, the menu bar panel, or 显示 › 共享屏幕时对方可见 in the app menu. macOS has one switch for recording and screen sharing, so while it is on people also see the notes when you share your screen: the notes window shows a breathing record mark next to its status the whole time, and clicking it turns the setting off. In a narrow English window, the title and the status line no longer break onto two lines.- Fixed: in English, the menu bar panel cut off its status ("English (detecting…) → …") and the interpreting languages, and Settings › 同声传译 left "· Change" alone on a second line. The panel now wraps the status and puts the languages on their own line when they don't fit.- Fixed: while you hold the talk key and speak Chinese, the subtitle bar shows your words as you say them, about a second behind. It used to show nothing for roughly ten seconds, so a short sentence only appeared after the key was released.diff --git a/README.md b/README.mdindex 622423c..79d50f3 100644--- a/README.md+++ b/README.md@@ -75,7 +75,7 @@ Cicada asks for a permission only when you use the feature that needs it; everyt- **Network and virtual microphone**: Cicada only connects to Google Translate (`translate.googleapis.com`), Ling / Ming when a key is configured (`api.ant-ling.com`), the official BlackHole download, and GitHub once a day for update checks. BlackHole is downloaded from the official Apple-notarized package and verified against a hardcoded SHA-256 checksum before installing.- **No analytics or servers of our own**: There is no analytics, no tracking, and no backend server. Diagnostics only log timings and counts locally in the meeting folder.- **Local storage**: Meetings, recordings and notes live in `~/Library/Application Support/LiveSubs`. Your Ling key and voice sample are readable only by your user account, excluded from Time Machine backups, and never written to logs or exports.-- **Private notes window**: Hidden from screen sharing, screen recording and screenshots.+- **Private notes window**: Hidden from screen sharing, screen recording and screenshots, unless you turn on 共享屏幕时让对方看到 to record a demo.## Modelsdiff --git a/README.zh-CN.md b/README.zh-CN.mdindex 365d83a..c68773e 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -75,7 +75,7 @@- **联网与虚拟麦克风**。只有翻译(`translate.googleapis.com`)、填了 key 后的 Ling / Ming(`api.ant-ling.com`)、下载 BlackHole 驱动和每天去 GitHub 检查一次新版本会联网。BlackHole 从官方下载已经过苹果公证的安装包,安装前会核对代码里写死的 SHA-256。- **没有统计和自建服务器**。应用没有统计、没有埋点,也没有我们自己的服务器,“诊断”功能只把耗时和次数记在本机会议文件夹里。- **本机数据位置**。会议记录、录音和纪要存在 `~/Library/Application Support/LiveSubs`。Ling key 和你录的声音样本只对当前系统账户可读,不进 Time Machine 备份,也不写进日志和导出文件。-- **共享屏幕看不到纪要窗口**。屏幕共享、录屏和截图都拍不到它。+- **共享屏幕看不到纪要窗口**。屏幕共享、录屏和截图都拍不到它;要录演示时可以打开“共享屏幕时让对方看到”。## 用到的模型diff --git a/Sources/LiveSubs/AppMenu.swift b/Sources/LiveSubs/AppMenu.swiftindex 664e34d..5a53a8b 100644--- a/Sources/LiveSubs/AppMenu.swift+++ b/Sources/LiveSubs/AppMenu.swift@@ -59,6 +59,7 @@ final class AppMenu: NSObject, NSMenuItemValidation {display.addItem(item(L("纪要和原话并排"), #selector(setSize(_:)), "3", tag: 2))display.addItem(.separator())display.addItem(item(L("始终置顶"), #selector(toggleOnTop)))+ display.addItem(item(L("共享屏幕时对方可见"), #selector(toggleCapturable)))add(display, to: main)// Standard actions with no target go down the responder chain (text fields, selectable text).@@ -137,6 +138,9 @@ final class AppMenu: NSObject, NSMenuItemValidation {case #selector(toggleOnTop):item.state = notesWindow.onTop ? .on : .offreturn true+ case #selector(toggleCapturable):+ item.state = model.settings.notesCapturable ? .on : .off+ return truecase #selector(search):return notesWindow.isVisiblecase #selector(checkUpdates):@@ -229,5 +233,10 @@ final class AppMenu: NSObject, NSMenuItemValidation {w.onTop.toggle()}+ @objc private func toggleCapturable() {+ guard let model else { return }+ model.setNotesCapturable(!model.settings.notesCapturable)+ }+@objc private func search() { model?.notesWindow.send(.search) }}diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex cc67a0b..4863535 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -37,6 +37,8 @@ final class AppModel: ObservableObject {@Published private(set) var ending: MeetingEndWatch.Pending?/// The last meeting ended by itself: the menu says so, and the next call in a meeting app starts a new one.@Published private(set) var autoEnded = false+ /// The notes window is on screen: the menu bar panel's 显示 / 收起 follows it.+ @Published private(set) var notesShown = falseprivate var endWatch: MeetingEndWatch?private var endTimer: Timer?/// Debug: meeting apps in a call instead of what Core Audio says, and shorter waits.@@ -467,6 +469,14 @@ final class AppModel: ObservableObject {// MARK: Display (live notes / subtitle bar / nothing)+ /// 录屏时可见: every place that shows it (settings, menu bar panel, 显示 menu, the notes+ /// window's badge) flips this one setting.+ func setNotesCapturable(_ on: Bool) {+ settings.notesCapturable = on+ notesWindow.setCapturable(on)+ objectWillChange.send()+ }+func setDisplayMode(_ mode: String) {settings.displayMode = modeobjectWillChange.send()@@ -521,6 +531,14 @@ final class AppModel: ObservableObject {notesWindow.show()}+ /// 收起 in the menu bar panel: out of the way for now, still in 实时纪要 mode+ /// (unlike the close button, it doesn't open the records window).+ func hideNotesWindow() { notesWindow.hide() }++ func notesVisibilityChanged(_ shown: Bool) {+ if notesShown != shown { notesShown = shown }+ }+// MARK: Settings actionsvar sourceSelection: String {diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swiftindex 2e9b19a..3345baa 100644--- a/Sources/LiveSubs/NotesViews.swift+++ b/Sources/LiveSubs/NotesViews.swift@@ -603,7 +603,7 @@ struct FlowLayout: Layout {// One moving thing at a time says the app is working. Driven by TimelineView rather than// repeatForever animations, which the window's once-a-second redraw would restart.-private func phase(_ date: Date, period: Double, delay: Double = 0) -> Double {+func phase(_ date: Date, period: Double, delay: Double = 0) -> Double {let t = date.timeIntervalSinceReferenceDate - delayreturn (t.truncatingRemainder(dividingBy: period) + period).truncatingRemainder(dividingBy: period) / period}diff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swiftindex 03c4cbf..0714965 100644--- a/Sources/LiveSubs/NotesWindow.swift+++ b/Sources/LiveSubs/NotesWindow.swift@@ -3,7 +3,7 @@ import Combineimport SwiftUI/// The live notes window: floats over the meeting app, can be dragged and resized anywhere,-/// stays out of screen sharing, and remembers its frame. Three layouts by width: a small card+/// stays out of screen sharing (unless 录屏时可见 is on), and remembers its frame. Three layouts by width: a small card/// (< 360), a sidebar with 纪要 / 文字记录 tabs, and notes beside the transcript (≥ 760).@MainActorfinal class NotesWindowController: NSObject, NSWindowDelegate {@@ -58,8 +58,8 @@ final class NotesWindowController: NSObject, NSWindowDelegate {p.hidesOnDeactivate = falsep.becomesKeyOnlyIfNeeded = truep.isReleasedWhenClosed = false- // Others never see it when you share your screen.- p.sharingType = .none+ // Others never see it when you share your screen, unless the user lets recordings in.+ p.sharingType = model.settings.notesCapturable ? .readOnly : .nonep.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]p.minSize = NSSize(width: 300, height: 180)p.backgroundColor = .white@@ -72,15 +72,18 @@ final class NotesWindowController: NSObject, NSWindowDelegate {panel = p}panel?.orderFrontRegardless()+ model.notesVisibilityChanged(true)}func hide() {panel?.orderOut(nil)+ model?.notesVisibilityChanged(false)}/// Closed with its close button (hide() doesn't come here): the meeting goes on in the/// records window, so the notes stay one click away.func windowWillClose(_ notification: Notification) {+ model?.notesVisibilityChanged(false)model?.notesWindowClosed()}@@ -103,7 +106,7 @@ final class NotesWindowController: NSObject, NSWindowDelegate {/// Debug control only: what the close button does.func performClose() { panel?.performClose(nil) }- /// Debug control only: let screenshots capture the window.+ /// 录屏时可见, and the debug command that flips it for one screenshot without saving it.func setCapturable(_ on: Bool) { panel?.sharingType = on ? .readOnly : .none }/// The sidebar: docked to the right edge, nearly full height.@@ -233,34 +236,38 @@ struct NotesWindowView: View {private func header(wide: Bool) -> some View {VStack(alignment: .leading, spacing: 16) {- HStack(alignment: .top, spacing: 4) {- VStack(alignment: .leading, spacing: 6) {+ // The status line gets its own full-width row: beside the buttons it had a third of a+ // narrow window, and "Listening · 00:09" or "Live notes" broke onto two lines in English.+ VStack(alignment: .leading, spacing: 6) {+ HStack(alignment: .center, spacing: 4) {Text(live || session == nil ? L("实时纪要") : L("会议纪要")).font(.system(size: 24, weight: .bold))- HStack(spacing: 6) {- if live { LiveDot() }- // Wraps rather than cut off "· 纪要已更新至 …" when the buttons leave little room.- Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(2)- .fixedSize(horizontal: false, vertical: true)+ .lineLimit(1).minimumScaleFactor(0.75)+ Spacer(minLength: 8)+ if engine.state == .updating, !engine.notes.isEmpty {+ UpdatingPill().padding(.trailing, 4)}- }- Spacer()- if engine.state == .updating, !engine.notes.isEmpty {- UpdatingPill().padding(.top, 4).padding(.trailing, 4)- }- if live {- languageChip.padding(.trailing, 2)- Button(action: askToEnd) {- Text("结束").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)- .padding(.horizontal, 12).frame(height: 28)- .overlay(RoundedRectangle(cornerRadius: 7).stroke(Palette.line, lineWidth: 1))- .contentShape(Rectangle())+ if live {+ languageChip.padding(.trailing, 2)+ Button(action: askToEnd) {+ Text("结束").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)+ .padding(.horizontal, 12).frame(height: 28)+ .overlay(RoundedRectangle(cornerRadius: 7).stroke(Palette.line, lineWidth: 1))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain).help("结束这场会议").padding(.trailing, 4)+ }+ iconButton(wide ? "rectangle.split.2x1.fill" : "rectangle.split.2x1", help: wide ? L("收窄") : L("纪要和原话并排")) {+ setWidth(wide ? 460 : 820, nil)}- .buttonStyle(.plain).help("结束这场会议").padding(.trailing, 4)+ iconButton("minus", help: L("收成小卡")) { collapse() }}- iconButton(wide ? "rectangle.split.2x1.fill" : "rectangle.split.2x1", help: wide ? L("收窄") : L("纪要和原话并排")) {- setWidth(wide ? 460 : 820, nil)+ HStack(spacing: 6) {+ if live { LiveDot() }+ Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(2)+ .fixedSize(horizontal: false, vertical: true)+ if settings.notesCapturable { capturableBadge }}- iconButton("minus", help: L("收成小卡")) { collapse() }+ .frame(minHeight: 22)}if !wide {HStack(spacing: 0) {@@ -277,6 +284,27 @@ struct NotesWindowView: View {.padding(.horizontal, 24).padding(.top, 34).padding(.bottom, 12)}+ /// Shown while 录屏时可见 is on, so it isn't left on into a shared screen: a record mark (ring+ /// around a dot, like the menu bar's while recording) whose ring breathes. No words, since+ /// recordings and screen sharing both see the window. A click turns it off.+ private var capturableBadge: some View {+ Button { model.setNotesCapturable(false) } label: {+ TimelineView(.animation(minimumInterval: 1 / 15)) { ctx in+ let t = 0.5 + 0.5 * cos(phase(ctx.date, period: 2.4) * 2 * .pi)+ ZStack {+ Circle().stroke(Palette.accent, lineWidth: 1.5).frame(width: 13, height: 13)+ .opacity(0.35 + 0.65 * t)+ Circle().fill(Palette.accent).frame(width: 6, height: 6)+ }+ .frame(width: 22, height: 22)+ }+ .contentShape(Circle())+ }+ .buttonStyle(.plain)+ .help("录屏和共享屏幕都看得到纪要窗口,点一下关闭")+ .accessibilityLabel(Text("录屏可见"))+ }+private var searchField: some View {HStack(spacing: 6) {Image(systemName: "magnifyingglass").font(.system(size: 13)).foregroundStyle(Palette.tertiary)@@ -681,6 +709,7 @@ struct NotesWindowView: View {.font(.system(size: 12)).foregroundStyle(Palette.tertiary)}Spacer()+ if settings.notesCapturable { capturableBadge }iconButton("arrow.up.left.and.arrow.down.right", help: L("展开纪要")) { setWidth(460, 760) }}if live, let p = model.ending {diff --git a/Sources/LiveSubs/Settings.swift b/Sources/LiveSubs/Settings.swiftindex 55c6568..59151d8 100644--- a/Sources/LiveSubs/Settings.swift+++ b/Sources/LiveSubs/Settings.swift@@ -102,6 +102,12 @@ final class AppSettings: ObservableObject {didSet { save() }}+ /// Let screen recordings (and so screen sharing too: macOS has one switch for both) capture the+ /// notes window. Off by default; kept across launches like 始终置顶, so the window shows a badge.+ @Published var notesCapturable: Bool {+ didSet { save() }+ }+/// Record per-sentence timings (never text) and show the 诊断 tab. On by default in dev builds.@Published var diagnostics: Bool {didSet { save() }@@ -139,6 +145,7 @@ final class AppSettings: ObservableObject {silenceEnd = defaults.string(forKey: "silenceEnd") ?? "prompt"silenceMinutes = defaults.object(forKey: "silenceMinutes") as? Double ?? 10diagnostics = defaults.object(forKey: "diagnostics") as? Bool ?? DevBuild.isDev+ notesCapturable = defaults.bool(forKey: "notesCapturable")}private func save() {@@ -168,6 +175,7 @@ final class AppSettings: ObservableObject {defaults.set(silenceEnd, forKey: "silenceEnd")defaults.set(silenceMinutes, forKey: "silenceMinutes")defaults.set(diagnostics, forKey: "diagnostics")+ defaults.set(notesCapturable, forKey: "notesCapturable")}/// Target language. "Follow system" translates into my language, or into the next systemdiff --git a/Sources/LiveSubs/SettingsWindow.swift b/Sources/LiveSubs/SettingsWindow.swiftindex b91b418..cd8a7fd 100644--- a/Sources/LiveSubs/SettingsWindow.swift+++ b/Sources/LiveSubs/SettingsWindow.swift@@ -68,6 +68,8 @@ struct Segments: View {let options: [(id: String, title: String)]let value: Stringvar fill = false+ /// Darker on a grey card, where `Palette.fill` would vanish.+ var track = Palette.filllet onPick: (String) -> Voidvar body: some View {HStack(spacing: 2) {@@ -76,7 +78,7 @@ struct Segments: View {Button { onPick(o.id) } label: {Text(o.title).font(.system(size: 12, weight: on ? .semibold : .regular)).foregroundStyle(on ? Palette.ink : Palette.secondary).lineLimit(1)- .padding(.horizontal, 10).frame(maxWidth: fill ? .infinity : nil).frame(height: 26)+ .padding(.horizontal, fill ? 6 : 10).frame(maxWidth: fill ? .infinity : nil).frame(height: 26).background(RoundedRectangle(cornerRadius: 7).fill(on ? Color.white : .clear).shadow(color: .black.opacity(on ? 0.08 : 0), radius: 1.5, y: 1)).contentShape(Rectangle())@@ -86,11 +88,23 @@ struct Segments: View {}}.padding(3)- .background(RoundedRectangle(cornerRadius: 9).fill(Palette.fill))+ .background(RoundedRectangle(cornerRadius: 9).fill(track)).fixedSize(horizontal: !fill, vertical: false)}}+/// 字幕条: shown while someone talks, or always. Settings and the menu bar panel.+@MainActor func overlayAutoSegments(model: AppModel, fill: Bool = false, track: Color = Palette.fill) -> some View {+ Segments(options: [("auto", L("有人说话时")), ("always", L("始终显示"))],+ value: model.settings.overlayAuto ? "auto" : "always", fill: fill, track: track) { model.setOverlayAuto($0 == "auto") }+}++/// 字幕条: how long it waits after the last words before tucking away.+@MainActor func hideAfterSegments(settings: AppSettings, fill: Bool = false, track: Color = Palette.fill) -> some View {+ Segments(options: [2.0, 4, 8].map { (String(Int($0)), L("\(Int($0)) 秒")) },+ value: String(Int(settings.overlayHideAfter)), fill: fill, track: track) { settings.overlayHideAfter = Double($0) ?? 4 }+}+/// The 字幕 choices.let subtitleOptions: [(id: String, title: String)] = [("both", L("原文 + 译文")), ("translation", L("只看译文")), ("original", L("只看原文"))]@@ -119,10 +133,13 @@ struct PillMenu: View {struct SoftButton: View {let title: Stringvar dark = false+ /// White, for a button sitting on a grey card.+ var onGrey = falselet action: () -> Void- init(_ title: String, dark: Bool = false, action: @escaping () -> Void) {+ init(_ title: String, dark: Bool = false, onGrey: Bool = false, action: @escaping () -> Void) {self.title = titleself.dark = dark+ self.onGrey = onGreyself.action = action}var body: some View {@@ -130,7 +147,7 @@ struct SoftButton: View {Text(title).font(.system(size: 12, weight: .semibold)).foregroundStyle(dark ? Color.white : Palette.ink).padding(.horizontal, 12).frame(height: 28)- .background(RoundedRectangle(cornerRadius: 7).fill(dark ? Palette.ink : Color(white: 0.925)))+ .background(RoundedRectangle(cornerRadius: 7).fill(dark ? Palette.ink : onGrey ? Color.white : Color(white: 0.925))).contentShape(Rectangle())}.buttonStyle(.plain)@@ -246,7 +263,7 @@ let appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as// MARK: - Virtual microphone checklist-/// The one place the virtual mic is set up: onboarding step 3 and the settings window.+/// The one place the virtual mic is set up: onboarding step 4 and the settings window./// Not ready → a three-step checklist with one button that does the next step./// Ready → one line with a status dot and the sound test.struct MicSetupCard: View {@@ -613,34 +630,28 @@ struct SettingsView: View {VStack(alignment: .leading, spacing: 14) {SettingsCard {SettingsRow(title: L("听的时候显示"), detail: L("选择任意模式都会正常保存记录、生成纪要")) {- Picker("显示方式", selection: Binding(get: { settings.displayMode }, set: { model.setDisplayMode($0) })) {- Text("实时纪要").tag("notes")- Text("字幕条").tag("bar")- Text("不显示").tag("none")- }- .pickerStyle(.segmented).labelsHidden().frame(width: 210)+ Segments(options: [("notes", L("实时纪要")), ("bar", L("字幕条")), ("none", L("不显示"))],+ value: settings.displayMode) { model.setDisplayMode($0) }}SettingsRow(title: L("切换显示方式"), detail: model.toggleKeyTaken ? L("被其他应用占用了,点右边换一个") : L("实时纪要 → 字幕条 → 不显示"), divider: false) {ShortcutField(model: model, role: .toggle)}}+ Text("实时纪要").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.top, 4)+ SettingsCard {+ SettingsRow(title: L("共享屏幕时让对方看到"), detail: L("录屏也一样;关着时只有你看得到纪要窗口"), divider: false) {+ Toggle("共享屏幕时让对方看到", isOn: Binding(get: { settings.notesCapturable }, set: { model.setNotesCapturable($0) }))+ .toggleStyle(.switch).labelsHidden().tint(Palette.accent)+ }+ }Text("字幕条").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.top, 4)SettingsCard {SettingsRow(title: L("字幕条显示时机")) {- Picker("显示", selection: Binding(get: { settings.overlayAuto }, set: { model.setOverlayAuto($0) })) {- Text("有人说话时").tag(true)- Text("始终显示").tag(false)- }- .pickerStyle(.segmented).labelsHidden().frame(width: 140)+ overlayAutoSegments(model: model)}if settings.overlayAuto {SettingsRow(title: L("安静多久后收起")) {- Picker("收起", selection: $settings.overlayHideAfter) {- Text("2 秒").tag(2.0)- Text("4 秒").tag(4.0)- Text("8 秒").tag(8.0)- }- .pickerStyle(.segmented).labelsHidden().frame(width: 140)+ hideAfterSegments(settings: settings)}}SettingsRow(title: L("位置和大小"), detail: L("鼠标悬停可拖动位置,拖拽右下角可缩放大小"), divider: false) {diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swiftindex 4d3d98f..56606bf 100644--- a/Sources/LiveSubs/Views.swift+++ b/Sources/LiveSubs/Views.swift@@ -92,17 +92,14 @@ struct MenuPanelView: View {}}- private var displayTitle: some View {- Text("显示").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)+ @ViewBuilder private var holdKey: some View {+ Text("按住").foregroundStyle(Palette.secondary)+ KeyCap(settings.talkKey.display)}- private var displayPicker: some View {- Picker("显示", selection: Binding(get: { settings.displayMode }, set: { model.setDisplayMode($0) })) {- Text("实时纪要").tag("notes")- Text("字幕条").tag("bar")- Text("不显示").tag("none")- }- .pickerStyle(.segmented).labelsHidden()+ private var speakRoute: some View {+ Text("说\(settings.speakFromLang.name) → \(targetName(model.speak.targetCode))")+ .foregroundStyle(Palette.secondary).lineLimit(1).fixedSize()}var body: some View {@@ -124,8 +121,10 @@ struct MenuPanelView: View {}HStack(spacing: 6) {Circle().fill(model.running ? Palette.accent : Color.gray.opacity(0.5)).frame(width: 7, height: 7)+ // Two lines: "English (detecting…) → 简体中文" doesn't fit one beside the switch.Text(model.running ? model.summary : model.autoEnded ? L("会议已自动结束") : L("已暂停"))- .font(.system(size: 12)).foregroundStyle(Palette.secondary).lineLimit(1)+ .font(.system(size: 12)).foregroundStyle(Palette.secondary).lineLimit(2)+ .fixedSize(horizontal: false, vertical: true)}}Spacer()@@ -146,7 +145,7 @@ struct MenuPanelView: View {options: targetOptions) {model.targetSelection = $0}- ChoiceRow(label: L("字幕"), value: subtitleOptions.first { $0.id == model.subtitles }?.title ?? L("原文 + 译文"),+ ChoiceRow(label: L("内容"), value: subtitleOptions.first { $0.id == model.subtitles }?.title ?? L("原文 + 译文"),badge: model.meetingSubtitles != nil ? L("仅本场") : nil, options: subtitleOptions) {model.setSubtitles($0)}@@ -157,11 +156,10 @@ struct MenuPanelView: View {HStack(alignment: .top, spacing: 12) {VStack(alignment: .leading, spacing: 4) {Text("同声传译").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)- HStack(spacing: 5) {- Text("按住").foregroundStyle(Palette.secondary)- KeyCap(settings.talkKey.display)- Text("说\(settings.speakFromLang.name) → \(targetName(model.speak.targetCode))")- .foregroundStyle(Palette.secondary).lineLimit(1)+ // The languages drop to their own line when the row is too narrow (English, "Right ⌥").+ ViewThatFits(in: .horizontal) {+ HStack(spacing: 5) { holdKey; speakRoute }+ VStack(alignment: .leading, spacing: 4) { HStack(spacing: 5) { holdKey }; speakRoute }}.font(.system(size: 12))// Green only when nothing needs fixing; the warning row below covers the rest.@@ -220,58 +218,23 @@ struct MenuPanelView: View {Divider()- VStack(spacing: 10) {- // English labels are wider than the 210 pt the Chinese ones fit in: the picker gets its own row.- if uiIsChinese {- HStack {- displayTitle- Spacer()- displayPicker.frame(width: 210)- }- } else {- VStack(alignment: .leading, spacing: 8) {- displayTitle- displayPicker- }- .frame(maxWidth: .infinity, alignment: .leading)- }- if settings.displayMode == "notes" {- HStack {- Text(model.ling.hasKey ? L("纪要、文字记录和字幕都在一个窗口里") : L("填入 API key 后可生成纪要;文字记录照常保存"))- .font(.system(size: 12)).foregroundStyle(Palette.secondary)- Spacer()- SoftButton(L("打开")) { model.openNotesWindow() }- }- }- if settings.displayMode == "bar" {- HStack {- Text("字幕条").font(.system(size: 12)).foregroundStyle(Palette.secondary)- Spacer()- Picker("字幕条", selection: Binding(get: { settings.overlayAuto }, set: { model.setOverlayAuto($0) })) {- Text("有人说话时显示").tag(true)- Text("始终显示").tag(false)- }- .pickerStyle(.segmented).labelsHidden().frame(width: 170)+ VStack(alignment: .leading, spacing: 10) {+ HStack {+ Text("显示方式").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)+ Spacer()+ HStack(spacing: 5) {+ KeyCap(settings.toggleKey.display)+ Text("轮换").foregroundStyle(Palette.tertiary)}+ .font(.system(size: 11))+ .help(L("切换显示方式"))}- if settings.displayMode == "bar" && settings.overlayAuto {- HStack {- Text("安静多久后收起").font(.system(size: 12)).foregroundStyle(Palette.secondary)- Spacer()- Picker("收起前等待", selection: $settings.overlayHideAfter) {- Text("2 秒").tag(2.0)- Text("4 秒").tag(4.0)- Text("8 秒").tag(8.0)- }- .pickerStyle(.segmented).labelsHidden().frame(width: 170)+ HStack(spacing: 8) {+ ForEach(DisplayTile.modes, id: \.self) { mode in+ DisplayTile(mode: mode, selected: settings.displayMode == mode) { model.setDisplayMode(mode) }}}- HStack(spacing: 5) {- Text("切换显示方式").foregroundStyle(Palette.secondary)- Spacer()- KeyCap(settings.toggleKey.display)- }- .font(.system(size: 12))+ displayCard}UpdateBanner(updates: model.updates, model: model)@@ -294,6 +257,76 @@ struct MenuPanelView: View {}extension MenuPanelView {+ /// The settings of the chosen display mode only, so switching modes swaps one card+ /// instead of reshuffling the section.+ @ViewBuilder var displayCard: some View {+ VStack(alignment: .leading, spacing: 8) {+ switch settings.displayMode {+ case "bar":+ cardRow(L("什么时候出现")) {+ overlayAutoSegments(model: model, fill: uiIsChinese, track: Palette.line).frame(width: uiIsChinese ? segmentWidth : nil)+ }+ if settings.overlayAuto {+ cardRow(L("安静多久后收起")) {+ hideAfterSegments(settings: settings, fill: uiIsChinese, track: Palette.line).frame(width: uiIsChinese ? segmentWidth : nil)+ }+ }+ case "none":+ Text("屏幕上不出字幕,文字记录照常保存")+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ default:+ HStack(spacing: 10) {+ VStack(alignment: .leading, spacing: 2) {+ Text(model.notesShown ? L("纪要窗口已打开") : L("纪要窗口已收起"))+ .font(.system(size: 12)).foregroundStyle(Palette.ink)+ if !model.ling.hasKey {+ Text("填入 API key 后可生成纪要;文字记录照常保存")+ .font(.system(size: 11)).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ Spacer(minLength: 4)+ SoftButton(model.notesShown ? L("收起") : L("打开"), dark: !model.notesShown, onGrey: true) {+ model.notesShown ? model.hideNotesWindow() : model.openNotesWindow()+ }+ }+ Divider()+ // Tinted while on: sharing the screen shows the notes too.+ HStack(spacing: 10) {+ VStack(alignment: .leading, spacing: 2) {+ Text("共享屏幕时让对方看到").font(.system(size: 12)).foregroundStyle(Palette.ink)+ if settings.notesCapturable {+ Text("对方现在能看到纪要窗口").font(.system(size: 11)).foregroundStyle(Palette.accentInk)+ }+ }+ Spacer(minLength: 4)+ Toggle("共享屏幕时让对方看到", isOn: Binding(get: { settings.notesCapturable }, set: { model.setNotesCapturable($0) }))+ .toggleStyle(.switch).controlSize(.mini).labelsHidden().tint(Palette.accent)+ }+ .padding(.horizontal, 6).padding(.vertical, 4)+ .background(RoundedRectangle(cornerRadius: 8).fill(settings.notesCapturable ? Palette.accentPale : .clear))+ .padding(.horizontal, -6)+ }+ }+ .padding(12)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 11).fill(Palette.ground))+ }++ /// Both 字幕条 choices share one width so their right edges line up; English sizes to fit and may stack.+ private var segmentWidth: CGFloat { 160 }++ /// A label and its control on one line, or stacked when the English runs too wide.+ private func cardRow<C: View>(_ title: String, @ViewBuilder control: () -> C) -> some View {+ let label = Text(title).font(.system(size: 12)).foregroundStyle(Palette.ink)+ let c = control()+ return ViewThatFits(in: .horizontal) {+ HStack(spacing: 0) { label; Spacer(minLength: 8); c }+ VStack(alignment: .leading, spacing: 6) { label; c }+ }+ }+/// ⋯ next to the 同声传译 switch: its settings, 试一句, and putting the system mic back by hand.var speakMenu: some View {Menu {@@ -332,6 +365,68 @@ extension MenuPanelView {}}+/// One of 实时纪要 / 字幕条 / 不显示 in the menu bar panel: a small picture of what shows on screen.+struct DisplayTile: View {+ static let modes = ["notes", "bar", "none"]+ let mode: String+ let selected: Bool+ let action: () -> Void++ private var title: String {+ switch mode {+ case "bar": return L("字幕条")+ case "none": return L("不显示")+ default: return L("实时纪要")+ }+ }++ var body: some View {+ Button(action: action) {+ VStack(spacing: 6) {+ glyph.frame(height: 26).opacity(selected ? 1 : 0.7)+ Text(title)+ .font(.system(size: 12, weight: selected ? .semibold : .regular))+ .foregroundStyle(selected ? Palette.ink : Palette.secondary)+ .lineLimit(1).minimumScaleFactor(0.8)+ }+ .padding(.top, 10).padding(.bottom, 8).padding(.horizontal, 4)+ .frame(maxWidth: .infinity)+ .background(RoundedRectangle(cornerRadius: 11).fill(selected ? Color.white : Palette.ground))+ .overlay(RoundedRectangle(cornerRadius: 11).stroke(selected ? Palette.ink : .clear, lineWidth: 2))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .accessibilityAddTraits(selected ? .isSelected : [])+ }++ private let frameLine = Color(red: 0.79, green: 0.80, blue: 0.83)++ @ViewBuilder private var glyph: some View {+ switch mode {+ case "bar":+ RoundedRectangle(cornerRadius: 4).fill(Color.white)+ .overlay(RoundedRectangle(cornerRadius: 4).stroke(frameLine, lineWidth: 1))+ .overlay(alignment: .bottom) {+ RoundedRectangle(cornerRadius: 2).fill(Palette.ink).frame(width: 26, height: 6).padding(.bottom, 3)+ }+ .frame(width: 38, height: 26)+ case "none":+ RoundedRectangle(cornerRadius: 4).strokeBorder(Palette.tertiary.opacity(0.6), style: StrokeStyle(lineWidth: 1, dash: [3, 2]))+ .frame(width: 38, height: 26)+ default:+ VStack(alignment: .leading, spacing: 3) {+ Capsule().fill(Palette.ink).frame(width: 18, height: 3)+ Capsule().fill(frameLine).frame(width: 24, height: 3)+ Capsule().fill(frameLine).frame(width: 20, height: 3)+ }+ .padding(5)+ .frame(width: 34, height: 26, alignment: .topLeading)+ .background(RoundedRectangle(cornerRadius: 4).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 4).stroke(frameLine, lineWidth: 1))+ }+ }+}+struct KeyCap: View {let text: Stringinit(_ text: String) { self.text = text }diff --git a/site/changelog.json b/site/changelog.jsonindex 358b3b3..bbe699e 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -6,11 +6,21 @@"summary": "打开同声传译时,系统麦克风自动换成虚拟麦克风,Chrome 里的会议网页不用再手动设置;关掉或退出时自动换回。","image": null,"items": [+ {+ "kind": "changed",+ "title": "菜单栏面板的显示方式更好懂。",+ "text": "显示方式换成三个带小图的格子:实时纪要、字幕条、不显示。下面的卡片只放选中那种的设置:实时纪要显示窗口开着还是收起,配一个打开或收起按钮(收起不会弹出会议记录),以及“共享屏幕时让对方看到”(原来叫录屏时显示纪要窗口);字幕条是什么时候出现、安静多久后收起;不显示则说明文字记录照常保存。⌃⌥S 快捷键挪到标题旁边,上面原文 + 译文那一行改叫“内容”,字幕不再一词两用。原来系统蓝色的分段选择(面板和设置里字幕条的时机、设置里的显示方式、会议记录窗口的双语 / 原文 / 译文)统一换成灰底白滑块,面板里字幕条的两个选择也对齐成同样宽。"+ },{"kind": "new","title": "Chrome 里开会也不用设置麦克风了。","text": "打开同声传译时,知了把系统麦克风换成 BlackHole 2ch,关掉同声传译或退出知了时换回原来的麦克风,用“默认”麦克风的会议网页和软件直接就能听到译文。知了自己仍然用你的真实麦克风听你说话,也可以在设置里固定一个。上次没来得及换回(比如知了意外退出),或者说话时插上 AirPods 把系统麦克风换走了,菜单栏面板会提示,点一下还原或换回;面板上同声传译旁边的 ⋯ 里也能随时还原。不想自动切换的话,可以在设置的同声传译里关掉。"},+ {+ "kind": "new",+ "title": "录屏时也能拍到纪要窗口。",+ "text": "做演示、录教程时,可以让录屏拍到实时纪要窗口。默认关闭,在设置的显示、菜单栏面板,或者顶部菜单的显示 › 共享屏幕时对方可见里打开。macOS 的录屏和共享屏幕是同一个开关,打开后共享屏幕对方也能看到纪要,所以纪要窗口会一直显示一个呼吸的录制标记,点一下就关掉。"+ },{"kind": "changed","title": "安装窗口讲清楚首次打开的提示。",