Skip to content

Commit

Permalink
Check In
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Jul 14, 2022
1 parent 25c0daa commit f7e5419
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 65 deletions.
24 changes: 15 additions & 9 deletions src/ST.Client.Desktop.Avalonia/Application/UI/App.axaml.cs
Expand Up @@ -115,11 +115,13 @@ public void SetThemeNotChangeValue(AppTheme value)
case AppTheme.Light:
themeName = FluentAvaloniaTheme.LightModeString;
//mode = FluentThemeMode.Light;
//LiveCharts.CurrentSettings.AddLightTheme();
break;
case AppTheme.Dark:
default:
themeName = FluentAvaloniaTheme.DarkModeString;
//mode = FluentThemeMode.Dark;
//LiveCharts.CurrentSettings.AddDarkTheme();
break;
}

Expand Down Expand Up @@ -231,20 +233,24 @@ public override void Initialize()
}, isTrace: isTrace);

LiveCharts.Configure(config =>
{
config
// registers SkiaSharp as the library backend
// REQUIRED unless you build your own
.AddSkiaSharp()
// adds the default supported types
// OPTIONAL but highly recommend
//.AddDefaultMappers()
.AddSkiaSharp();
// adds the default supported types
// OPTIONAL but highly recommend
//.AddDefaultMappers()
// select a theme, default is Light
// OPTIONAL
//.AddDarkTheme()
.AddDarkTheme());
// select a theme, default is Light
// OPTIONAL
//.AddDarkTheme()
if (Theme == AppTheme.Light)
config.AddLightTheme();
else
config.AddDarkTheme();
});
#if WINDOWS
InitWebView2();
#endif
Expand Down
Expand Up @@ -45,7 +45,7 @@
<TextBlock Text="{ReflectionBinding Path=User.NickName,Mode=OneWay,Source={x:Static service:UserService.Current}}"
Classes="h3"/>
<StackPanel Orientation="Horizontal" Spacing="10">
<TextBlock Text="{ReflectionBinding Path=User.LevelStr,Mode=OneWay,Source={x:Static service:UserService.Current}}"
<TextBlock Text="{ReflectionBinding Path=User.Level,Mode=OneWay,Source={x:Static service:UserService.Current},StringFormat={}Lv.{0}}"
Classes="h8"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
Expand Down
Expand Up @@ -63,17 +63,36 @@
Classes="h8"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>-->
<Button Margin="5 0" FontSize="10">
<Button Margin="5 0"
FontSize="10">
<ToolTip.Tip>
<MultiBinding StringFormat="{}{0} : {1} / {2}">
<Binding Path="Res.User_Experience"
Source="{x:Static resx:R.Current}" />
<Binding Path="User.Experience"
Source="{x:Static service:UserService.Current}" />
<Binding Path="User.NextExperience"
Source="{x:Static service:UserService.Current}" />
</MultiBinding>
</ToolTip.Tip>
<Button.Content>
<MultiBinding StringFormat="{}{0} : {1}">
<MultiBinding StringFormat="{}{0} : Lv.{1}">
<Binding Path="Res.User_Level"
Source="{x:Static resx:R.Current}" />
<Binding Path="User.LevelStr"
<Binding Path="User.Level"
Source="{x:Static service:UserService.Current}" />
</MultiBinding>
</Button.Content>
</Button>
<Button Margin="5 0" FontSize="10">
<Button Margin="5 0"
FontSize="10"
IsVisible="{ReflectionBinding Path=!User.IsSignIn,Mode=OneWay,Source={x:Static service:UserService.Current}}"
Content="{ReflectionBinding Path=Res.Sign,Mode=OneWay,Source={x:Static resx:R.Current}}"
Command="{ReflectionBinding Path=SignIn,Mode=OneWay,Source={x:Static service:UserService.Current}}"/>
<Button Margin="5 0"
FontSize="10"
IsVisible="{ReflectionBinding Path=User.IsSignIn,Mode=OneWay,Source={x:Static service:UserService.Current}}"
ToolTip.Tip="{ReflectionBinding Path=Res.Signed,Mode=OneWay,Source={x:Static resx:R.Current}}">
<Button.Content>
<MultiBinding StringFormat="{}{0} : {1}">
<Binding Path="Res.User_EngineOil"
Expand All @@ -88,8 +107,12 @@
<ItemsControl Grid.Row="3">
<!--<ui:Button Content="{ReflectionBinding Path=Res.RefreshAvatar,Mode=OneWay,Source={x:Static resx:R.Current}}"
Command="{ReflectionBinding Path=RefreshUserAvatarAsync,Source={x:Static service:UserService.Current}}"/>-->
<!--<ui:Button Content="{ReflectionBinding Path=Res.UserProfile,Mode=OneWay,Source={x:Static resx:R.Current}}"
Command="{ReflectionBinding Path=NavigateUserCenterPage,Source={x:Static service:UserService.Current}}"/>-->
<ui:Button Content="{ReflectionBinding Path=Res.UserProfile,Mode=OneWay,Source={x:Static resx:R.Current}}"
Command="{ReflectionBinding Path=NavigateUserCenterPage,Source={x:Static service:UserService.Current}}"/>
Command="{ReflectionBinding Path=ShowWindow,Source={x:Static service:UserService.Current}}"
HorizontalContentAlignment="Stretch"
CommandParameter="UserProfile"/>
<ui:Button Command="{ReflectionBinding Path=ShowWindow,Source={x:Static service:UserService.Current}}"
HorizontalContentAlignment="Stretch"
CommandParameter="Notice">
Expand Down
52 changes: 34 additions & 18 deletions src/ST.Client/Services/Mvvm/UserService.cs
@@ -1,4 +1,5 @@
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.Application.Models;
using System.Application.UI;
using System.Application.UI.Resx;
Expand Down Expand Up @@ -89,9 +90,34 @@ public async void SignOut()
}
}

public async Task<IApiResponse<ClockInResponse>> SignIn()
public async Task SignIn()
{
return await csc.AccountClockIn();
if (User == null)
{
return;
}
if (User.IsSignIn == false)
{
var state = await csc.AccountClockIn();
if (state.IsSuccess)
{
User.Experience = state.Content!.Experience;
User.NextExperience = state.Content!.NextExperience;
User.Level = state.Content!.Level;
User.EngineOil = state.Content!.Strength;
User.IsSignIn = true;
//_ = Task.Run(async () =>
//{
// await Task.Delay(DateTime.Now.Date.AddDays(1).Subtract(DateTime.Now));
// IsSignedIn = false;
//});
Toast.Show(AppResources.User_SignIn_Ok);
}
else
{
Toast.Show(state.Message);
}
}
}

public async Task DelAccountAsync()
Expand All @@ -106,26 +132,16 @@ public async Task SignOutUserManagerAsync()
await userManager.SignOutAsync();
}

UserInfoDTO? _User;

public UserInfoDTO? User
{
get => _User;
set => this.RaiseAndSetIfChanged(ref _User, value);
}
[Reactive]
public UserInfoDTO? User { get; set; }

/// <summary>
/// 指示当前用户是否已通过身份验证(已登录)
/// </summary>
public bool IsAuthenticated => User != null;

SteamUser? _SteamUser;

public SteamUser? CurrentSteamUser
{
get => _SteamUser;
set => this.RaiseAndSetIfChanged(ref _SteamUser, value);
}
[Reactive]
public SteamUser? CurrentSteamUser { get; set; }

object? _AvatarPath;

Expand Down Expand Up @@ -204,13 +220,13 @@ public async Task RefreshUserAsync(UserInfoDTO? user, bool refreshCurrentUser =
User = user;
this.RaisePropertyChanged(nameof(IsAuthenticated));

await RefreshUserAvatarAsync();

if (refreshCurrentUser)
{
var currentUser = await userManager.GetCurrentUserAsync();
RefreshCurrentUser(currentUser);
}

await RefreshUserAvatarAsync();
}

public async Task RefreshUserAsync(bool refreshCurrentUser = true)
Expand Down
36 changes: 27 additions & 9 deletions src/ST.Client/UI/Resx/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/ST.Client/UI/Resx/AppResources.resx
Expand Up @@ -2112,7 +2112,7 @@ AAAAA-BBBBB-CCCC3</value>
<data name="User_Sponsor" xml:space="preserve">
<value>赞助用户</value>
</data>
<data name="Account_SignIn_Ok" xml:space="preserve">
<data name="User_SignIn_Ok" xml:space="preserve">
<value>签到成功</value>
</data>
<data name="Save" xml:space="preserve">
Expand Down Expand Up @@ -2320,6 +2320,9 @@ AAAAA-BBBBB-CCCC3</value>
<data name="Sign" xml:space="preserve">
<value>签到</value>
</data>
<data name="Signed" xml:space="preserve">
<value>已签到</value>
</data>
<data name="UploadFlow" xml:space="preserve">
<value>上行流量</value>
</data>
Expand All @@ -2344,4 +2347,7 @@ AAAAA-BBBBB-CCCC3</value>
<data name="User_Level" xml:space="preserve">
<value>等级</value>
</data>
<data name="User_Experience" xml:space="preserve">
<value>经验值</value>
</data>
</root>
Expand Up @@ -45,16 +45,7 @@ public AccountPageViewModel()
});
SignIn = ReactiveCommand.CreateFromTask(async () =>
{
var state = await UserService.Current.SignIn();
if (state.IsSuccess)
{
UserService.Current.User!.Experience = state.Content!.Experience;
Toast.Show(AppResources.Account_SignIn_Ok);
}
else
{
Toast.Show(state.Message);
}
await UserService.Current.SignIn();
});
RefreshButton = ReactiveCommand.CreateFromTask(async () =>
{
Expand Down
35 changes: 23 additions & 12 deletions src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs
@@ -1,5 +1,6 @@
#if MVVM_VM
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.Application;
#endif
using System.Application.Columns;
Expand Down Expand Up @@ -58,6 +59,9 @@ public string NickName
[MPKey(3)]
[N_JsonProperty("3")]
[S_JsonProperty("3")]
#if MVVM_VM
[Reactive]
#endif
public uint Experience { get; set; }

/// <summary>
Expand Down Expand Up @@ -90,20 +94,10 @@ public string NickName
[MPKey(7)]
[N_JsonProperty("7")]
[S_JsonProperty("7")]
public byte Level { get; set; }

#if MVVM_VM
[MPIgnore]
[N_JsonIgnore]
[S_JsonIgnore]
public string LevelStr
{
get
{
return $"Lv.{Level}";
}
}
[Reactive]
#endif
public byte Level { get; set; }

[MPKey(8)]
[N_JsonProperty("8")]
Expand Down Expand Up @@ -251,6 +245,9 @@ public string Age
[MPKey(19)]
[N_JsonProperty("19")]
[S_JsonProperty("19")]
#if MVVM_VM
[Reactive]
#endif
public UserType UserType { get; set; }

/// <summary>
Expand All @@ -259,6 +256,20 @@ public string Age
[MPKey(20)]
[N_JsonProperty("20")]
[S_JsonProperty("20")]
#if MVVM_VM
[Reactive]
#endif
public uint NextExperience { get; set; }

/// <summary>
/// 是否签到
/// </summary>
[MPKey(21)]
[N_JsonProperty("21")]
[S_JsonProperty("21")]
#if MVVM_VM
[Reactive]
#endif
public bool IsSignIn { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/ST.Services.CloudService.ViewModels/FodyWeavers.xml
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ReactiveUI />
</Weavers>

0 comments on commit f7e5419

Please sign in to comment.