/// <summary> /// 是否设置了密码加密且弹出解密框 /// </summary> /// <returns></returns> public async Task <(bool success, string?password)> HasPasswordEncryptionShowPassWordWindow() { var auth = await repository.GetFirstOrDefaultSourceAsync(); if (auth == null) { return(false, null); } var hasPassword = repository.HasSecondaryPassword(auth); if (hasPassword) { var password = await TextBoxWindowViewModel.ShowDialogByPresetAsync(TextBoxWindowViewModel.PresetType.LocalAuth_PasswordRequired); var list = await repository.ConvertToList(new[] { auth }, password); if (list.Any_Nullable()) { return(true, password); } Toast.Show(AppResources.LocalAuth_ProtectionAuth_PasswordError); return(false, null); } else { //没有设置密码直接成功 return(true, null); } }
public async Task InitializeAsync(GameAccountPlatformAuthenticator[] auths, bool isSync = false) { var hasPassword = repository.HasSecondaryPassword(auths); List <IGAPAuthenticatorDTO> list; if (hasPassword) { var password = await TextBoxWindowViewModel.ShowDialogByPresetAsync(TextBoxWindowViewModel.PresetType.LocalAuth_PasswordRequired); if (string.IsNullOrEmpty(password)) { return; } list = await repository.ConvertToList(auths, password); } else { list = await repository.ConvertToList(auths); } if (list.Any_Nullable()) { var authenticators = list.Select(s => new MyAuthenticator(s)); //MainThread2.BeginInvokeOnMainThread(() => //{ Authenticators.Clear(); Authenticators.AddOrUpdate(authenticators); if (isSync) { Task.Run(() => { foreach (var item in Authenticators.Items) { item.Sync(); } //ToastService.Current.Notify(AppResources.LocalAuth_RefreshAuthSuccess); }).ForgetAndDispose(); } //else // ToastService.Current.Notify(AppResources.LocalAuth_RefreshAuthSuccess); //}); } else { Toast.Show(AppResources.LocalAuth_ProtectionAuth_PasswordError); } }