- 侧边栏 4 → 6 项:首页 / 历史记录 / 词汇表 / 风格 / 帮助中心 / 设置 - 词典 → 词汇表,整页改 chip 流式布局:phrase + hitCount,hover ✕ 删除, 批量输入(每行一个),重置统计 / 清除全部 - DictionaryEntry 加 hitCount + 兼容旧 dictionary.json 解码 - DictationCoordinator 在润色后扫描最终文本递增命中数; 删除 learnTerms 自动学词路径 - 润色模式 → 风格 (StyleTab):4 张模式卡 + 启用开关; 关闭时跳过 Ark 直接插入原文 (UserPreferences.polishEnabled) - 帮助中心:快速上手 4 步、快捷键速查、FAQ、GitHub 外链 - 设置 Tab 合并 Volc ASR + Ark 凭据、录音、授权、隐私、关于 + 检查更新 - 胶囊:NSPanel 220×96, hasShadow=false;macOS 26 分支去掉 SwiftUI 阴影 → 解决"红绿灯外圈黑边" - 侧边栏视觉:strokeBorder 0.08 → 0.04、阴影 radius 16 → 6 → 解决"灰色边栏 + 黑色卡顿" - 首页底部新增今日概览 + 风格预览
74 lines
2.8 KiB
Swift
74 lines
2.8 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
@MainActor
|
|
final class SettingsWindowController: NSObject, NSWindowDelegate {
|
|
private var window: NSWindow?
|
|
private let navigation = SettingsNavigationModel()
|
|
|
|
func show(tab: OpenLessMainTab = .home) {
|
|
NSApp.setActivationPolicy(.regular)
|
|
navigation.selection = tab
|
|
if let window = window {
|
|
window.makeKeyAndOrderFront(nil)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
alignTrafficLights(in: window)
|
|
return
|
|
}
|
|
let hosting = NSHostingController(rootView: SettingsView(navigation: navigation))
|
|
let win = NSWindow(contentViewController: hosting)
|
|
win.title = "OpenLess"
|
|
win.styleMask = [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView]
|
|
win.titleVisibility = .hidden
|
|
win.titlebarAppearsTransparent = true
|
|
win.toolbar = nil
|
|
// 只允许拖动原生顶栏区域(含 traffic lights 那条带);
|
|
// 否则 TextField 上的拖选手势会被整窗拖动吞掉。
|
|
win.isMovableByWindowBackground = false
|
|
win.setContentSize(NSSize(width: 1040, height: 700))
|
|
win.contentMinSize = NSSize(width: 960, height: 640)
|
|
win.tabbingMode = .disallowed
|
|
win.center()
|
|
win.isReleasedWhenClosed = false
|
|
win.delegate = self
|
|
self.window = win
|
|
win.makeKeyAndOrderFront(nil)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
DispatchQueue.main.async { [weak self, weak win] in
|
|
guard let win else { return }
|
|
self?.alignTrafficLights(in: win)
|
|
}
|
|
}
|
|
|
|
func windowWillClose(_ notification: Notification) {
|
|
NSApp.setActivationPolicy(.accessory)
|
|
}
|
|
|
|
func windowDidResize(_ notification: Notification) {
|
|
guard let window = notification.object as? NSWindow else { return }
|
|
alignTrafficLights(in: window)
|
|
}
|
|
|
|
func windowDidBecomeKey(_ notification: Notification) {
|
|
guard let window = notification.object as? NSWindow else { return }
|
|
alignTrafficLights(in: window)
|
|
}
|
|
|
|
private func alignTrafficLights(in window: NSWindow) {
|
|
let buttons: [NSButton?] = [
|
|
window.standardWindowButton(.closeButton),
|
|
window.standardWindowButton(.miniaturizeButton),
|
|
window.standardWindowButton(.zoomButton),
|
|
]
|
|
// 侧边栏左边距 12pt;红绿灯距侧边栏左边 ~8pt → 距窗口左 20pt。
|
|
for (index, button) in buttons.compactMap({ $0 }).enumerated() {
|
|
var frame = button.frame
|
|
frame.origin.x = 20 + CGFloat(index) * 22
|
|
if let superview = button.superview, superview.bounds.height > 80 {
|
|
frame.origin.y = superview.bounds.height - 34
|
|
}
|
|
button.frame = frame
|
|
}
|
|
}
|
|
}
|