feat: 完成个人中心默认应用设置

This commit is contained in:
Argo-Tianyi 2022-01-12 13:18:34 +08:00
parent e79b2d3007
commit 92f615c730
3 changed files with 23 additions and 1 deletions

View File

@ -234,4 +234,10 @@ class UserService : BaseDatabase, IUser
}
return ret;
}
public bool SaveApp(string userName, string app)
{
Database.Update<User>("Set App = @1 Where UserName = @0", userName, app);
return true;
}
}

View File

@ -71,6 +71,13 @@ public interface IUser
/// <returns></returns>
List<User> GetAll();
/// <summary>
/// 保存指定用户的默认 App
/// </summary>
/// <param name="userName"></param>
/// <param name="app"></param>
bool SaveApp(string userName, string app);
/// <summary>
/// 认证方法
/// </summary>

View File

@ -33,6 +33,10 @@ public partial class Profiles
[NotNull]
private IDict? DictService { get; set; }
[Inject]
[NotNull]
private IUser? UserService { get; set; }
private List<UploadFile> PreviewFileList { get; } = new(new[] { new UploadFile { PrevUrl = "/images/Argo.png" } });
/// <summary>
@ -42,9 +46,10 @@ public partial class Profiles
{
base.OnInitialized();
var user = UserService.GetUserByUserName(AppContext.UserName);
CurrentUser = new User()
{
App = AppContext.AppId,
App = user?.App ?? AppContext.AppId,
UserName = AppContext.UserName,
DisplayName = AppContext.DisplayName
};
@ -65,6 +70,10 @@ public partial class Profiles
private Task OnSaveApp()
{
if (CurrentUser.App != null)
{
UserService.SaveApp(AppContext.UserName, CurrentUser.App);
}
return Task.CompletedTask;
}