Files
suixinkan_uikit/suixinkan/Core/WeChat/WeChatShareModels.swift

74 lines
1.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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
}