知了 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: make the meeting records window read like a document
wquguru26342f32a2c3
diff --git a/AGENTS.md b/AGENTS.mdindex 801c3ee..fec8f73 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,7 +49,7 @@ python3 scripts/site.py && python3 -m http.server -d build/site # website prevDiagnostics (`Diagnostics.swift`, design: claude.ai/artifact/GHGzgN1sCodGfa17ZXLCa7): a "诊断" switch at the bottom left of the settings sidebar, beside the version (`diagnostics`, off by default; on in dev builds); switching it on adds a "诊断" tab below the others. It records only timings and counts, never transcript text: per heard sentence last new words → final transcript ("识别定稿") and final → translation, with Ling queue time, the provider that answered and why earlier ones fell through (`TranslateTrace`); per speak-back press release → transcript → translation → voice done; every Ling request (priority, queue, duration, outcome, tokens). Lines go to `metrics.jsonl` in the meeting folder (`type` = `sentence` / `ling`). The tab shows p50/p95, the provider split, fallback reasons, Ling rate and the last sentences as bars, and copies a plain-text report. It is separate from `debug`: the switch never enables transcript logging or the debug notification. Not done yet: the latency line under the subtitle bar and the health line in the panel.-Debug control: dev builds always accept commands on the distributed notification `com.wquguru.cicada.debug` (release builds only with `defaults write com.wquguru.cicada debug -bool true`, which also logs transcript text). Send them with `tools/lsctl` (`start`, `stop`, `open`, `panel`, `onboarding:<step>`, `samplePlay`, `speakFile:<audio>`, `settings:<overlay|speak|records|ai|diagnostics>`, `diagnostics:<on|off>`, `diagReport`, `micTest`, `micNext`, `talkKey:<right|keyCode:mods>`, `toggleKey:<keyCode:mods>`, `shortcuts`, `aiKeyFile:<path>` (key from a 0600 file, never through the log), `aiCheck`, `aiRemove`, `aiState`, `lingSimulate:<429|hijack|timeout|off>`, `voice:<lang>[=<id>]`, `voicePreview:<lang>=<id>`, `voiceCloneFile:<wav>`, `display:<notes|bar|none>`, `notesWindow[:x,y,w,h]`, `notesFrame`, `notesNow`, `notesState`, `notesShow:<id>`, `notesReplay:<id>`, `notesRender:<png>`, `notesCapturable`, `place:x,y,w,font`, `frame`, `overlayState`, `export:<dir>` …).+Debug control: dev builds always accept commands on the distributed notification `com.wquguru.cicada.debug` (release builds only with `defaults write com.wquguru.cicada debug -bool true`, which also logs transcript text). Send them with `tools/lsctl` (`start`, `stop`, `open`, `panel`, `onboarding:<step>`, `samplePlay`, `speakFile:<audio>`, `settings:<overlay|speak|records|ai|diagnostics>`, `diagnostics:<on|off>`, `diagReport`, `micTest`, `micNext`, `talkKey:<right|keyCode:mods>`, `toggleKey:<keyCode:mods>`, `shortcuts`, `aiKeyFile:<path>` (key from a 0600 file, never through the log), `aiCheck`, `aiRemove`, `aiState`, `lingSimulate:<429|hijack|timeout|off>`, `voice:<lang>[=<id>]`, `voicePreview:<lang>=<id>`, `voiceCloneFile:<wav>`, `display:<notes|bar|none>`, `notesWindow[:x,y,w,h]`, `notesFrame`, `notesNow`, `notesState`, `notesShow:<id>`, `notesReplay:<id>`, `notesRender:<png>`, `notesCapturable`, `mainShow:<id>[,transcript]`, `mainRender:<png>` (the main window, plus the shown meeting's whole notes page as `<png>.notes.png`), `place:x,y,w,font`, `frame`, `overlayState`, `export:<dir>` …).Release: `scripts/release.sh <x.y.z>` (clean `main`, a `## x.y.z — <today>` section in `CHANGELOG.md`) bumps `Resources/Info.plist`, commits, tags `v<x.y.z>` and pushes; `.github/workflows/release.yml` (runner `macos-26`) builds the tag, checks it matches Info.plist and publishes the DMG, zip and checksums with notes from `scripts/release_notes.sh`. `build.yml` runs on pull requests and on demand only: macOS minutes are expensive for a private repo.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a59bfc5..bcdffc4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,7 @@ the release workflow publishes it as the release notes.## Unreleased- Changed: with a Ling key, what you say while holding the talk key is heard and translated in one step by Ming's audio model, which gets names right far more often than the on-device recognizer (江充 instead of 将冲) and needs one request instead of two. The translation is ready about 2 s after you let go (about 1 s before); if Ming is slow, busy or replies oddly, it falls back to on-device recognition and the usual translation. 诊断 shows which one answered.+- Changed: the meeting records window reads like a document: meetings grouped by 今天 / 昨天 / 本周 / month, a card at the bottom showing whether it's listening (with the switch and settings), and each meeting opens as a page: date, a large editable title, its length, sentence count and languages, the summary as the opening paragraph, then topics with their times, conclusions and to-dos. ⌘F jumps to search.- Changed: Live Subs is now 知了 (Cicada in English): new name, new logo, new app id (`com.wquguru.cicada`). macOS treats it as a new app, so it asks again for system audio, microphone and Input Monitoring, and settings and the AI key start fresh; meeting records are kept. Delete the old Live Subs from Applications.- New: choose the voice the room hears for each language (Settings › 同声传译 › 对方听到的声音): natural Ming voices, two women and two men where available (Emma, George, Charlotte in English; 小雅, 小棠, 小锋, 卓然 in Chinese; Japanese, Korean, German, French and Spanish too), the Mac's own voices, each with a play button. Or record 15 s of your own voice and the room hears you, in any language (with your accent, about 1.5 s later than the built-in voices). The recording stays on your Mac and is sent to Ling only with what you say.- Changed: clearer wording throughout the Chinese interface.diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex 46693c4..658b13b 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -32,6 +32,8 @@ final class AppModel: ObservableObject {@Published var liveSource = ""@Published var liveTranslation = ""@Published var onboardingStep = 1+ /// Debug: which meeting and tab the main window shows ("<id>" or "<id>,transcript").+ @Published var mainShow: String?/// Hold right ⌥ is chosen but "输入监控" isn't allowed yet.@Published var talkNeedsPermission = false@Published var toggleKeyTaken = false@@ -639,6 +641,21 @@ final class AppModel: ObservableObject {let png = rep.representation(using: .png, properties: [:]) {try? png.write(to: URL(fileURLWithPath: arg))}+ case "mainShow": mainShow = arg+ case "mainRender":+ // The main window as drawn, for checking it without Screen Recording permission.+ guard let view = NSApp.windows.first(where: { $0.contentView is NSHostingView<MainWindowView> })?.contentView,+ let rep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else { break }+ view.cacheDisplay(in: view.bounds, to: rep)+ try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg))+ // And the shown meeting's whole notes page beside it, for what is below the fold.+ if let id = mainShow?.split(separator: ",").first.map(String.init), let n = store.session(id)?.notes {+ let r = ImageRenderer(content: NotesContentView(notes: n, document: true).padding(32).frame(width: 744).background(Color.white))+ r.scale = 2+ if let img = r.nsImage, let tiff = img.tiffRepresentation, let full = NSBitmapImageRep(data: tiff) {+ try? full.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg + ".notes.png"))+ }+ }case "notesState": debugLog("notes state=\(notes.state) topics=\(notes.notes.topics.count) covered=\(notes.notes.covered) glossary=\(notes.glossary.count) timedPoints=\(notes.notes.topics.reduce(0) { $0 + ($1.pointTimes?.compactMap { $0 }.count ?? 0) })/\(notes.notes.topics.reduce(0) { $0 + $1.points.count }) fresh=\(notes.fresh.count)")case "lingSimulate":ling.simulate = ["429": .rateLimited, "hijack": .hijacked, "timeout": .timeout][arg]diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swiftindex 8c2d5a4..26a2a16 100644--- a/Sources/LiveSubs/NotesViews.swift+++ b/Sources/LiveSubs/NotesViews.swift@@ -12,6 +12,9 @@ struct NotesContentView: View {var fresh: Set<String> = []/// The meeting is still going: the last topic is "正在讲".var live = false+ /// The main window's page: the summary as a lead paragraph, quiet section labels, rules+ /// between rows instead of cards.+ var document = falsevar updating = falsevar summaryJustChanged = false/// The time of the last line the notes cover ("到 03:52").@@ -21,8 +24,11 @@ struct NotesContentView: View {var onJump: (Double) -> Void = { _ in }var body: some View {- VStack(alignment: .leading, spacing: 18) {- if !notes.summary.isEmpty {+ VStack(alignment: .leading, spacing: document ? 32 : 18) {+ if document && !notes.summary.isEmpty {+ Text(notes.summary).font(.system(size: 17)).lineSpacing(7).foregroundStyle(Palette.ink.opacity(0.9))+ .textSelection(.enabled).fixedSize(horizontal: false, vertical: true)+ } else if !notes.summary.isEmpty {VStack(alignment: .leading, spacing: 8) {HStack(spacing: 8) {Text("总结").font(.system(size: 15, weight: .bold))@@ -40,49 +46,33 @@ struct NotesContentView: View {}if !notes.topics.isEmpty {- VStack(alignment: .leading, spacing: 14) {- SectionTitle("议题")+ VStack(alignment: .leading, spacing: document ? 0 : 14) {+ title("议题")ForEach(Array(notes.topics.enumerated()), id: \.element.id) { i, topic in+ if document { Divider() }TopicView(topic: topic,end: i + 1 < notes.topics.count ? notes.topics[i + 1].start : (live ? nil : endedAt),current: live && i == notes.topics.count - 1,updating: updating && i == notes.topics.count - 1, fresh: fresh, onJump: onJump)+ .padding(.vertical, document ? 14 : 0)}}}if !notes.conclusions.isEmpty || !notes.todos.isEmpty {VStack(alignment: .leading, spacing: 10) {- SectionTitle(notes.todos.isEmpty ? "结论" : "结论和待办")- FramedList {- ForEach(Array((notes.conclusions + notes.todos).enumerated()), id: \.offset) { i, item in- let todo = i >= notes.conclusions.count- HStack(alignment: .firstTextBaseline, spacing: 10) {- if todo {- Image(systemName: "circle").font(.system(size: 11)).foregroundStyle(Palette.tertiary)- }- Text(item.text + (item.owner.map { "(\($0))" } ?? ""))- .font(.system(size: 14)).lineSpacing(2)- .foregroundStyle(item.support == 0 ? Palette.tertiary : Palette.ink)- .frame(maxWidth: .infinity, alignment: .leading)- if item.support == 0 {- Tag("依据较少")- } else if let t = item.t {- TimeLink(text: "\(NotesEngine.clock(t)) · \(item.support) 句", t: t, onJump: onJump)- } else {- Tag("依据 \(item.support) 句")- }- }- .padding(.horizontal, 16).padding(.vertical, 11)- if i < notes.conclusions.count + notes.todos.count - 1 { Divider() }- }+ title(notes.todos.isEmpty ? "结论" : "结论和待办")+ if document {+ VStack(alignment: .leading, spacing: 0) { items }+ } else {+ FramedList { items }}}}if !notes.terms.isEmpty {VStack(alignment: .leading, spacing: 10) {- SectionTitle("人名和术语")+ title("人名和术语")FlowLayout(spacing: 6) {ForEach(notes.terms) { t in(Text(t.name).bold() + Text(t.note.isEmpty ? "" : " \(t.note)")@@ -97,6 +87,46 @@ struct NotesContentView: View {}}}++ @ViewBuilder+ private func title(_ text: String) -> some View {+ if document {+ Text(text).font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.bottom, 2)+ } else {+ SectionTitle(text)+ }+ }++ @ViewBuilder+ private var items: some View {+ let all = notes.conclusions + notes.todos+ ForEach(Array(all.enumerated()), id: \.offset) { i, item in+ let todo = i >= notes.conclusions.count+ if document && i > 0 { Divider() }+ HStack(alignment: .firstTextBaseline, spacing: 10) {+ if todo {+ Image(systemName: "circle").font(.system(size: document ? 13 : 11)).foregroundStyle(Palette.tertiary)+ } else if document {+ Circle().fill(Palette.ink.opacity(0.55)).frame(width: 5, height: 5)+ .alignmentGuide(.firstTextBaseline) { $0[.bottom] + 4 }+ .frame(width: 13)+ }+ Text(item.text + (item.owner.map { "(\($0))" } ?? ""))+ .font(.system(size: 14)).lineSpacing(2)+ .foregroundStyle(item.support == 0 ? Palette.tertiary : Palette.ink)+ .frame(maxWidth: .infinity, alignment: .leading)+ if item.support == 0 {+ Tag("依据较少")+ } else if let t = item.t {+ TimeLink(text: "\(NotesEngine.clock(t)) · \(item.support) 句", t: t, onJump: onJump)+ } else {+ Tag("依据 \(item.support) 句")+ }+ }+ .padding(.horizontal, document ? 0 : 16).padding(.vertical, 11)+ if !document && i < all.count - 1 { Divider() }+ }+ }}private struct TopicView: View {diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swiftindex cf44377..cbbdefc 100644--- a/Sources/LiveSubs/Views.swift+++ b/Sources/LiveSubs/Views.swift@@ -252,6 +252,7 @@ struct MainWindowView: View {@State private var titleDraft = ""@State private var tab = "notes"@State private var jumpTo: Double?+ @FocusState private var searchFocused: Boolprivate var filtered: [Session] {guard !query.isEmpty else { return store.sessions }@@ -266,56 +267,83 @@ struct MainWindowView: View {var body: some View {HStack(spacing: 0) {sidebar- .frame(width: 270)+ .frame(width: 264)detail.frame(maxWidth: .infinity, maxHeight: .infinity)- .background(RoundedRectangle(cornerRadius: 16).fill(Color.white))- .overlay(RoundedRectangle(cornerRadius: 16).stroke(Palette.line, lineWidth: 1))- .padding(.trailing, 14).padding(.bottom, 14).padding(.top, 38)+ .background(RoundedRectangle(cornerRadius: 14).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 14).stroke(Palette.line, lineWidth: 1))+ .padding(.trailing, 10).padding(.vertical, 10)}.background(Palette.ground)+ .background(Button("") { searchFocused = true }.keyboardShortcut("f").opacity(0))+ .onChange(of: model.mainShow) { _, show in+ guard let parts = show?.split(separator: ",").map(String.init), let id = parts.first else { return }+ selection = id+ tab = parts.count > 1 ? parts[1] : "notes"+ if parts.count > 2 { view = parts[2] }+ }}// MARK: Sidebarprivate var sidebar: some View {- VStack(alignment: .leading, spacing: 10) {- HStack(spacing: 10) {- LogoTile(size: 28)- Text("会议记录").font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.ink)- Spacer()- Button { model.openSettings() } label: {- Image(systemName: "slider.horizontal.3").font(.system(size: 14)).frame(width: 32, height: 32)- }- .buttonStyle(.plain).foregroundStyle(Palette.secondary).help("设置")- }- .padding(.top, 38)-- HStack(spacing: 6) {+ VStack(alignment: .leading, spacing: 14) {+ HStack(spacing: 8) {Image(systemName: "magnifyingglass").foregroundStyle(Palette.tertiary)- TextField("搜索会议内容", text: $query).textFieldStyle(.plain)+ TextField("搜索标题和原话", text: $query).textFieldStyle(.plain).focused($searchFocused)+ if query.isEmpty {+ Text("⌘F").font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ } else {+ Button { query = "" } label: { Image(systemName: "xmark.circle.fill") }+ .buttonStyle(.plain).foregroundStyle(Palette.tertiary).help("清除")+ }}.font(.system(size: 13)).padding(.horizontal, 10).frame(height: 34)- .background(RoundedRectangle(cornerRadius: 9).fill(Color.white))- .overlay(RoundedRectangle(cornerRadius: 9).stroke(Palette.line, lineWidth: 1))+ .background(RoundedRectangle(cornerRadius: 10).fill(Color(red: 0.914, green: 0.922, blue: 0.937)))+ .padding(.top, 40)ScrollView {- LazyVStack(spacing: 4) {- ForEach(filtered) { s in- sessionRow(s)+ LazyVStack(alignment: .leading, spacing: 2) {+ ForEach(groups, id: \.title) { g in+ Text(g.title).font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.tertiary)+ .padding(.horizontal, 10).padding(.top, g.title == groups.first?.title ? 0 : 12).padding(.bottom, 4)+ ForEach(g.sessions) { sessionRow($0) }+ }+ if store.sessions.isEmpty {+ Text("开启字幕后,每场会议都会自动保存在这里。")+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ .padding(.horizontal, 10)+ } else if filtered.isEmpty {+ Text("没有找到“\(query)”").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ .padding(.horizontal, 10)}}}- if store.sessions.isEmpty {- Text("开启字幕后,每场会议都会自动保存在这里。")- .font(.system(size: 12)).foregroundStyle(Palette.secondary)- .padding(.top, 8)- Spacer()- }+ .scrollIndicators(.never)++ statusCard+ }+ .padding(.leading, 14).padding(.trailing, 12).padding(.bottom, 14)+ }++ /// 今天 / 昨天 / 本周 / then one group per month, newest first.+ private var groups: [(title: String, sessions: [Session])] {+ let cal = Calendar.current+ let f = DateFormatter()+ f.locale = Locale(identifier: "zh_CN")+ var out: [(title: String, sessions: [Session])] = []+ for s in filtered {+ let d = s.startedAt+ let title: String+ if cal.isDateInToday(d) { title = "今天" }+ else if cal.isDateInYesterday(d) { title = "昨天" }+ else if cal.isDate(d, equalTo: Date(), toGranularity: .weekOfYear) { title = "本周" }+ else if cal.isDate(d, equalTo: Date(), toGranularity: .year) { f.dateFormat = "M月"; title = f.string(from: d) }+ else { f.dateFormat = "yyyy年M月"; title = f.string(from: d) }+ if out.last?.title == title { out[out.count - 1].sessions.append(s) } else { out.append((title, [s])) }}- .padding(.horizontal, 14)- .padding(.bottom, 14)+ return out}private func sessionRow(_ s: Session) -> some View {@@ -325,17 +353,20 @@ struct MainWindowView: View {selection = s.idtitleDraft = s.title} label: {- VStack(alignment: .leading, spacing: 4) {- HStack(spacing: 6) {+ VStack(alignment: .leading, spacing: 3) {+ HStack(spacing: 7) {if live { Circle().fill(Palette.accent).frame(width: 7, height: 7) }Text(s.title).font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink).lineLimit(1)}- Text(meta(s, live: live)).font(.system(size: 11)).foregroundStyle(Palette.secondary).lineLimit(1)+ Text(meta(s, live: live)).font(.system(size: 11))+ .foregroundStyle(live ? Palette.accentInk : Palette.secondary).lineLimit(1)+ .padding(.leading, live ? 14 : 0)}.frame(maxWidth: .infinity, alignment: .leading)- .padding(.horizontal, 12).padding(.vertical, 10)- .background(RoundedRectangle(cornerRadius: 10).fill(selected ? Color.white : Color.clear))- .overlay(RoundedRectangle(cornerRadius: 10).stroke(selected ? Palette.line : Color.clear, lineWidth: 1))+ .padding(.horizontal, 10).padding(.vertical, 9)+ .background(RoundedRectangle(cornerRadius: 9).fill(selected ? Color.white : Color.clear)+ .shadow(color: selected ? Palette.ink.opacity(0.06) : .clear, radius: 1, y: 1))+ .overlay(RoundedRectangle(cornerRadius: 9).stroke(selected ? Palette.line : Color.clear, lineWidth: 1)).contentShape(Rectangle())}.buttonStyle(.plain)@@ -348,10 +379,59 @@ struct MainWindowView: View {private func meta(_ s: Session, live: Bool) -> String {let f = DateFormatter()f.locale = Locale(identifier: "zh_CN")- f.dateFormat = Calendar.current.isDateInToday(s.startedAt) ? "今天 HH:mm" : "M月d日 HH:mm"+ let cal = Calendar.current+ f.dateFormat = cal.isDateInToday(s.startedAt) || cal.isDateInYesterday(s.startedAt) ? "HH:mm"+ : cal.isDate(s.startedAt, equalTo: Date(), toGranularity: .weekOfYear) ? "EEE HH:mm" : "M月d日 HH:mm"+ if live { return "正在记录 · \(f.string(from: s.startedAt)) 起 · \(s.lines.count) 句" }+ return [f.string(from: s.startedAt), Self.length(s), Self.pair(s, short: true)].compactMap { $0 }.joined(separator: " · ")+ }++ static func length(_ s: Session) -> String {let mins = Int(s.duration / 60)- let length = mins < 1 ? "不到 1 分钟" : "\(mins) 分钟"- return live ? "进行中 · \(s.lines.count) 句" : "\(f.string(from: s.startedAt)) · \(length) · \(s.lines.count) 句"+ if mins < 1 { return "不到 1 分钟" }+ return mins < 60 ? "\(mins) 分钟" : mins % 60 == 0 ? "\(mins / 60) 小时" : "\(mins / 60) 小时 \(mins % 60) 分"+ }++ /// "英 → 中" (short) or "英语 → 中文", from the most common pair among the lines.+ static func pair(_ s: Session, short: Bool) -> String? {+ let pairs = Dictionary(grouping: s.lines.filter { $0.speaker != "me" }, by: { "\(lang($0.srcLang))|\(lang($0.dstLang))" })+ guard let top = pairs.max(by: { $0.value.count < $1.value.count })?.key else { return nil }+ let p = top.split(separator: "|").map(String.init)+ guard p.count == 2, p[0] != p[1] else { return nil }+ func name(_ c: String) -> String {+ let names = ["en": "英语", "ja": "日语", "zh-CN": "中文", "zh-TW": "繁中", "ko": "韩语",+ "es": "西语", "fr": "法语", "de": "德语", "pt": "葡语"]+ guard let n = names[c] else { return c.uppercased() }+ return short ? String(n.prefix(1)) : n+ }+ return "\(name(p[0])) → \(name(p[1]))"+ }++ private static func lang(_ code: String) -> String {+ let base = String(code.split(whereSeparator: { $0 == "-" || $0 == "_" }).first ?? "")+ return base == "zh" ? (code.contains("Hant") || code.hasSuffix("TW") || code.hasSuffix("HK") ? "zh-TW" : "zh-CN") : base+ }++ /// What is listening right now, with the switch and settings at hand.+ private var statusCard: some View {+ HStack(spacing: 10) {+ LogoTile(size: 28).opacity(model.running ? 1 : 0.5)+ VStack(alignment: .leading, spacing: 1) {+ Text(model.running ? "正在听" : "已暂停").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)+ Text(model.running ? model.summary : "打开开关开始听").font(.system(size: 11)).foregroundStyle(Palette.secondary)+ .lineLimit(1)+ }+ Spacer(minLength: 4)+ Toggle("字幕", isOn: Binding(get: { model.running }, set: { model.setRunning($0) }))+ .toggleStyle(.switch).labelsHidden().controlSize(.mini).tint(Palette.ink)+ Button { model.openSettings() } label: {+ Image(systemName: "slider.horizontal.3").font(.system(size: 13)).frame(width: 28, height: 28).contentShape(Rectangle())+ }+ .buttonStyle(.plain).foregroundStyle(Palette.secondary).help("设置")+ }+ .padding(.horizontal, 10).padding(.vertical, 9)+ .background(RoundedRectangle(cornerRadius: 12).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 12).stroke(Palette.line, lineWidth: 1))}// MARK: Detail@@ -359,90 +439,29 @@ struct MainWindowView: View {@ViewBuilderprivate var detail: some View {if let s = current {- VStack(alignment: .leading, spacing: 0) {- HStack(alignment: .center, spacing: 14) {- VStack(alignment: .leading, spacing: 6) {- TextField("标题", text: Binding(- get: { titleDraft.isEmpty ? s.title : titleDraft },- set: { titleDraft = $0 }- ))- .textFieldStyle(.plain)- .font(.system(size: 20, weight: .bold))- .onSubmit { store.rename(s.id, to: titleDraft) }- Text(TranscriptExport.header(s) + " · \(s.lines.count) 句")- .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ VStack(spacing: 0) {+ toolbar(s)+ Divider()+ if s.lines.isEmpty {+ ScrollView {+ header(s).frame(maxWidth: 680).padding(.horizontal, 32).padding(.vertical, 36)+ .frame(maxWidth: .infinity)}- Spacer()- Picker("内容", selection: $tab) {- Text("纪要").tag("notes")- Text("文字记录").tag("transcript")- }- .pickerStyle(.segmented).labelsHidden().frame(width: 150)- if tab == "transcript" {- Picker("显示", selection: $view) {- Text("双语").tag("both")- Text("原文").tag("src")- Text("译文").tag("dst")+ .overlay {+ Text(s.id == store.liveID ? "正在听,说话的内容会出现在这里" : "这场会议没有记录到内容")+ .font(.system(size: 13)).foregroundStyle(Palette.secondary)}- .pickerStyle(.segmented).labelsHidden().frame(width: 150)- }- Menu {- Button("复制为 Markdown") { model.export(s, kind: "copy") }- Divider()- Button("导出 Markdown…") { model.export(s, kind: "md") }- Button("导出 Word…") { model.export(s, kind: "word") }- Button("导出字幕 SRT…") { model.export(s, kind: "srt") }- Divider()- Button("在 Finder 中显示") { NSWorkspace.shared.activateFileViewerSelecting([store.folder(s.id)]) }- } label: {- Text("导出").font(.system(size: 13, weight: .semibold)).foregroundStyle(.white)- .padding(.horizontal, 16).frame(height: 32)- .background(RoundedRectangle(cornerRadius: 9).fill(Palette.ink))- }- .menuStyle(.button).buttonStyle(.plain).menuIndicator(.hidden)- .disabled(s.lines.isEmpty)- }- .padding(.horizontal, 28).padding(.top, 24).padding(.bottom, 16)- .onChange(of: s.id) { _, _ in titleDraft = "" }-- Divider().padding(.horizontal, 28)-- if tab == "notes" && !s.lines.isEmpty {- SessionNotesView(model: model, engine: model.notes, ling: model.ling, session: s) { t in+ } else if tab == "notes" {+ SessionNotesView(model: model, engine: model.notes, ling: model.ling, session: s,+ header: AnyView(header(s))) { t injumpTo = ttab = "transcript"}- } else if s.lines.isEmpty {- VStack(spacing: 8) {- Spacer()- Text(s.id == store.liveID ? "正在听,说话的内容会出现在这里" : "这场会议没有记录到内容")- .font(.system(size: 13)).foregroundStyle(Palette.secondary)- Spacer()- }- .frame(maxWidth: .infinity)} else {- ScrollViewReader { proxy in- ScrollView {- LazyVStack(alignment: .leading, spacing: 0) {- ForEach(s.lines) { l in- lineRow(l).id(l.id)- Divider()- }- }- .padding(.horizontal, 28)- }- .onChange(of: s.lines.count) { _, _ in- if s.id == store.liveID, let last = s.lines.last {- withAnimation { proxy.scrollTo(last.id, anchor: .bottom) }- }- }- .onAppear {- if let t = jumpTo, let l = s.lines.first(where: { $0.t >= t - 1 }) { proxy.scrollTo(l.id, anchor: .top) }- jumpTo = nil- }- }+ transcript(s)}}+ .onChange(of: s.id) { _, _ in titleDraft = "" }} else {VStack(spacing: 10) {LogoTile(size: 44)@@ -454,33 +473,154 @@ struct MainWindowView: View {}}+ private func toolbar(_ s: Session) -> some View {+ HStack(spacing: 4) {+ tabButton("纪要", id: "notes")+ tabButton("文字记录", id: "transcript", count: s.lines.count)+ Spacer()+ if tab == "transcript" {+ Picker("显示", selection: $view) {+ Text("双语").tag("both")+ Text("原文").tag("src")+ Text("译文").tag("dst")+ }+ .pickerStyle(.segmented).labelsHidden().frame(width: 150).padding(.trailing, 6)+ }+ Button { NSWorkspace.shared.activateFileViewerSelecting([store.folder(s.id)]) } label: {+ Image(systemName: "folder").font(.system(size: 14)).frame(width: 32, height: 32).contentShape(Rectangle())+ }+ .buttonStyle(.plain).foregroundStyle(Palette.secondary).help("在 Finder 中显示")+ Menu {+ Button("复制为 Markdown") { model.export(s, kind: "copy") }+ Divider()+ Button("导出 Markdown…") { model.export(s, kind: "md") }+ Button("导出 Word…") { model.export(s, kind: "word") }+ Button("导出字幕 SRT…") { model.export(s, kind: "srt") }+ } label: {+ HStack(spacing: 6) {+ Text("导出").font(.system(size: 13, weight: .semibold))+ Image(systemName: "chevron.down").font(.system(size: 9, weight: .bold))+ }+ .foregroundStyle(.white)+ .padding(.horizontal, 14).frame(height: 30)+ .background(RoundedRectangle(cornerRadius: 8).fill(Palette.ink))+ }+ .menuStyle(.button).buttonStyle(.plain).menuIndicator(.hidden).fixedSize()+ .disabled(s.lines.isEmpty)+ }+ .padding(.leading, 16).padding(.trailing, 14)+ .frame(height: 52)+ }++ private func tabButton(_ title: String, id: String, count: Int? = nil) -> some View {+ let on = tab == id+ return Button { tab = id } label: {+ HStack(spacing: 5) {+ Text(title).font(.system(size: 13, weight: on ? .semibold : .regular))+ .foregroundStyle(on ? Palette.ink : Palette.secondary)+ if let count { Text("\(count)").font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary) }+ }+ .padding(.horizontal, 12).frame(height: 52)+ .overlay(alignment: .bottom) { Rectangle().fill(on ? Palette.ink : .clear).frame(height: 2) }+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ }++ /// Date, the editable title and a row of facts: the top of the page, scrolling with it.+ private func header(_ s: Session) -> some View {+ let live = s.id == store.liveID+ return VStack(alignment: .leading, spacing: 12) {+ Text(dateLine(s, live: live)).font(.system(size: 12)).foregroundStyle(Palette.secondary)+ TextField("标题", text: Binding(+ get: { titleDraft.isEmpty ? s.title : titleDraft },+ set: { titleDraft = $0 }+ ), axis: .vertical)+ .textFieldStyle(.plain)+ .font(.system(size: 28, weight: .bold))+ .onSubmit { store.rename(s.id, to: titleDraft) }+ HStack(spacing: 8) {+ if live { Tag("正在记录", live: true) }+ chip(Self.length(s))+ chip("\(s.lines.count) 句")+ if let p = Self.pair(s, short: false) { chip(p) }+ if let n = (live ? model.notes.notes : s.notes), !n.isEmpty {+ if n.final { Tag("完整版纪要", live: true) } else { chip("速记版纪要") }+ }+ }+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ }++ private func chip(_ text: String) -> some View {+ Text(text).font(.system(size: 12)).foregroundStyle(Palette.secondary)+ .padding(.horizontal, 9).padding(.vertical, 4)+ .background(RoundedRectangle(cornerRadius: 6).fill(Palette.fill))+ .fixedSize()+ }++ private func dateLine(_ s: Session, live: Bool) -> String {+ let f = DateFormatter()+ f.locale = Locale(identifier: "zh_CN")+ f.dateFormat = "M月d日 EEE HH:mm"+ let start = f.string(from: s.startedAt)+ guard !live, let end = s.endedAt else { return live ? "\(start) 起" : start }+ f.dateFormat = "HH:mm"+ return "\(start) – \(f.string(from: end))"+ }++ private func transcript(_ s: Session) -> some View {+ ScrollViewReader { proxy in+ ScrollView {+ LazyVStack(alignment: .leading, spacing: 0) {+ header(s).padding(.bottom, 20)+ ForEach(s.lines) { l in+ Divider()+ lineRow(l).id(l.id)+ }+ }+ .frame(maxWidth: 680)+ .padding(.horizontal, 32).padding(.vertical, 36)+ .frame(maxWidth: .infinity)+ }+ .onChange(of: s.lines.count) { _, _ in+ if s.id == store.liveID, let last = s.lines.last {+ withAnimation { proxy.scrollTo(last.id, anchor: .bottom) }+ }+ }+ .onAppear {+ if let t = jumpTo, let l = s.lines.first(where: { $0.t >= t - 1 }) { proxy.scrollTo(l.id, anchor: .top) }+ jumpTo = nil+ }+ }+ }+private func lineRow(_ l: TranscriptLine) -> some View {let me = l.speaker == "me"return HStack(alignment: .top, spacing: 16) {Text(TranscriptExport.clock(l.t))- .font(.system(size: 11).monospacedDigit()).foregroundStyle(Palette.tertiary)- .frame(width: 44, alignment: .leading).padding(.top, 2)+ .font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary)+ .frame(width: 52, alignment: .leading).padding(.top, 1)VStack(alignment: .leading, spacing: 5) {- HStack(spacing: 6) {- Circle().fill(me ? Palette.accent : Palette.ink.opacity(0.35)).frame(width: 7, height: 7)- Text(me ? "你" : "对方").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.secondary)- }+ Text(me ? "你" : "对方").font(.system(size: 11, weight: .semibold))+ .foregroundStyle(me ? Palette.accentInk : Palette.secondary)if view != "dst" {Text(l.src)- .font(.system(size: view == "src" ? 14 : 13))+ .font(.system(size: view == "src" ? 15 : 13)).foregroundStyle(view == "src" ? Palette.ink : Palette.tertiary)+ .lineSpacing(2).textSelection(.enabled)}if view != "src" {Text(l.dst ?? "翻译中…")- .font(.system(size: 14))+ .font(.system(size: 15)).lineSpacing(3).foregroundStyle(l.dst == nil ? Palette.tertiary : Palette.ink).textSelection(.enabled)}}Spacer(minLength: 0)}- .padding(.vertical, 12)+ .padding(.vertical, 14)}}@@ -492,6 +632,8 @@ struct SessionNotesView: View {@ObservedObject var engine: NotesEngine@ObservedObject var ling: LingClientlet session: Session+ /// The page's title block, scrolling with the notes.+ var header: AnyView = AnyView(EmptyView())let onJump: (Double) -> Voidprivate var live: Bool { session.id == model.store.liveID }@@ -500,9 +642,11 @@ struct SessionNotesView: View {var body: some View {ScrollView {- VStack(alignment: .leading, spacing: 0) {+ VStack(alignment: .leading, spacing: 30) {+ headerif let notes, !notes.isEmpty {- NotesContentView(notes: notes, fresh: live ? engine.fresh : [], live: live, onJump: onJump)+ NotesContentView(notes: notes, fresh: live ? engine.fresh : [], live: live, document: true,+ endedAt: session.lines.last?.t, onJump: onJump)} else if generating || (live && ling.hasKey && !session.lines.isEmpty) {NotesGeneratingView(heard: session.lines.count)} else {@@ -529,8 +673,9 @@ struct SessionNotesView: View {.background(RoundedRectangle(cornerRadius: 18).fill(Palette.raised))}}- .padding(.horizontal, 28).padding(.vertical, 20)- .frame(maxWidth: 760, alignment: .leading)+ .frame(maxWidth: 680, alignment: .leading)+ .padding(.horizontal, 32).padding(.vertical, 36)+ .frame(maxWidth: .infinity)}}}diff --git a/site/changelog.json b/site/changelog.jsonindex 1dfee5b..5b43d83 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -90,6 +90,11 @@"kind": "fixed","title": "点纪要窗口会带出主窗口。","text": "现在点它不会把主窗口或设置顶上来,也不抢会议软件的焦点;只开着纪要窗口时,Dock 里不再多一个图标。点 Dock 图标会回到已打开的窗口;正在记录时退出会先问一句;设置记住位置和上次的页面;「窗口」菜单列出已打开的窗口。"+ },+ {+ "kind": "improved",+ "title": "会议记录窗口像读文档一样。",+ "text": "会议按今天、昨天、本周、月份分组;左下角能看到是否在听,开关和设置也在这里;每场会议是一页:日期、大标题、时长和语言,总结放在最前面,接着是带时间的议题、结论和待办。⌘F 直接搜索。"}]},