1
This commit is contained in:
1 parent
3135189ea3
commit
a003d90b0e
21 files changed
+754
-145
No files matched your search
@@ -3,6 +3,7 @@ using NLog;
|
||||
using Prism.Autofac;
|
||||
using Prism.Ioc;
|
||||
using Prism.Services.Dialogs;
|
||||
using Store.Management.Api;
|
||||
using Store.Management.Framework.Configs;
|
||||
using Store.Management.Framework.Extensions;
|
||||
using Store.Management.Framework.Services;
|
||||
@@ -131,7 +132,11 @@ public abstract class FrameworkApplication : PrismApplication
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
ShuttingDown = true;
|
||||
try { base.OnExit(e); }
|
||||
try
|
||||
{
|
||||
try { Container?.Resolve<StoreApiClient>().Dispose(); }
|
||||
finally { base.OnExit(e); }
|
||||
}
|
||||
finally
|
||||
{
|
||||
DispatcherUnhandledException -= OnDispatcherUnhandledException;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
xmlns:f="clr-namespace:Store.Management.Framework.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MAX.Common.WPF;component/Resources/Generic.xaml" />
|
||||
|
||||
<ResourceDictionary Source="/Store.Management.Framework;component/Controls/DataGridEx/DataGridEx.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using Store.Management.Api;
|
||||
using Store.Management.Api.Authentication;
|
||||
|
||||
namespace Store.Management.Framework.Services;
|
||||
|
||||
/// <summary>用户登录服务,复用应用 API 客户端的认证会话。</summary>
|
||||
public interface ILoginService
|
||||
{
|
||||
/// <summary>提交登录;passwordHash 为 UTF-8 密码的 32 位大写 MD5。</summary>
|
||||
Task LoginAsync(string userName, string passwordHash, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
internal sealed class LoginService(StoreApiClient apiClient) : ILoginService, ISingletonDependency
|
||||
{
|
||||
public Task LoginAsync(string userName, string passwordHash, CancellationToken cancellationToken = default)
|
||||
=> apiClient.Auth.LoginAsync(new LoginRequest
|
||||
{
|
||||
UserName = userName.Trim(),
|
||||
Password = passwordHash
|
||||
}, cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Autofac;
|
||||
using MAX.Common.WPF.Converters;
|
||||
using MAX.Common.WPF.Utilities;
|
||||
using MAX.Core;
|
||||
using MAX.Framework.Interfaces;
|
||||
using Store.Management.Api;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Management.Framework
|
||||
{
|
||||
internal class Startup : IStartup
|
||||
{
|
||||
public int Priority => IntPriority.High;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
EnumDisplayConverter.EnumDisplayManager = new EnumDisplayManagerWPF(null);
|
||||
}
|
||||
|
||||
public void Register(ContainerBuilder builder)
|
||||
{
|
||||
var client = new StoreApiClient(new ApiClientOptions
|
||||
{
|
||||
BaseUrl = new Uri("http://localhost:14312/api/")
|
||||
});
|
||||
builder.Register(_ => client).SingleInstance().PreserveExistingDefaults();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HandyControl" Version="3.6.2.1" />
|
||||
<PackageReference Include="MAX.Common.WPF" Version="1.4.23" />
|
||||
<ProjectReference Include="..\Store.Management.Api\Store.Management.Api.csproj" />
|
||||
<ProjectReference Include="..\Core\MAX.Core\MAX.Core.csproj" />
|
||||
<ProjectReference Include="..\Core\MAX.Framework\MAX.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in new issue
Block a user