import AppIntents import UIKit // 「上传剪贴板」控件动作:读本机剪贴板文本,经控件专用会话推到云剪贴板。 struct UploadClipboardIntent: AppIntent { static var title: LocalizedStringResource = "上传剪贴板" static var description = IntentDescription("把本机剪贴板内容上传到 Commilitia Drop 云剪贴板") func perform() async throws -> some IntentResult { let text = await MainActor.run { UIPasteboard.general.string ?? "" } if !text.isEmpty { try? await ClipboardClient.upload(text) } return .result() } } // 「拉取剪贴板」控件动作:拉云剪贴板内容写入本机剪贴板。 struct PullClipboardIntent: AppIntent { static var title: LocalizedStringResource = "拉取剪贴板" static var description = IntentDescription("把 Commilitia Drop 云剪贴板内容写入本机剪贴板") func perform() async throws -> some IntentResult { if let text = try? await ClipboardClient.pull(), !text.isEmpty { await MainActor.run { UIPasteboard.general.string = text } } return .result() } }