You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
2.9 KiB

import 'package:json_annotation/json_annotation.dart';
part 'channel_app_model.g.dart';
/// 渠道应用信息响应模型
@JsonSerializable()
class ChannelAppResponse {
@JsonKey(name: 'code')
final int code;
@JsonKey(name: 'data')
final ChannelAppData? data;
@JsonKey(name: 'msg')
final String msg;
const ChannelAppResponse({
required this.code,
this.data,
required this.msg,
});
factory ChannelAppResponse.fromJson(Map<String, dynamic> json) =>
_$ChannelAppResponseFromJson(json);
Map<String, dynamic> toJson() => _$ChannelAppResponseToJson(this);
}
/// 渠道应用数据模型
@JsonSerializable()
class ChannelAppData {
@JsonKey(name: 'app')
final AppInfo app;
const ChannelAppData({
required this.app,
});
factory ChannelAppData.fromJson(Map<String, dynamic> json) =>
_$ChannelAppDataFromJson(json);
Map<String, dynamic> toJson() => _$ChannelAppDataToJson(this);
}
/// 应用信息模型
@JsonSerializable()
class AppInfo {
/// 下载地址
@JsonKey(name: 'address')
final String address;
/// 渠道标识
@JsonKey(name: 'channel')
final String channel;
/// 应用描述
@JsonKey(name: 'description')
final String description;
/// 最新版本号
@JsonKey(name: 'version')
final String version;
/// 是否显示游客登录
@JsonKey(name: 'tourists')
final bool tourists;
const AppInfo({
required this.address,
required this.channel,
required this.description,
required this.version,
required this.tourists,
});
factory AppInfo.fromJson(Map<String, dynamic> json) =>
_$AppInfoFromJson(json);
Map<String, dynamic> toJson() => _$AppInfoToJson(this);
}
/// 版本更新信息模型
class VersionUpdateInfo {
/// 是否有新版本
final bool hasUpdate;
/// 当前版本
final String currentVersion;
/// 最新版本
final String latestVersion;
/// 应用信息
final AppInfo? appInfo;
/// 更新类型
final UpdateType updateType;
const VersionUpdateInfo({
required this.hasUpdate,
required this.currentVersion,
required this.latestVersion,
this.appInfo,
required this.updateType,
});
}
/// 更新类型枚举
enum UpdateType {
/// 无需更新
none,
/// 可选更新
optional,
/// 强制更新
force,
}
/// 应用商店类型枚举
enum AppStoreType {
/// iOS App Store
appStore,
/// Google Play
googlePlay,
/// 华为应用市场
huawei,
/// 小米应用商店
xiaomi,
/// OPPO软件商店
oppo,
/// vivo应用商店
vivo,
/// 荣耀应用市场
honor,
/// 官网下载
official,
/// 未知
unknown,
}
/// 平台信息模型
class PlatformInfo {
/// 平台类型
final String platform;
/// 应用商店类型
final AppStoreType storeType;
/// 渠道标识
final String channel;
const PlatformInfo({
required this.platform,
required this.storeType,
required this.channel,
});
}