123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // KMAdvertisementModel.swift
- // KMAdvertisement
- //
- // Created by lizhe on 2022/11/30.
- //
- //参考链接 https://www.jianshu.com/p/a24cf8f37860
- //func encode<T>(of model: T) throws where T: Codable {
- // let encoder = JSONEncoder()
- // encoder.outputFormatting = .prettyPrinted
- // let encodedData = try encoder.encode(model)
- // print(String(data: encodedData, encoding: .utf8)!)
- //}
- //func decode<T>(of jsonString: String, type: T.Type) throws -> T where T: Codable {
- // let data = jsonString.data(using: .utf8)!
- // let decoder = JSONDecoder()
- // let model = try! decoder.decode(T.self, from: data)
- // return model
- //}
- /**
-
- */
- public struct KMAdvertisementModel: Codable {
- public let appName: KMAdvertisementAppNameType? //产品名
- public let platform: KMAdvertisementPlatformType? //平台
- public let showType: KMAdvertisementShowType? //显示类型
- public let startTime: String? //开始时间 时间戳
- public let endTime: String? //结束时间 时间戳
- public let subscribeType: KMAdvertisementSubscribeType? //是否订阅
- public let version: String? //小于等于此版本生效
- let content:[Section]
-
-
- public struct Section: Codable {
- let sectionTitle: Text?
- let content: [Content]
-
- public struct Content: Codable {
- var index: Int?
- let title: Text?
- let imageURL: Image?
- let ipadImageURL: Image?
- let linkURL: Language?
- let tips: Language?
- let button: Text?
- let actionType: KMAdvertisementActionType?
- }
- }
-
- struct Text: Codable {
- let font: Font?
- let color: Color?
- let background: Background?
- let language: Language?
- }
-
- struct Font: Codable {
- let name: String?
- let size: Int?
- }
-
- struct Color: Codable {
- let height: ColorState?
- let normal: ColorState?
-
- struct ColorState: Codable {
- let dark: ColorInfo?
- let universal: ColorInfo?
-
- struct ColorInfo: Codable {
- var hex: String?
- var alpha: Float?
- }
- }
- }
- struct Background: Codable {
- let color: Color?
- let layer: Layer?
-
- struct Layer: Codable {
- let cornerRadius: CGFloat?
- let borderWidth: CGFloat?
- let borderColor: Color?
- }
- }
-
- struct Image: Codable {
- let height: Language?
- let normal: Language?
- let background: Background?
- }
-
- struct Language: Codable {
- let en: String?
- let zh_TW: String?
- let zh_CN: String?
- }
- }
|