mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-28 01:04:18 +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
32 lines
919 B
Swift
32 lines
919 B
Swift
import Foundation
|
|
|
|
/// 用户主动触发的图片剪贴板 seam:以 PNG 数据为规范输入写入剪贴板。生产
|
|
/// adapter 负责平台类型映射(PNG 之外附加哪些兼容类型),协议不感知;读取
|
|
/// 侧暂无消费者,协议不设 read。分享策略与二维码生成不属于此协议。
|
|
@MainActor
|
|
protocol ImageClipboard {
|
|
func write(_ pngData: Data) throws
|
|
}
|
|
|
|
enum ImageClipboardFailure: Equatable, Error {
|
|
case writeFailed
|
|
}
|
|
|
|
/// 测试与 Preview 使用的内存实现:不触碰用户的真实 pasteboard。
|
|
@MainActor
|
|
final class InMemoryImageClipboard: ImageClipboard {
|
|
private(set) var pngData: Data?
|
|
var writeFailure: ImageClipboardFailure?
|
|
|
|
init(writeFailure: ImageClipboardFailure? = nil) {
|
|
self.writeFailure = writeFailure
|
|
}
|
|
|
|
func write(_ pngData: Data) throws {
|
|
if let writeFailure {
|
|
throw writeFailure
|
|
}
|
|
self.pngData = pngData
|
|
}
|
|
}
|