improve cloud service experience

This commit is contained in:
Lightczx
2023-04-08 22:09:07 +08:00
parent a4f555ea40
commit e5c5c1c95c
8 changed files with 61 additions and 51 deletions

View File

@@ -41,15 +41,6 @@ internal sealed class SystemBackdrop
appOptions.PropertyChanged += OnOptionsPropertyChanged; appOptions.PropertyChanged += OnOptionsPropertyChanged;
} }
private void OnOptionsPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(AppOptions.BackdropType))
{
type = ((AppOptions)sender!).BackdropType;
Update();
}
}
/// <summary> /// <summary>
/// 尝试设置背景 /// 尝试设置背景
/// </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) private void OnWindowActivated(object sender, WindowActivatedEventArgs args)
{ {
configuration!.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated; configuration!.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated;

View File

@@ -12,7 +12,7 @@
<Identity <Identity
Name="60568DGPStudio.SnapHutao" Name="60568DGPStudio.SnapHutao"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52" Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.6.0.0" /> Version="1.6.2.0" />
<Properties> <Properties>
<DisplayName>Snap Hutao</DisplayName> <DisplayName>Snap Hutao</DisplayName>

View File

@@ -15,6 +15,7 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
private string? userName = SH.ViewServiceHutaoUserLoginOrRegisterHint; private string? userName = SH.ViewServiceHutaoUserLoginOrRegisterHint;
private string? token; private string? token;
private bool isLoggedIn; private bool isLoggedIn;
private bool isHutaoCloudServiceAllowed;
/// <summary> /// <summary>
/// 用户名 /// 用户名
@@ -36,6 +37,11 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
/// </summary> /// </summary>
public bool IsLoggedIn { get => isLoggedIn; set => SetProperty(ref isLoggedIn, value); } public bool IsLoggedIn { get => isLoggedIn; set => SetProperty(ref isLoggedIn, value); }
/// <summary>
/// 胡桃云服务是否可用
/// </summary>
public bool IsCloudServiceAllowed { get => isHutaoCloudServiceAllowed; set => SetProperty(ref isHutaoCloudServiceAllowed, value); }
/// <inheritdoc/> /// <inheritdoc/>
public HutaoUserOptions Value { get => this; } public HutaoUserOptions Value { get => this; }

View File

@@ -30,10 +30,7 @@ internal sealed class HutaoUserService : IHutaoUserService, IHutaoUserServiceIni
this.options = options; this.options = options;
} }
/// <summary> /// <inheritdoc/>
/// 异步初始化
/// </summary>
/// <returns>任务</returns>
public async ValueTask<bool> InitializeAsync() public async ValueTask<bool> InitializeAsync()
{ {
await initializeCompletionSource.Task.ConfigureAwait(false); await initializeCompletionSource.Task.ConfigureAwait(false);

View File

@@ -8,4 +8,9 @@ namespace Snap.Hutao.Service.Hutao;
/// </summary> /// </summary>
internal interface IHutaoUserService : ICastableService internal interface IHutaoUserService : ICastableService
{ {
/// <summary>
/// 异步初始化
/// </summary>
/// <returns>任务</returns>
ValueTask<bool> InitializeAsync();
} }

View File

@@ -283,36 +283,38 @@
<StackPanel <StackPanel
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Spacing="{StaticResource SettingsCardSpacing}"
Visibility="{Binding CultivateEntries.Count, Converter={StaticResource Int32ToVisibilityRevertConverter}}"> Visibility="{Binding CultivateEntries.Count, Converter={StaticResource Int32ToVisibilityRevertConverter}}">
<StackPanel HorizontalAlignment="Center"> <StackPanel.Resources>
<clw:SettingsCard <Thickness x:Key="SettingsCardPadding">16</Thickness>
Description="{shcm:ResourceString Name=ViewPageCultivationWikiAvatarDescription}" <x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
Header="{shcm:ResourceString Name=ViewWikiAvatarHeader}" <x:Double x:Key="SettingsCardWrapNoIconThreshold">0</x:Double>
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Avatar.png}"> <x:Double x:Key="SettingsCardMinHeight">0</x:Double>
<Button </StackPanel.Resources>
Command="{Binding NavigateToPageCommand}" <clw:SettingsCard
CommandParameter="Snap.Hutao.View.Page.WikiAvatarPage" ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/> Command="{Binding NavigateToPageCommand}"
</clw:SettingsCard> CommandParameter="Snap.Hutao.View.Page.WikiAvatarPage"
<clw:SettingsCard Description="{shcm:ResourceString Name=ViewPageCultivationWikiAvatarDescription}"
Description="{shcm:ResourceString Name=ViewPageCultivationWikiWeaponDescription}" Header="{shcm:ResourceString Name=ViewWikiAvatarHeader}"
Header="{shcm:ResourceString Name=ViewWikiWeaponHeader}" HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Avatar.png}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Weapon.png}"> IsClickEnabled="True"/>
<Button <clw:SettingsCard
Command="{Binding NavigateToPageCommand}" ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
CommandParameter="Snap.Hutao.View.Page.WikiWeaponPage" Command="{Binding NavigateToPageCommand}"
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/> CommandParameter="Snap.Hutao.View.Page.WikiWeaponPage"
</clw:SettingsCard> Description="{shcm:ResourceString Name=ViewPageCultivationWikiWeaponDescription}"
<clw:SettingsCard Header="{shcm:ResourceString Name=ViewWikiWeaponHeader}"
Description="{shcm:ResourceString Name=ViewPageCultivationAvatarPropertyDescription}" HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_BagTabIcon_Weapon.png}"
Header="{shcm:ResourceString Name=ViewAvatarPropertyHeader}" IsClickEnabled="True"/>
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_Icon_BoostUp.png}"> <clw:SettingsCard
<Button ActionIconToolTip="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"
Command="{Binding NavigateToPageCommand}" Command="{Binding NavigateToPageCommand}"
CommandParameter="Snap.Hutao.View.Page.AvatarPropertyPage" CommandParameter="Snap.Hutao.View.Page.AvatarPropertyPage"
Content="{shcm:ResourceString Name=ViewPageCultivationNavigateAction}"/> Description="{shcm:ResourceString Name=ViewPageCultivationAvatarPropertyDescription}"
</clw:SettingsCard> Header="{shcm:ResourceString Name=ViewAvatarPropertyHeader}"
</StackPanel> HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Icon/UI_Icon_BoostUp.png}"
IsClickEnabled="True"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</PivotItem> </PivotItem>

View File

@@ -74,9 +74,8 @@
<mxi:Interaction.Behaviors> <mxi:Interaction.Behaviors>
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding HutaoCloudViewModel.OpenUICommand}"/> <shcb:InvokeCommandOnLoadedBehavior Command="{Binding HutaoCloudViewModel.OpenUICommand}"/>
</mxi:Interaction.Behaviors> </mxi:Interaction.Behaviors>
<Grid Visibility="{Binding HutaoCloudViewModel.IsInitialized, Converter={StaticResource BoolToVisibilityConverter}}"> <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> <Grid.Resources>
<shc:BindingProxy x:Key="ViewModelBindingProxy" DataContext="{Binding}"/> <shc:BindingProxy x:Key="ViewModelBindingProxy" DataContext="{Binding}"/>
<shc:BindingProxy x:Key="HutaoCloudViewModelBindingProxy" DataContext="{Binding HutaoCloudViewModel}"/> <shc:BindingProxy x:Key="HutaoCloudViewModelBindingProxy" DataContext="{Binding HutaoCloudViewModel}"/>
@@ -140,7 +139,7 @@
CommandParameter="{Binding SelectedArchive}" CommandParameter="{Binding SelectedArchive}"
Content="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudUpload}"/> Content="{shcm:ResourceString Name=ViewPageGachaLogHutaoCloudUpload}"/>
</Grid> </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> <StackPanel.Resources>
<Thickness x:Key="SettingsCardPadding">16</Thickness> <Thickness x:Key="SettingsCardPadding">16</Thickness>
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double> <x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>

View File

@@ -8,6 +8,7 @@ using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model.Entity; using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Abstraction; using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.GachaLog; using Snap.Hutao.Service.GachaLog;
using Snap.Hutao.Service.Hutao;
using Snap.Hutao.Service.Navigation; using Snap.Hutao.Service.Navigation;
using Snap.Hutao.Web.Response; using Snap.Hutao.Web.Response;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -26,7 +27,6 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
private readonly IServiceProvider serviceProvider; private readonly IServiceProvider serviceProvider;
private ObservableCollection<string>? uids; private ObservableCollection<string>? uids;
private bool isHutaoCloudServiceAllowed;
/// <summary> /// <summary>
/// 构造一个新的胡桃云服务视图模型 /// 构造一个新的胡桃云服务视图模型
@@ -37,6 +37,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
hutaoCloudService = serviceProvider.GetRequiredService<IHutaoCloudService>(); hutaoCloudService = serviceProvider.GetRequiredService<IHutaoCloudService>();
contentDialogFactory = serviceProvider.GetRequiredService<IContentDialogFactory>(); contentDialogFactory = serviceProvider.GetRequiredService<IContentDialogFactory>();
infoBarService = serviceProvider.GetRequiredService<IInfoBarService>(); infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
Options = serviceProvider.GetRequiredService<HutaoUserOptions>();
this.serviceProvider = serviceProvider; this.serviceProvider = serviceProvider;
UploadCommand = new AsyncRelayCommand<GachaArchive>(UploadAsync); 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); } public ObservableCollection<string>? Uids { get => uids; set => SetProperty(ref uids, value); }
/// <summary> /// <summary>
/// 是否可以使用胡桃云服务 /// 选项
/// </summary> /// </summary>
public bool IsHutaoCloudServiceAllowed { get => isHutaoCloudServiceAllowed; set => SetProperty(ref isHutaoCloudServiceAllowed, value); } public HutaoUserOptions Options { get; }
/// <summary> /// <summary>
/// 上传记录命令 /// 上传记录命令
@@ -95,6 +96,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
/// <inheritdoc/> /// <inheritdoc/>
protected override async Task OpenUIAsync() protected override async Task OpenUIAsync()
{ {
await serviceProvider.GetRequiredService<IHutaoUserService>().InitializeAsync().ConfigureAwait(false);
await RefreshUidCollectionAsync().ConfigureAwait(false); await RefreshUidCollectionAsync().ConfigureAwait(false);
await ThreadHelper.SwitchToMainThreadAsync(); await ThreadHelper.SwitchToMainThreadAsync();
IsInitialized = true; IsInitialized = true;
@@ -151,8 +153,7 @@ internal sealed class HutaoCloudViewModel : Abstraction.ViewModel
Response<List<string>> resp = await hutaoCloudService.GetUidsAsync().ConfigureAwait(false); Response<List<string>> resp = await hutaoCloudService.GetUidsAsync().ConfigureAwait(false);
await ThreadHelper.SwitchToMainThreadAsync(); await ThreadHelper.SwitchToMainThreadAsync();
IsHutaoCloudServiceAllowed = resp.IsOk(); if (Options.IsCloudServiceAllowed = resp.IsOk())
if (IsHutaoCloudServiceAllowed)
{ {
Uids = resp.Data!.ToObservableCollection(); Uids = resp.Data!.ToObservableCollection();
} }