// // WeChatShareModels.swift // suixinkan // import Foundation /// 微信分享目标场景。 enum WeChatShareScene: Int, CaseIterable, Sendable { /// 微信好友会话。 case session = 0 /// 朋友圈。 case timeline = 1 /// 微信收藏。 case favorite = 2 /// 展示文案。 var title: String { switch self { case .session: return "微信好友" case .timeline: return "朋友圈" case .favorite: return "收藏" } } /// 映射到微信 SDK 的 `scene` 整数值。 var wxSceneValue: Int32 { Int32(rawValue) } } /// 微信分享请求结果。 enum WeChatShareResult: Equatable, Sendable { case success case cancelled case notInstalled case unsupported case invalidPayload(String) case sendFailed(Int) case unknown(Int) /// 根据微信 SDK 错误码转换为业务可识别的分享结果。 static func fromWXErrorCode(_ code: Int32) -> WeChatShareResult { switch code { case 0: return .success case -2: return .cancelled default: return .unknown(Int(code)) } } } /// 网页分享载荷,供邀请等业务模块调用微信分享。 struct WeChatWebPageSharePayload: Equatable, Sendable { let title: String let description: String let url: String } /// 文本分享载荷。 struct WeChatTextSharePayload: Equatable, Sendable { let text: String } /// 图片分享载荷。 struct WeChatImageSharePayload: Equatable, Sendable { let imageData: Data }