|
@@ -5,7 +5,7 @@ using Vinno.IDS.ProjectManagement.Protocol.Emums.SystemConfigEnums;
|
|
|
|
|
|
namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
{
|
|
|
- public partial class MainLayout
|
|
|
+ public partial class MainLayout: IDisposable
|
|
|
{
|
|
|
private string _token;
|
|
|
private string _language;
|
|
@@ -16,15 +16,12 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
private UserInfoVO _userInfo;
|
|
|
private Dictionary<string, string> LanguageDictionary { get; set; } = new Dictionary<string, string>();
|
|
|
private string _modifyPw = "";
|
|
|
- //private string _systemTitle = "";
|
|
|
- //private string _welcomeLogin = "";
|
|
|
- //private string _currentLoginAccount = "";
|
|
|
|
|
|
private bool _initialized;
|
|
|
|
|
|
private ModifyPassword _modifyPassword;
|
|
|
|
|
|
- private System.Threading.Timer timer;
|
|
|
+ private System.Threading.Timer _timer;
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
{
|
|
@@ -33,10 +30,6 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
|
|
|
if (_token == null || _userInfo == null)
|
|
|
{
|
|
|
- //await ProjectMessageHelper.MessageWarningAsync("请重新登录");
|
|
|
-
|
|
|
- //await LocalService.RemoveItem<string>(ProjectStorageEnum.ProjectToken);
|
|
|
- //await LocalService.RemoveItem<UserInfoVO>(ProjectStorageEnum.ProjectUser);
|
|
|
NavigationManager.NavigateTo("/login");
|
|
|
}
|
|
|
else
|
|
@@ -55,13 +48,7 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
|
|
|
}
|
|
|
|
|
|
- _initialized = true;
|
|
|
-
|
|
|
- await Task.Run(() =>
|
|
|
- {
|
|
|
- timer = new System.Threading.Timer(AuthToken, null, 0, 300000);
|
|
|
- });
|
|
|
-
|
|
|
+ _initialized = true;
|
|
|
}
|
|
|
|
|
|
private async void AuthToken(object? state)
|
|
@@ -74,6 +61,8 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
var isTrue = await BPAccountManager.TokenHealthCheckAsync(tokenDTO);
|
|
|
if (!isTrue.Data)
|
|
|
{
|
|
|
+ _timer.Dispose();
|
|
|
+ _timer = null;
|
|
|
await LocalService.RemoveItem<string>(ProjectStorageEnum.ProjectToken);
|
|
|
await LocalService.RemoveItem<UserInfoVO>(ProjectStorageEnum.ProjectUser);
|
|
|
await LocalService.RemoveItem<List<string>>(ProjectStorageEnum.ProjectMenuBtnAuth);
|
|
@@ -82,12 +71,6 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Dispose()
|
|
|
- {
|
|
|
- // 释放计时器
|
|
|
- timer?.Dispose();
|
|
|
- }
|
|
|
-
|
|
|
protected override async Task OnParametersSetAsync()
|
|
|
{
|
|
|
if (_initialized)
|
|
@@ -105,9 +88,6 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
_nameUrl = "/images/man.png";
|
|
|
_languageLogout = LanguageDictionary.ContainsKey("Logout") ? LanguageDictionary["Logout"] : "Logout";
|
|
|
_modifyPw = LanguageDictionary.ContainsKey("ModifyPassWord") ? LanguageDictionary["ModifyPassWord"] : "ModifyPassWord";
|
|
|
- //_systemTitle = LanguageDictionary.ContainsKey("SystemTitle") ? LanguageDictionary["SystemTitle"] : "SystemTitle";
|
|
|
- //_welcomeLogin = LanguageDictionary.ContainsKey("WelcomeLogin") ? LanguageDictionary["WelcomeLogin"] : "WelcomeLogin";
|
|
|
- //_currentLoginAccount = LanguageDictionary.ContainsKey("CurrentLoginAccount") ? LanguageDictionary["CurrentLoginAccount"] : "CurrentLoginAccount";
|
|
|
|
|
|
if (_languageLogout == "注销")
|
|
|
{
|
|
@@ -127,6 +107,11 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
{
|
|
|
_slideItems = new List<MenuItem>();
|
|
|
}
|
|
|
+
|
|
|
+ if (_timer == null)
|
|
|
+ {
|
|
|
+ _timer = new System.Threading.Timer(AuthToken, null, 0, 10000);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -139,17 +124,25 @@ namespace Vinno.IDS.ProjectManagement.Shared
|
|
|
|
|
|
private async Task Logout()
|
|
|
{
|
|
|
- // var token = await LocalService.GetItem<string>(SpecStorageEnum.SpecToken);
|
|
|
- // var res = await LoginManager.LogoutAsync(token);
|
|
|
- // if (res.Data)
|
|
|
- // {
|
|
|
+ if (_timer != null)
|
|
|
+ {
|
|
|
+ _timer.Dispose();
|
|
|
+ _timer = null;
|
|
|
+ }
|
|
|
await LocalService.RemoveItem<string>(ProjectStorageEnum.ProjectToken);
|
|
|
await LocalService.RemoveItem<UserInfoVO>(ProjectStorageEnum.ProjectUser);
|
|
|
await LocalService.RemoveItem<List<string>>(ProjectStorageEnum.ProjectMenuBtnAuth);
|
|
|
StateHasChanged();
|
|
|
- NavigationManager.NavigateTo("/login");
|
|
|
- // }
|
|
|
+ NavigationManager.NavigateTo("/login");
|
|
|
+ }
|
|
|
|
|
|
+ public void Dispose()
|
|
|
+ {
|
|
|
+ if (_timer != null)
|
|
|
+ {
|
|
|
+ _timer.Dispose();
|
|
|
+ _timer = null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|