diff --git a/src/Starward.Language/Lang.Designer.cs b/src/Starward.Language/Lang.Designer.cs index c14e2c908..7b2dabde5 100644 --- a/src/Starward.Language/Lang.Designer.cs +++ b/src/Starward.Language/Lang.Designer.cs @@ -466,6 +466,60 @@ public static string Common_Yes { } } + /// + /// 查找类似 Warning: The selected time period includes gacha records from more than 6 months ago, which cannot be retrieved after deleting. 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_6MonthsDeletingWarning { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_6MonthsDeletingWarning", resourceCulture); + } + } + + /// + /// 查找类似 Begin Time 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_BeginTime { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_BeginTime", resourceCulture); + } + } + + /// + /// 查找类似 Delete gacha records for a specific time period 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_DeleteGachaRecordsForASpecificTimePeriod { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_DeleteGachaRecordsForASpecificTimePeriod", resourceCulture); + } + } + + /// + /// 查找类似 End Time 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_EndTime { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_EndTime", resourceCulture); + } + } + + /// + /// 查找类似 The selected time period includes {0} gacha records. 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_TheSelectedTimePeriodIncludes0GachaRecords { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_TheSelectedTimePeriodIncludes0GachaRecords", resourceCulture); + } + } + + /// + /// 查找类似 This account has {0} gacha record(s). 的本地化字符串。 + /// + public static string DeleteGachaLogDialog_ThisAccountHas0GachaRecordS { + get { + return ResourceManager.GetString("DeleteGachaLogDialog_ThisAccountHas0GachaRecordS", resourceCulture); + } + } + /// /// 查找类似 Downloaded: 的本地化字符串。 /// @@ -1223,6 +1277,15 @@ public static string GachaLogPage_CopyURL { } } + /// + /// 查找类似 Delete All 的本地化字符串。 + /// + public static string GachaLogPage_DeleteAll { + get { + return ResourceManager.GetString("GachaLogPage_DeleteAll", resourceCulture); + } + } + /// /// 查找类似 Deleted {0} gacha record(s) of UID {1}. 的本地化字符串。 /// @@ -1358,6 +1421,15 @@ public static string GachaLogPage_ShowNoviceGachaType { } } + /// + /// 查找类似 Specific Time Period 的本地化字符串。 + /// + public static string GachaLogPage_SpecificTimePeriod { + get { + return ResourceManager.GetString("GachaLogPage_SpecificTimePeriod", resourceCulture); + } + } + /// /// 查找类似 Update (All) 的本地化字符串。 /// diff --git a/src/Starward.Language/Lang.resx b/src/Starward.Language/Lang.resx index 9c8f9e9ed..7d191ee06 100644 --- a/src/Starward.Language/Lang.resx +++ b/src/Starward.Language/Lang.resx @@ -1609,4 +1609,28 @@ Do you accept the risk and continue to use it? Other Rewards + + Begin Time + + + End Time + + + Delete gacha records for a specific time period + + + Warning: The selected time period includes gacha records from more than 6 months ago, which cannot be retrieved after deleting. + + + This account has {0} gacha record(s). + + + The selected time period includes {0} gacha records. + + + Delete All + + + Specific Time Period + \ No newline at end of file diff --git a/src/Starward.Language/Lang.zh-CN.resx b/src/Starward.Language/Lang.zh-CN.resx index 3687f014f..040e5bb83 100644 --- a/src/Starward.Language/Lang.zh-CN.resx +++ b/src/Starward.Language/Lang.zh-CN.resx @@ -59,46 +59,46 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - - + + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -1609,4 +1609,28 @@ 其他奖励 + + 起始时间 + + + 结束时间 + + + 删除特定时间段的抽卡记录 + + + 警告:所选时间段包含6个月之前的抽卡记录,删除后无法再次获取。 + + + 此账号有 {0} 条抽卡记录 + + + 所选时间段包含 {0} 条抽卡记录 + + + 全部删除 + + + 指定时间段 + \ No newline at end of file diff --git a/src/Starward/Controls/DeleteGachaLogDialog.xaml b/src/Starward/Controls/DeleteGachaLogDialog.xaml new file mode 100644 index 000000000..694bd1cfd --- /dev/null +++ b/src/Starward/Controls/DeleteGachaLogDialog.xaml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Starward/Pages/GachaLogPage.xaml.cs b/src/Starward/Pages/GachaLogPage.xaml.cs index f6def0415..f61deb528 100644 --- a/src/Starward/Pages/GachaLogPage.xaml.cs +++ b/src/Starward/Pages/GachaLogPage.xaml.cs @@ -11,6 +11,7 @@ using Microsoft.UI.Xaml.Media.Animation; using Microsoft.UI.Xaml.Media.Imaging; using Microsoft.UI.Xaml.Navigation; +using Starward.Controls; using Starward.Core; using Starward.Core.Gacha; using Starward.Helpers; @@ -592,6 +593,30 @@ private async Task DeleteUidAsync() } + [RelayCommand] + private async Task DeleteUidByTimeAsync() + { + try + { + var dialog = new DeleteGachaLogDialog + { + CurrentGameBiz = this.CurrentGameBiz, + DefaultUid = this.SelectUid, + XamlRoot = this.XamlRoot, + }; + var result = await dialog.ShowAsync(); + if (dialog.Deleted) + { + UpdateGachaTypeStats(dialog.SelectUid); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Delete uid"); + } + } + + [RelayCommand] private async Task DeleteGachaCacheFileAsync() diff --git a/src/Starward/Services/Gacha/GachaLogService.cs b/src/Starward/Services/Gacha/GachaLogService.cs index 1797dfdd3..6b6f76e9d 100644 --- a/src/Starward/Services/Gacha/GachaLogService.cs +++ b/src/Starward/Services/Gacha/GachaLogService.cs @@ -263,6 +263,12 @@ public virtual int DeleteUid(long uid) + public virtual int DeleteGachaLogByTime(long uid, DateTime begin, DateTime end) + { + using var dapper = _database.CreateConnection(); + return dapper.Execute($"DELETE FROM {GachaTableName} WHERE Uid = @uid AND Time >= @begin AND Time <= @end;", new { uid, begin, end }); + } +