using MyHomePage.Api.Models.Entities; namespace MyHomePage.Api.Models.Dtos; /// 设置输出 DTO public class SettingDto { public string ThemeMode { get; set; } = "dark"; public string AccentColor { get; set; } = "#6c5ce7"; public string? BackgroundImage { get; set; } public string BackgroundType { get; set; } = "preset"; public bool OpenLinksInNewTab { get; set; } = true; /// 搜索框行为(P46):true = 搜索结果在新选项卡打开(默认);false = 当前选项卡打开 public bool OpenSearchInNewTab { get; set; } = true; // ===== P34 360 在线壁纸模式 ===== /// 是否启用 360 在线壁纸(按分类随机 + 定时切换) public bool WallpaperEnabled { get; set; } = false; /// 360 壁纸分类 ID,空字符串 = 全部/推荐 public string WallpaperCategoryId { get; set; } = ""; /// 自动切换间隔(分钟),0 = 不自动切换 public int WallpaperInterval { get; set; } = 30; public DateTime UpdatedAt { get; set; } /// 从实体构造 DTO,统一所有 Controller / Service 的转换逻辑,避免漏字段。 public static SettingDto FromEntity(Setting s) => new() { ThemeMode = s.ThemeMode, AccentColor = s.AccentColor, BackgroundImage = s.BackgroundImage, BackgroundType = s.BackgroundType, OpenLinksInNewTab = s.OpenLinksInNewTab != 0, OpenSearchInNewTab = s.OpenSearchInNewTab != 0, WallpaperEnabled = s.WallpaperEnabled != 0, WallpaperCategoryId = s.WallpaperCategoryId ?? "", WallpaperInterval = s.WallpaperInterval, UpdatedAt = s.UpdatedAt }; } /// 设置更新入参(全部可选) public class SettingUpdateRequest { public string? ThemeMode { get; set; } public string? AccentColor { get; set; } public string? BackgroundImage { get; set; } public string? BackgroundType { get; set; } public bool? OpenLinksInNewTab { get; set; } /// 搜索框行为(P46):true = 搜索结果在新选项卡打开(默认);false = 当前选项卡打开 public bool? OpenSearchInNewTab { get; set; } // ===== P34 360 在线壁纸 ===== public bool? WallpaperEnabled { get; set; } public string? WallpaperCategoryId { get; set; } public int? WallpaperInterval { get; set; } }