/// 更新配置
class UpdateConfig {
  /// 检查更新的 API 地址
  final String checkUpdateUrl;

  /// 应用包名
  final String packageName;

  /// 更新检查间隔（分钟）
  final int checkIntervalMinutes;

  /// 是否启用自动检查
  final bool autoCheck;

  /// 是否在 WiFi 下自动下载
  final bool autoDownloadOnWifi;

  const UpdateConfig({
    required this.checkUpdateUrl,
    required this.packageName,
    this.checkIntervalMinutes = 60,
    this.autoCheck = true,
    this.autoDownloadOnWifi = false,
  });

  /// Mining App 默认配置
  static const mining = UpdateConfig(
    checkUpdateUrl: 'https://mapi.szaiai.com/mining-admin/api/app/version/check',
    packageName: 'com.durianqueen.mining',
    checkIntervalMinutes: 60,
    autoCheck: true,
  );

  UpdateConfig copyWith({
    String? checkUpdateUrl,
    String? packageName,
    int? checkIntervalMinutes,
    bool? autoCheck,
    bool? autoDownloadOnWifi,
  }) {
    return UpdateConfig(
      checkUpdateUrl: checkUpdateUrl ?? this.checkUpdateUrl,
      packageName: packageName ?? this.packageName,
      checkIntervalMinutes: checkIntervalMinutes ?? this.checkIntervalMinutes,
      autoCheck: autoCheck ?? this.autoCheck,
      autoDownloadOnWifi: autoDownloadOnWifi ?? this.autoDownloadOnWifi,
    );
  }
}
