mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
improve cloud service experience
This commit is contained in:
@@ -41,15 +41,6 @@ internal sealed class SystemBackdrop
|
||||
appOptions.PropertyChanged += OnOptionsPropertyChanged;
|
||||
}
|
||||
|
||||
private void OnOptionsPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(AppOptions.BackdropType))
|
||||
{
|
||||
type = ((AppOptions)sender!).BackdropType;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试设置背景
|
||||
/// </summary>
|
||||
@@ -106,6 +97,15 @@ internal sealed class SystemBackdrop
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOptionsPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(AppOptions.BackdropType))
|
||||
{
|
||||
type = ((AppOptions)sender!).BackdropType;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWindowActivated(object sender, WindowActivatedEventArgs args)
|
||||
{
|
||||
configuration!.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<Identity
|
||||
Name="60568DGPStudio.SnapHutao"
|
||||
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
|
||||
Version="1.6.0.0" />
|
||||
Version="1.6.2.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Snap Hutao</DisplayName>
|
||||
|
||||
@@ -15,6 +15,7 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
private string? userName = SH.ViewServiceHutaoUserLoginOrRegisterHint;
|
||||
private string? token;
|
||||
private bool isLoggedIn;
|
||||
private bool isHutaoCloudServiceAllowed;
|
||||
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
@@ -36,6 +37,11 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
/// </summary>
|
||||
public bool IsLoggedIn { get => isLoggedIn; set => SetProperty(ref isLoggedIn, value); }
|
||||
|
||||
/// <summary>
|
||||
/// 胡桃云服务是否可用
|
||||
/// </summary>
|
||||
public bool IsCloudServiceAllowed { get => isHutaoCloudServiceAllowed; set => SetProperty(ref isHutaoCloudServiceAllowed, value); }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public HutaoUserOptions Value { get => this; }
|
||||
|
||||
|
||||
@@ -30,10 +30,7 @@ internal sealed class HutaoUserService : IHutaoUserService, IHutaoUserServiceIni
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
/// <returns>任务</returns>
|
||||
/// <inheritdoc/>
|
||||
public async ValueTask<bool> InitializeAsync()
|
||||
{
|
||||
await initializeCompletionSource.Task.ConfigureAwait(false);
|
||||
|
||||
@@ -8,4 +8,9 @@ namespace Snap.Hutao.Service.Hutao;
|
||||
/// </summary>
|
||||
internal interface IHutaoUserService : ICastableService
|
||||
{
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
/// <returns>任务</returns>
|
||||
ValueTask<bool> InitializeAsync();
|
||||
}
|
||||
@@ -283,36 +283,38 @@
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Spacing="{StaticResource SettingsCardSpacing}"
|
||||
Visibility="{Binding CultivateEntries.Count, Converter={StaticResource Int32ToVisibilityRevertConverter}}">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<clw:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationWikiAvatarDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewWikiAvatarHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Avatar.png}">
|
||||
<Button
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.WikiAvatarPage"
|
||||
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/>
|
||||
</clw:SettingsCard>
|
||||
<clw:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationWikiWeaponDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewWikiWeaponHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Weapon.png}">
|
||||
<Button
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.WikiWeaponPage"
|
||||
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/>
|
||||
</clw:SettingsCard>
|
||||
<clw:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationAvatarPropertyDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewAvatarPropertyHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_Icon_BoostUp.png}">
|
||||
<Button
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.AvatarPropertyPage"
|
||||
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/>
|
||||
</clw:SettingsCard>
|
||||
</StackPanel>
|
||||
<StackPanel.Resources>
|
||||
<Thickness x:Key="SettingsCardPadding">16</Thickness>
|
||||
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
|
||||
<x:Double x:Key="SettingsCardWrapNoIconThreshold">0</x:Double>
|
||||
<x:Double x:Key="SettingsCardMinHeight">0</x:Double>
|
||||
</StackPanel.Resources>
|
||||
<clw:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.WikiAvatarPage"
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationWikiAvatarDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewWikiAvatarHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Avatar.png}"
|
||||
IsClickEnabled="True"/>
|
||||
<clw:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.WikiWeaponPage"
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationWikiWeaponDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewWikiWeaponHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Weapon.png}"
|
||||
IsClickEnabled="True"/>
|
||||
<clw:SettingsCard
|
||||
ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
|
||||
Command="{Binding NavigateToPageCommand}"
|
||||
CommandParameter="Snap.Hutao.View.Page.AvatarPropertyPage"
|
||||
Description="{shcm:ResourceString Name=ViewPageCultivationAvatarPropertyDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewAvatarPropertyHeader}"
|
||||
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_Icon_BoostUp.png}"
|
||||
IsClickEnabled="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</PivotItem>
|
||||
|
||||
@@ -74,9 +74,8 @@
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding HutaoCloudViewModel.OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
<Grid Visibility="{Binding HutaoCloudViewModel.IsInitialized, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid Visibility="{Binding HutaoCloudViewModel.IsHutaoCloudServiceAllowed, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid Visibility="{Binding HutaoCloudViewModel.Options.IsCloudServiceAllowed, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid.Resources>
|
||||
<shc:BindingProxy x:Key="ViewModelBindingProxy" DataContext="{Binding}"/>
|
||||
<shc:BindingProxy x:Key="HutaoCloudViewModelBindingProxy" DataContext="{Binding HutaoCloudViewModel}"/>
|
||||
@@ -140,7 +139,7 @@
|
||||
CommandParameter="{Binding SelectedArchive}"
|
||||
Content="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudUpload}"/>
|
||||
</Grid>
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}" Visibility="{Binding HutaoCloudViewModel.IsHutaoCloudServiceAllowed, Converter={StaticResource BoolToVisibilityRevertConverter}}">
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}" Visibility="{Binding HutaoCloudViewModel.Options.IsCloudServiceAllowed, Converter={StaticResource BoolToVisibilityRevertConverter}}">
|
||||
<StackPanel.Resources>
|
||||
<Thickness x:Key="SettingsCardPadding">16</Thickness>
|
||||
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
|
||||
|
||||
@@ -8,6 +8,7 @@ using Snap.Hutao.Factory.Abstraction;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Service.Abstraction;
|
||||
using Snap.Hutao.Service.GachaLog;
|
||||
using Snap.Hutao.Service.Hutao;
|
||||
using Snap.Hutao.Service.Navigation;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -26,7 +27,6 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
private ObservableCollection<string>? uids;
|
||||
private bool isHutaoCloudServiceAllowed;
|
||||
|
||||
/// <summary>
|
||||
/// 构造一个新的胡桃云服务视图模型
|
||||
@@ -37,6 +37,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
|
||||
hutaoCloudService = serviceProvider.GetRequiredService<IHutaoCloudService>();
|
||||
contentDialogFactory = serviceProvider.GetRequiredService<IContentDialogFactory>();
|
||||
infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
|
||||
Options = serviceProvider.GetRequiredService<HutaoUserOptions>();
|
||||
this.serviceProvider = serviceProvider;
|
||||
|
||||
UploadCommand = new AsyncRelayCommand<GachaArchive>(UploadAsync);
|
||||
@@ -51,9 +52,9 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
|
||||
public ObservableCollection<string>? Uids { get => uids; set => SetProperty(ref uids, value); }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以使用胡桃云服务
|
||||
/// 选项
|
||||
/// </summary>
|
||||
public bool IsHutaoCloudServiceAllowed { get => isHutaoCloudServiceAllowed; set => SetProperty(ref isHutaoCloudServiceAllowed, value); }
|
||||
public HutaoUserOptions Options { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 上传记录命令
|
||||
@@ -95,6 +96,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
|
||||
/// <inheritdoc/>
|
||||
protected override async Task OpenUIAsync()
|
||||
{
|
||||
await serviceProvider.GetRequiredService<IHutaoUserService>().InitializeAsync().ConfigureAwait(false);
|
||||
await RefreshUidCollectionAsync().ConfigureAwait(false);
|
||||
await ThreadHelper.SwitchToMainThreadAsync();
|
||||
IsInitialized = true;
|
||||
@@ -151,8 +153,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
|
||||
Response<List<string>> resp = await hutaoCloudService.GetUidsAsync().ConfigureAwait(false);
|
||||
|
||||
await ThreadHelper.SwitchToMainThreadAsync();
|
||||
IsHutaoCloudServiceAllowed = resp.IsOk();
|
||||
if (IsHutaoCloudServiceAllowed)
|
||||
if (Options.IsCloudServiceAllowed = resp.IsOk())
|
||||
{
|
||||
Uids = resp.Data!.ToObservableCollection();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user