mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-08 11:14:51 +00:00
- Replace toolbar QR popover with a window sheet per sketch: top hint, 280pt white-backed QR, copy-image / save-image / copy-ss:// actions and a Done button; all buttons share a 260pt min label width - Freeze share payload and suggested file name at presentation time; transient "copied" feedback on copy actions - Add ImageClipboard seam (PNG normative type + TIFF in AppKit adapter) and QrImageSaver seam (NSSavePanel PNG, sanitized suggested name) - Register new typed failures in the presentation whitelist; extend platform-effects architecture guard and seam tests - Record spec in docs/design/server-share-sheet.md; GLOSSARY server share now covers saved QR image files
23 lines
809 B
Swift
23 lines
809 B
Swift
import AppKit
|
|
|
|
/// 生产 AppKit image clipboard adapter,与 AppKitTextClipboard 同为 pasteboard
|
|
/// replacement 语义的集中点。PNG 为规范类型,另附 TIFF 兼容类型(部分接收方
|
|
/// 如聊天应用只认 TIFF);TIFF 附加失败不影响 PNG 已写入这一结果。
|
|
@MainActor
|
|
final class AppKitImageClipboard: ImageClipboard {
|
|
private let pasteboard: NSPasteboard
|
|
|
|
init(pasteboard: NSPasteboard = .general) {
|
|
self.pasteboard = pasteboard
|
|
}
|
|
|
|
func write(_ pngData: Data) throws {
|
|
guard pasteboard.clearContents() != 0, pasteboard.setData(pngData, forType: .png) else {
|
|
throw ImageClipboardFailure.writeFailed
|
|
}
|
|
if let image = NSImage(data: pngData), let tiff = image.tiffRepresentation {
|
|
_ = pasteboard.setData(tiff, forType: .tiff)
|
|
}
|
|
}
|
|
}
|