/// <summary>
        /// 开始第三方快速登录、注册、绑定
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        public static async Task StartAsync(WindowViewModel vm, FastLoginChannel channel, bool isBind)
        {
            var app = IApplication.Instance;

            StartServer(app);
            var conn_helper = DI.Get <IApiConnectionPlatformHelper>();
            var apiBaseUrl  = ICloudServiceClient.Instance.ApiBaseUrl;

#if DEBUG
            if (UseLoopbackTest)
            {
                apiBaseUrl = "https://127.0.0.1:28110";
            }
#endif

            ThirdPartyLoginHelper.isBind = isBind;
            ThirdPartyLoginHelper.vm     = vm;
            Disposable.Create(() =>
            {
                if (vm == ThirdPartyLoginHelper.vm)
                {
                    ThirdPartyLoginHelper.vm = null;
                }
            }).AddTo(vm);
            if (tempAes == null)
            {
                tempAes = AESUtils.Create();                  // 每次创建新的之前的会失效
            }
            var skey_bytes           = tempAes.ToParamsByteArray();
            var skey_str             = conn_helper.RSA.EncryptToString(skey_bytes);
            var csc                  = DI.Get <CloudServiceClientBase>();
            var padding              = RSAUtils.DefaultPadding;
            var access_token         = string.Empty;
            var access_token_expires = string.Empty;
            if (isBind)
            {
                var authToken = await conn_helper.Auth.GetAuthTokenAsync();

                var authHeaderValue = conn_helper.GetAuthenticationHeaderValue(authToken);
                if (authHeaderValue != null)
                {
                    var authHeaderValueStr = authHeaderValue.ToString();
                    access_token = tempAes.Encrypt(authHeaderValueStr);
                    var now = DateTime.UtcNow;
                    access_token_expires = tempAes.Encrypt(now.ToString(DateTimeFormat.RFC1123));
                }
            }
            // &version={version}
            //var version = csc.Settings.AppVersionStr;
            var ver = _ThisAssembly.Version.Base64UrlEncode();
            var url = $"{apiBaseUrl}/ExternalLoginDetection/{(int)channel}?port={port}&sKey={skey_str}&sKeyPadding={padding.OaepHashAlgorithm}&ver={ver}&isBind={isBind}&access_token_expires={access_token_expires}&access_token={access_token}";
            await Browser2.OpenAsync(url);
        }
 private void SetCustomAddress(string url)
 {
     Browser2.Load(url);
 }
        public override void OnCreate()
        {
            if (IsActivity)
            {
                SetSupportActionBarWithNavigationClick(true);
            }

            binding !.tvDevelopers.SetLinkMovementMethod();
            binding !.tvBusinessCooperationContact.SetLinkMovementMethod();
            binding !.tvOpenSourceLicensed.SetLinkMovementMethod();
            binding !.tvAgreementAndPrivacy.SetLinkMovementMethod();
            //binding!.tvContributors.SetLinkMovementMethod();

            binding !.tvTitle.TextFormatted      = CreateTitle();
            binding !.tvVersion.Text             = $"{ViewModel!.LabelVersionDisplay} {ViewModel.VersionDisplay}";
            binding !.tvDevelopers.TextFormatted = CreateDevelopers();
            binding !.tvBusinessCooperationContact.TextFormatted = CreateBusinessCooperationContact();
            binding !.tvOpenSourceLicensed.TextFormatted         = CreateOpenSourceLicensed();
            binding !.tvCopyright.Text = Copyright;
            //binding!.tvContributors.TextFormatted = CreateContributors();

            R.Subscribe(() =>
            {
                if (IsActivity)
                {
                    Activity.Title = ViewModel.Name;
                }
                if (binding == null)
                {
                    return;
                }
                binding.tvAgreementAndPrivacy.TextFormatted = CreateAgreementAndPrivacy();
            }).AddTo(this);

            var adapter = new SmallPreferenceButtonAdapter <PreferenceButtonViewModel, PreferenceButton>(ViewModel !.PreferenceButtons);

            adapter.ItemClick += async(_, e) =>
            {
                switch (e.Current.Id)
                {
                case PreferenceButton.检查更新:
                    ViewModel !.CheckUpdateCommand.Invoke();
                    break;

                case PreferenceButton.更新日志:
                    await Browser2.OpenAsync(string.Format(
                                                 UrlConstants.OfficialWebsite_Box_Changelog_,
                                                 IApplication.Instance.Theme.ToString2(),
                                                 R.Language));

                    break;

                case PreferenceButton.常见问题疑难解答:
                    await Browser2.OpenAsync(string.Format(
                                                 UrlConstants.OfficialWebsite_Box_Faq_,
                                                 IApplication.Instance.Theme.ToString2(),
                                                 R.Language));

                    break;

                case PreferenceButton.开放源代码许可:
                    TextBlockActivity.StartActivity(Activity, new TextBlockViewModel
                    {
                        Title         = AppResources.About_OpenSource,
                        ContentSource = TextBlockViewModel.ContentSourceEnum.OpenSourceLibrary,
                    });
                    break;

                case PreferenceButton.源码仓库:
                    ComboBoxHelper.Dialog(Activity, SourceRepositories, async x => await Browser2.OpenAsync(x switch
                    {
                        GitHub => UrlConstants.GitHub_Repository,
                        Gitee => UrlConstants.Gitee_Repository,
                        _ => default,
                    }));
                    break;
 public async void OpenUserProfileUrl(AuthorizedDevice user)
 {
     await Browser2.OpenAsync(user.ProfileUrl);
 }
Exemple #5
0
 public async void OpenUserProfileUrl(SteamUser user)
 {
     await Browser2.OpenAsync(user.ProfileUrl);
 }