mirror of
https://github.com/wangdage12/Snap.Hutao.git
synced 2026-06-06 09:51:06 +08:00
修正机器人审查的一些项
This commit is contained in:
@@ -19,7 +19,8 @@ namespace Snap.Hutao.Migrations
|
||||
table: "cultivate_entries",
|
||||
column: "RelatedEntryId",
|
||||
principalTable: "cultivate_entries",
|
||||
principalColumn: "InnerId");
|
||||
principalColumn: "InnerId",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -108,8 +108,10 @@ internal sealed partial class AvatarPropertyBatchCultivateService : IAvatarPrope
|
||||
|
||||
if (baseline.SyncInventoryItems)
|
||||
{
|
||||
CultivateProject? project = await cultivationService.GetCurrentProjectAsync().ConfigureAwait(false);
|
||||
if (project is not null)
|
||||
Snap.Hutao.Core.Database.IAdvancedDbCollectionView<CultivateProject> projects = await cultivationService.GetProjectCollectionAsync().ConfigureAwait(false);
|
||||
await cultivationService.EnsureCurrentProjectAsync(projects).ConfigureAwait(false);
|
||||
|
||||
if (projects.CurrentItem is { } project)
|
||||
{
|
||||
IMetadataService metadataService = serviceProvider.GetRequiredService<IMetadataService>();
|
||||
ICultivationMetadataContext cultivationContext = await metadataService
|
||||
@@ -153,6 +155,7 @@ internal sealed partial class AvatarPropertyBatchCultivateService : IAvatarPrope
|
||||
|
||||
if (!await SaveCultivationAsync(consumption, new CultivatePromotionDeltaOptions(delta, baseline.Strategy)).ConfigureAwait(false))
|
||||
{
|
||||
result.StopReason = BatchCultivateStopReason.NoProject;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,4 +7,11 @@ internal struct BatchCultivateResult
|
||||
{
|
||||
public int SucceedCount;
|
||||
public int SkippedCount;
|
||||
public BatchCultivateStopReason StopReason;
|
||||
}
|
||||
|
||||
internal enum BatchCultivateStopReason
|
||||
{
|
||||
None = 0,
|
||||
NoProject = 1,
|
||||
}
|
||||
|
||||
@@ -54,22 +54,17 @@ internal sealed partial class CultivationRepository : ICultivationRepository
|
||||
|
||||
public Guid? TryGetAvatarCultivateEntryInnerId(Guid projectId, uint avatarId)
|
||||
{
|
||||
ImmutableArray<CultivateEntry> entries = GetCultivateEntryImmutableArrayByProjectIdAndItemId(projectId, avatarId);
|
||||
Guid? last = null;
|
||||
foreach (ref readonly CultivateEntry entry in entries.AsSpan())
|
||||
// NOTE: InnerId(Guid) 的大小不代表插入顺序;这里使用 SQLite 的 rowid 选择最新插入的一条。
|
||||
using (IServiceScope scope = ServiceProvider.CreateScope())
|
||||
{
|
||||
if (entry.Type != CultivateType.AvatarAndSkill)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (last is null || entry.InnerId.CompareTo(last.Value) > 0)
|
||||
{
|
||||
last = entry.InnerId;
|
||||
}
|
||||
AppDbContext db = scope.GetAppDbContext();
|
||||
return db.Set<CultivateEntry>()
|
||||
.AsNoTracking()
|
||||
.Where(e => e.ProjectId == projectId && e.Id == avatarId && e.Type == CultivateType.AvatarAndSkill)
|
||||
.OrderByDescending(e => EF.Property<long>(e, "rowid"))
|
||||
.Select(e => (Guid?)e.InnerId)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
public void AddCultivateEntry(CultivateEntry entry)
|
||||
|
||||
@@ -47,7 +47,7 @@ internal interface ICultivationRepository : IRepository<CultivateEntryLevelInfor
|
||||
|
||||
/// <summary>
|
||||
/// 解析当前计划中指定角色的养成条目(类型为 CultivateType.AvatarAndSkill)。
|
||||
/// 若存在多条历史记录,取条目主键 InnerId(Guid)较大的一条。
|
||||
/// 若存在多条历史记录,取最近插入数据库的一条(按 SQLite rowid 倒序)。
|
||||
/// </summary>
|
||||
Guid? TryGetAvatarCultivateEntryInnerId(Guid projectId, uint avatarId);
|
||||
|
||||
|
||||
@@ -232,65 +232,69 @@
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="StatisticsItemTemplate" x:DataType="shvcu:StatisticsCultivateItem">
|
||||
<Border Background="Transparent" IsRightTapEnabled="True">
|
||||
<Border.ContextFlyout>
|
||||
<Flyout FlyoutPresenterStyle="{ThemeResource FlyoutPresenterPadding0Style}">
|
||||
<ScrollViewer MaxHeight="320" MinWidth="220" Padding="12,10">
|
||||
<ItemsControl ItemsSource="{Binding StatisticsConsumerMenuLines, Mode=OneWay}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="shvcu:StatisticsConsumerMenuLine">
|
||||
<Grid Margin="0,3">
|
||||
<TextBlock
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind PlainMessage, Mode=OneWay}"
|
||||
TextWrapping="WrapWholeWords"
|
||||
Visibility="{x:Bind IsPlainMessage, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="4"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{x:Bind ShowRichRow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<shuxc:ItemIcon
|
||||
Width="28"
|
||||
Height="28"
|
||||
Icon="{x:Bind LeadingIcon, Mode=OneWay}"
|
||||
Quality="{x:Bind LeadingQuality, Mode=OneWay}"/>
|
||||
<Border Background="Transparent">
|
||||
<shuxcc:HorizontalCard
|
||||
Background="{Binding IsToday, Converter={ThemeResource BoolToStatisticsBrushSelector}}"
|
||||
IsRightTapEnabled="True"
|
||||
IsTabStop="True"
|
||||
UseSystemFocusVisuals="True">
|
||||
<FrameworkElement.ContextFlyout>
|
||||
<Flyout FlyoutPresenterStyle="{ThemeResource FlyoutPresenterPadding0Style}">
|
||||
<ScrollViewer MaxHeight="320" MinWidth="220" Padding="12,10">
|
||||
<ItemsControl ItemsSource="{Binding StatisticsConsumerMenuLines, Mode=OneWay}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="shvcu:StatisticsConsumerMenuLine">
|
||||
<Grid Margin="0,3">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind FirstName, Mode=OneWay}"/>
|
||||
Text="{x:Bind PlainMessage, Mode=OneWay}"
|
||||
TextWrapping="WrapWholeWords"
|
||||
Visibility="{x:Bind IsPlainMessage, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="4"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{x:Bind HasSecondIcon, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind BetweenSeparator, Mode=OneWay}"/>
|
||||
Visibility="{x:Bind ShowRichRow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<shuxc:ItemIcon
|
||||
Width="28"
|
||||
Height="28"
|
||||
Icon="{x:Bind SecondIcon, Mode=OneWay}"
|
||||
Quality="{x:Bind SecondQuality, Mode=OneWay}"/>
|
||||
Icon="{x:Bind LeadingIcon, Mode=OneWay}"
|
||||
Quality="{x:Bind LeadingQuality, Mode=OneWay}"/>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind SecondName, Mode=OneWay}"/>
|
||||
Text="{x:Bind FirstName, Mode=OneWay}"/>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="4"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{x:Bind HasSecondIcon, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind BetweenSeparator, Mode=OneWay}"/>
|
||||
<shuxc:ItemIcon
|
||||
Width="28"
|
||||
Height="28"
|
||||
Icon="{x:Bind SecondIcon, Mode=OneWay}"
|
||||
Quality="{x:Bind SecondQuality, Mode=OneWay}"/>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind SecondName, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind CountSuffix, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind CountSuffix, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Flyout>
|
||||
</Border.ContextFlyout>
|
||||
<shuxcc:HorizontalCard Background="{Binding IsToday, Converter={ThemeResource BoolToStatisticsBrushSelector}}">
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Flyout>
|
||||
</FrameworkElement.ContextFlyout>
|
||||
<shuxcc:HorizontalCard.Left>
|
||||
<Grid Grid.Column="0">
|
||||
<shuxc:ItemIcon
|
||||
|
||||
@@ -281,6 +281,12 @@ internal sealed partial class AvatarPropertyViewModel : Abstraction.ViewModel, I
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.StopReason is not BatchCultivateStopReason.None)
|
||||
{
|
||||
scopeContext.Messenger.Send(InfoBarMessage.Warning(SH.ViewModelCultivationEntryAddWarning));
|
||||
return;
|
||||
}
|
||||
|
||||
scopeContext.Messenger.Send(CultivationProjectEntriesChangedMessage.Empty);
|
||||
|
||||
InfoBarMessage message = result.SkippedCount > 0
|
||||
|
||||
@@ -149,7 +149,12 @@ internal sealed partial class CultivationViewModel : Abstraction.ViewModel, IRec
|
||||
LocalSetting.Set(SettingKeys.CultivationRefreshInventoryByCalculatorToAllProjects, value);
|
||||
}
|
||||
|
||||
public async void Receive(CultivationProjectEntriesChangedMessage message)
|
||||
public void Receive(CultivationProjectEntriesChangedMessage _)
|
||||
{
|
||||
ReceiveProjectEntriesChangedAsync().SafeForget();
|
||||
}
|
||||
|
||||
private async ValueTask ReceiveProjectEntriesChangedAsync()
|
||||
{
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
if (Projects?.CurrentItem is null)
|
||||
@@ -382,6 +387,12 @@ internal sealed partial class CultivationViewModel : Abstraction.ViewModel, IRec
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.StopReason is not BatchCultivateStopReason.None)
|
||||
{
|
||||
messenger.Send(InfoBarMessage.Warning(SH.ViewModelCultivationEntryAddWarning));
|
||||
return;
|
||||
}
|
||||
|
||||
messenger.Send(CultivationProjectEntriesChangedMessage.Empty);
|
||||
|
||||
InfoBarMessage message = result.SkippedCount > 0
|
||||
|
||||
Reference in New Issue
Block a user