492563ae44
- MacClipboardMonitor:NSPasteboard changeCount 轮询 500ms + ProcessInfo.beginActivity(.userInitiatedAllowingIdleSystemSleep) 防 App Nap,本机复制的普通文本自动上传云剪贴板。移植桌面 desktop/platform/clipboard.go 的 Monitor 回环守卫(selfHash 自写回声消费一次并解除 + lastHash 去重)与 clipboard_darwin.m 过滤(org.nspasteboard.{Concealed,Transient,AutoGenerated} 敏感标记跳过 / Handoff shared-pasteboard 暂存路径跳过 / 富文本从 RTF·RTFD 派生纯文本)
- EngineController:加 uploadClipboardText(_:)(monitor 直传已解析文本,绕过再读 pasteboard 避免暂存路径等边角,静默不弹空提示);macOS 写剪贴板前 armSelfWrite 武装守卫(手动拉取写入的内容不被 monitor 再上传成回环)
- 设置加「自动同步本机复制(上行)」开关(@AppStorage macClipboardAutoSync,默认开);MacRootView 按开关 onAppear/onChange 启停、登出(视图消失)即停;菜单栏加剪贴板上传 / 拉取(登录态)
- 下行自动(远端 → 本机自动写剪贴板)仍待办:共享引擎 JS 仅在手动 clipboardPull 时回灌原生 "clipboard" 通知,远端 SSE clipboard:update 在 WebView 壳不落原生(桌面走 Wails 专路 ApplyRemoteClipboard);补齐须改 web/src 引擎 + prod 部署(Mac 从线上加载 engine.html)+ 按 device_type=macos 门控免误伤 iOS。手动拉取(设置 / 菜单栏)已可用
- 验证:just mac-build(CommilitiaDropMac.app)+ iOS 模拟器(CommilitiaDrop.app)均 BUILD SUCCEEDED
50 lines
1.5 KiB
Swift
50 lines
1.5 KiB
Swift
#if os(macOS)
|
||
import SwiftUI
|
||
|
||
// 菜单栏常驻内容:账号 / 在线设备数 / 打开主窗口。后续接入一键剪贴板 push/pull + Quick Send。
|
||
struct MacMenuContent: View
|
||
{
|
||
@Environment(EngineController.self) private var engine
|
||
@Environment(AuthManager.self) private var auth
|
||
@Environment(\.openWindow) private var openWindow
|
||
|
||
var body: some View
|
||
{
|
||
VStack(alignment: .leading, spacing: 10)
|
||
{
|
||
Text("Commilitia Drop")
|
||
.font(.headline)
|
||
|
||
if let name = auth.session?.user.name
|
||
{
|
||
Text(name)
|
||
.font(.caption)
|
||
.foregroundStyle(.secondary)
|
||
Text("在线设备:\(engine.devices.filter(\.online).count)")
|
||
.font(.caption)
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
else
|
||
{
|
||
Text("未登录")
|
||
.font(.caption)
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
|
||
if auth.session != nil
|
||
{
|
||
Divider()
|
||
Button("上传本机剪贴板") { engine.uploadClipboard() }
|
||
Button("拉取云剪贴板") { engine.pullClipboard() }
|
||
}
|
||
|
||
Divider()
|
||
Button("打开主窗口") { openWindow(id: "main") }
|
||
Button("退出") { NSApplication.shared.terminate(nil) }
|
||
}
|
||
.padding(12)
|
||
.frame(width: 240)
|
||
}
|
||
}
|
||
#endif
|