namespace WorkCameraExport.Models
{
///
/// 应用配置 - 用户可配置项
///
public class AppConfig
{
///
/// 默认保存路径
///
public string DefaultSavePath { get; set; } = "";
///
/// 图片下载并发数 (1-10)
///
public int ImageDownloadConcurrency { get; set; } = 5;
///
/// 图片压缩质量 (30-100)
///
public int ImageCompressQuality { get; set; } = 50;
///
/// 自动清理临时文件
///
public bool AutoCleanTempFiles { get; set; } = true;
///
/// 验证并修正配置值
///
public void Validate()
{
// 并发数限制在 1-10
if (ImageDownloadConcurrency < 1) ImageDownloadConcurrency = 1;
if (ImageDownloadConcurrency > 10) ImageDownloadConcurrency = 10;
// 压缩质量限制在 30-100
if (ImageCompressQuality < 30) ImageCompressQuality = 30;
if (ImageCompressQuality > 100) ImageCompressQuality = 100;
// 默认保存路径为空时使用桌面
if (string.IsNullOrWhiteSpace(DefaultSavePath))
{
DefaultSavePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
}
}
///
/// 创建默认配置
///
public static AppConfig CreateDefault()
{
return new AppConfig
{
DefaultSavePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
ImageDownloadConcurrency = 5,
ImageCompressQuality = 50,
AutoCleanTempFiles = true
};
}
}
}