新增MES模块,包含供应商、客户、车辆和地磅数据记录管理功能,支持免密接口和数据同步。更新相关控制器、实体、服务和数据库配置,优化权限管理和数据字典支持,确保系统的灵活性和可扩展性。
This commit is contained in:
@@ -10,6 +10,7 @@ using YY.Admin.Core.Const;
|
||||
using YY.Admin.Core.EventBus;
|
||||
using YY.Admin.Core.Session;
|
||||
using YY.Admin.Services.Service.Auth;
|
||||
using YY.Admin.Services.Service.Config;
|
||||
using YY.Admin.Views;
|
||||
|
||||
namespace YY.Admin.ViewModels
|
||||
@@ -87,15 +88,58 @@ namespace YY.Admin.ViewModels
|
||||
}
|
||||
|
||||
#region 用户操作
|
||||
/// <summary>
|
||||
/// 从系统配置应用登录状态检查间隔(分钟)
|
||||
/// </summary>
|
||||
private static void ApplyTokenCheckIntervalFromConfig()
|
||||
{
|
||||
var minutes = 1;
|
||||
try
|
||||
{
|
||||
var cfg = Prism.Ioc.ContainerLocator.Current.Resolve<ISysConfigService>();
|
||||
var v = cfg.GetConfigValue<int>(ConfigConst.SysTokenCheckIntervalMinutes).GetAwaiter().GetResult();
|
||||
if (v >= 1 && v <= 120)
|
||||
minutes = v;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 使用默认 1 分钟
|
||||
}
|
||||
|
||||
if (_tokenCheckTimer != null)
|
||||
_tokenCheckTimer.Interval = TimeSpan.FromMinutes(minutes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启登录永不过期
|
||||
/// </summary>
|
||||
private static bool IsTokenNeverExpireEnabled()
|
||||
{
|
||||
try
|
||||
{
|
||||
var cfg = Prism.Ioc.ContainerLocator.Current.Resolve<ISysConfigService>();
|
||||
return cfg.GetConfigValue<bool>(ConfigConst.SysTokenNeverExpire).GetAwaiter().GetResult();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录设置保存后刷新检查间隔(已启动定时器时立即生效)
|
||||
/// </summary>
|
||||
public static void RefreshTokenCheckIntervalFromConfig()
|
||||
{
|
||||
ApplyTokenCheckIntervalFromConfig();
|
||||
}
|
||||
|
||||
// 启动定时器的方法
|
||||
public static void StartTokenCheckTimer()
|
||||
{
|
||||
if (_tokenCheckTimer == null)
|
||||
{
|
||||
_tokenCheckTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMinutes(1)
|
||||
};
|
||||
_tokenCheckTimer = new DispatcherTimer();
|
||||
_tokenCheckTimer.Tick += CheckTokenExpiration;
|
||||
|
||||
// 捕获全局用户输入事件
|
||||
@@ -107,6 +151,8 @@ namespace YY.Admin.ViewModels
|
||||
new KeyEventHandler(OnUserActivity));
|
||||
}
|
||||
|
||||
ApplyTokenCheckIntervalFromConfig();
|
||||
|
||||
if (!_tokenCheckTimer.IsEnabled)
|
||||
{
|
||||
_tokenCheckTimer.Start();
|
||||
@@ -124,6 +170,8 @@ namespace YY.Admin.ViewModels
|
||||
|
||||
private static void OnUserActivity(object sender, EventArgs e)
|
||||
{
|
||||
if (IsTokenNeverExpireEnabled())
|
||||
return;
|
||||
var authService = ContainerLocator.Current.Resolve<ISysAuthService>();
|
||||
authService.RefreshToken(UserContext?.Token?.AccessToken);
|
||||
}
|
||||
@@ -146,6 +194,9 @@ namespace YY.Admin.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsTokenNeverExpireEnabled())
|
||||
return;
|
||||
|
||||
var authService = ContainerLocator.Current.Resolve<ISysAuthService>();
|
||||
if (!authService.ValidateToken(UserContext.Token.AccessToken))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user