mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix multiple channel/subchannel crash & setting clear invalid cache path crash
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
using Windows.UI;
|
||||
|
||||
namespace Snap.Hutao.Control;
|
||||
namespace Snap.Hutao.Control.Brush;
|
||||
|
||||
internal sealed class ColorSegment : IColorSegment
|
||||
{
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Windows.UI;
|
||||
|
||||
namespace Snap.Hutao.Control;
|
||||
namespace Snap.Hutao.Control.Brush;
|
||||
|
||||
internal interface IColorSegment
|
||||
{
|
||||
@@ -7,7 +7,7 @@ using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Control;
|
||||
namespace Snap.Hutao.Control.Brush;
|
||||
|
||||
[DependencyProperty("Source", typeof(List<IColorSegment>), default!, nameof(OnSourceChanged))]
|
||||
internal sealed partial class SegmentedBar : ContentControl
|
||||
@@ -2,12 +2,11 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
namespace Snap.Hutao.Control.Alternating;
|
||||
namespace Snap.Hutao.Control.Collection.Alternating;
|
||||
|
||||
[DependencyProperty("ItemAlternateBackground", typeof(Brush))]
|
||||
[DependencyProperty("ItemAlternateBackground", typeof(Microsoft.UI.Xaml.Media.Brush))]
|
||||
internal sealed partial class AlternatingItemsControl : ItemsControl
|
||||
{
|
||||
private readonly VectorChangedEventHandler<object> itemsVectorChangedEventHandler;
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
|
||||
namespace Snap.Hutao.Control.Alternating;
|
||||
namespace Snap.Hutao.Control.Collection.Alternating;
|
||||
|
||||
internal interface IAlternatingItem
|
||||
{
|
||||
public Brush? Background { get; set; }
|
||||
public Microsoft.UI.Xaml.Media.Brush? Background { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Control.Collection.Selector;
|
||||
|
||||
[DependencyProperty("EnableMemberPath", typeof(string))]
|
||||
internal sealed partial class ComboBox2 : ComboBox
|
||||
{
|
||||
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
|
||||
{
|
||||
if (element is ComboBoxItem comboBoxItem)
|
||||
{
|
||||
Binding binding = new() { Path = new(EnableMemberPath) };
|
||||
comboBoxItem.SetBinding(IsEnabledProperty, binding);
|
||||
}
|
||||
|
||||
base.PrepareContainerForItemOverride(element, item);
|
||||
}
|
||||
}
|
||||
@@ -37,14 +37,21 @@ internal sealed partial class GachaLogQueryWebCacheProvider : IGachaLogQueryProv
|
||||
string? directory = Path.GetDirectoryName(path);
|
||||
ArgumentNullException.ThrowIfNull(directory);
|
||||
DirectoryInfo webCacheFolder = new(Path.Combine(directory, dataFolder, "webCaches"));
|
||||
Regex versionRegex = VersionRegex();
|
||||
DirectoryInfo? lastestVersionCacheFolder = webCacheFolder
|
||||
.EnumerateDirectories()
|
||||
.Where(dir => versionRegex.IsMatch(dir.Name))
|
||||
.MaxBy(dir => new Version(dir.Name));
|
||||
if (webCacheFolder.Exists)
|
||||
{
|
||||
Regex versionRegex = VersionRegex();
|
||||
DirectoryInfo? lastestVersionCacheFolder = webCacheFolder
|
||||
.EnumerateDirectories()
|
||||
.Where(dir => versionRegex.IsMatch(dir.Name))
|
||||
.MaxBy(dir => new Version(dir.Name));
|
||||
|
||||
lastestVersionCacheFolder ??= webCacheFolder;
|
||||
return Path.Combine(lastestVersionCacheFolder.FullName, @"Cache\Cache_Data\data_2");
|
||||
lastestVersionCacheFolder ??= webCacheFolder;
|
||||
return Path.Combine(lastestVersionCacheFolder.FullName, @"Cache\Cache_Data\data_2");
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -18,6 +18,15 @@ internal sealed partial class LaunchScheme
|
||||
private const string SdkStaticLauncherBilibiliKey = "KAtdSsoQ";
|
||||
private const string SdkStaticLauncherGlobalKey = "gcStgarh";
|
||||
|
||||
private static readonly LaunchScheme ServerChineseChannelDefaultSubChannelDefaultCompatOnly = new()
|
||||
{
|
||||
LauncherId = SdkStaticLauncherChineseId,
|
||||
Key = SdkStaticLauncherChineseKey,
|
||||
Channel = ChannelType.Default,
|
||||
SubChannel = SubChannelType.Default,
|
||||
IsOversea = false,
|
||||
};
|
||||
|
||||
private static readonly LaunchScheme ServerChineseChannelOfficialSubChannelDefault = new()
|
||||
{
|
||||
LauncherId = SdkStaticLauncherChineseId,
|
||||
@@ -63,6 +72,16 @@ internal sealed partial class LaunchScheme
|
||||
IsOversea = false,
|
||||
};
|
||||
|
||||
private static readonly LaunchScheme ServerGlobalChannelDefaultSubChannelDefaultCompatOnly = new()
|
||||
{
|
||||
LauncherId = SdkStaticLauncherGlobalId,
|
||||
Key = SdkStaticLauncherGlobalKey,
|
||||
Channel = ChannelType.Default,
|
||||
SubChannel = SubChannelType.Default,
|
||||
IsOversea = true,
|
||||
IsCompatOnly = true,
|
||||
};
|
||||
|
||||
private static readonly LaunchScheme ServerGlobalChannelOfficialSubChannelDefault = new()
|
||||
{
|
||||
LauncherId = SdkStaticLauncherGlobalId,
|
||||
@@ -99,6 +118,7 @@ internal sealed partial class LaunchScheme
|
||||
return new List<LaunchScheme>()
|
||||
{
|
||||
// 官服
|
||||
ServerChineseChannelDefaultSubChannelDefaultCompatOnly,
|
||||
ServerChineseChannelOfficialSubChannelDefault,
|
||||
ServerChineseChannelOfficialSubChannelOfficial,
|
||||
ServerChineseChannelOfficialSubChannelNoTapTap,
|
||||
@@ -108,6 +128,7 @@ internal sealed partial class LaunchScheme
|
||||
ServerChineseChannelBilibiliSubChannelOfficial,
|
||||
|
||||
// 国际服
|
||||
ServerGlobalChannelDefaultSubChannelDefaultCompatOnly,
|
||||
ServerGlobalChannelOfficialSubChannelDefault,
|
||||
ServerGlobalChannelOfficialSubChannelEpic,
|
||||
ServerGlobalChannelOfficialSubChannelGoogle,
|
||||
|
||||
@@ -55,6 +55,8 @@ internal sealed partial class LaunchScheme
|
||||
/// </summary>
|
||||
public bool IsOversea { get; private set; }
|
||||
|
||||
public bool IsCompatOnly { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 多通道相等
|
||||
/// </summary>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shca="using:Snap.Hutao.Control.Alternating"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shcca="using:Snap.Hutao.Control.Collection.Alternating"
|
||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shcp="using:Snap.Hutao.Control.Panel"
|
||||
@@ -612,11 +612,11 @@
|
||||
Background="{x:Null}"
|
||||
Header="{shcm:ResourceString Name=ViewPageAvatarPropertyHeader}">
|
||||
<Border Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}" CornerRadius="0,0,4,4">
|
||||
<shca:AlternatingItemsControl
|
||||
<shcca:AlternatingItemsControl
|
||||
Margin="0,0,0,-2"
|
||||
ItemAlternateBackground="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
|
||||
ItemsSource="{Binding SelectedAvatar.Properties}">
|
||||
<shca:AlternatingItemsControl.ItemTemplate>
|
||||
<shcca:AlternatingItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Padding="16,8" Background="{Binding Background, Mode=OneWay}">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -653,8 +653,8 @@
|
||||
Text="{Binding AddValue}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</shca:AlternatingItemsControl.ItemTemplate>
|
||||
</shca:AlternatingItemsControl>
|
||||
</shcca:AlternatingItemsControl.ItemTemplate>
|
||||
</shcca:AlternatingItemsControl>
|
||||
</Border>
|
||||
</Expander>
|
||||
<!-- 圣遗物 -->
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
xmlns:mxim="using:Microsoft.Xaml.Interactions.Media"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shccs="using:Snap.Hutao.Control.Collection.Selector"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shvc="using:Snap.Hutao.View.Control"
|
||||
xmlns:shvg="using:Snap.Hutao.ViewModel.Game"
|
||||
@@ -72,8 +73,9 @@
|
||||
IsEnabled="{Binding HutaoOptions.IsElevated}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<shvc:Elevation Margin="0,0,36,0" Visibility="{Binding HutaoOptions.IsElevated, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
||||
<ComboBox
|
||||
<shccs:ComboBox2
|
||||
DisplayMemberPath="DisplayName"
|
||||
EnableMemberPath="IsCompatOnly"
|
||||
ItemsSource="{Binding KnownSchemes}"
|
||||
SelectedItem="{Binding SelectedScheme, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Snap.Hutao.Control.Alternating;
|
||||
using Snap.Hutao.Control.Collection.Alternating;
|
||||
using Snap.Hutao.Model;
|
||||
using Snap.Hutao.Model.Intrinsic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
Reference in New Issue
Block a user