mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-29 07:27:36 +08:00
Browser2
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace System.Application
|
||||
{
|
||||
public static class Browser2
|
||||
{
|
||||
public static event Action<Win32Exception>? OnError;
|
||||
|
||||
public static bool HttpsOnly { get; set; }
|
||||
|
||||
public const string Prefix_HTTPS = "https://";
|
||||
|
||||
public const string Prefix_HTTP = "http://";
|
||||
|
||||
public const string Prefix_MSStore = "ms-windows-store://";
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否为 Http Url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="httpsOnly">是否仅Https</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsHttpUrl([NotNullWhen(true)] string? url, bool httpsOnly = false) => url != null &&
|
||||
(url.StartsWith(Prefix_HTTPS, StringComparison.OrdinalIgnoreCase) ||
|
||||
(!httpsOnly && url.StartsWith(Prefix_HTTP, StringComparison.OrdinalIgnoreCase)));
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否为 Store Url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsStoreUrl([NotNullWhen(true)] string? url) => url != null && url.StartsWith(Prefix_MSStore, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
static sbyte OpenCore(string? url)
|
||||
{
|
||||
if (IsStoreUrl(url))
|
||||
{
|
||||
return OpenCoreByProcess(url);
|
||||
}
|
||||
else if (IsHttpUrl(url, HttpsOnly))
|
||||
{
|
||||
if (DeviceInfo.Platform == DevicePlatform.Unknown)
|
||||
{
|
||||
return OpenCoreByProcess(url);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -2;
|
||||
|
||||
static sbyte OpenCoreByProcess(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process2.Start(url, useShellExecute: true);
|
||||
return 1;
|
||||
}
|
||||
catch (Win32Exception e)
|
||||
{
|
||||
// [Win32Exception: 找不到应用程序] 39次报告
|
||||
// 疑似缺失没有默认浏览器设置会导致此异常,可能与杀毒软件有关
|
||||
if (OnError == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Toast.Show(e.GetAllMessage());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnError(e);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 兼容 Linux/macOS/.Net Core/Android/iOS 的打开链接方法
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static Task OpenAsync(string? url) => OpenCore(url) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(url),
|
||||
_ => Task.CompletedTask,
|
||||
};
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static async void Open(string? url) => await OpenAsync(url);
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static Task OpenAsync(string? url, BrowserLaunchMode launchMode) => OpenCore(url) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(url, launchMode),
|
||||
_ => Task.CompletedTask,
|
||||
};
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static Task OpenAsync(string? url, BrowserLaunchOptions options) => OpenCore(url) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(url, options),
|
||||
_ => Task.CompletedTask,
|
||||
};
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static Task OpenAsync(Uri uri) => OpenCore(uri.ToString()) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(uri),
|
||||
_ => Task.CompletedTask,
|
||||
};
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchMode launchMode) => OpenCore(uri.ToString()) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(uri, launchMode),
|
||||
_ => Task.CompletedTask,
|
||||
};
|
||||
|
||||
/// <inheritdoc cref="OpenAsync(string?)"/>
|
||||
public static Task<bool> OpenAsync(Uri uri, BrowserLaunchOptions options) => OpenCore(uri.ToString()) switch
|
||||
{
|
||||
0 => Browser.OpenAsync(uri, options),
|
||||
1 => Task.FromResult(true),
|
||||
_ => Task.FromResult(false),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Application.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
using static System.Application.Browser2;
|
||||
|
||||
namespace System.Application.Services
|
||||
{
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace System.Application.UI.ViewModels
|
||||
}
|
||||
}
|
||||
var url = $"{apiBaseUrl}/ExternalLoginDetection/{(int)channel}?port={vm.ServerWebSocketListenerPort}&sKey={skey_str}&sKeyPadding={padding.OaepHashAlgorithm}&version={csc.Settings.AppVersionStr}&isBind={isBind}&access_token_expires={access_token_expires}&access_token={access_token}";
|
||||
BrowserOpen(url);
|
||||
await Browser2.OpenAsync(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace System.Application.UI.ViewModels
|
||||
IconKey = nameof(AboutPageViewModel);
|
||||
#endif
|
||||
|
||||
OpenBrowserCommand = ReactiveCommand.Create<string>(BrowserOpen);
|
||||
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(Browser2.OpenAsync);
|
||||
|
||||
//#if !__MOBILE__
|
||||
// CopyLinkCommand =
|
||||
|
||||
@@ -12,7 +12,6 @@ using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
@@ -255,19 +254,19 @@ namespace System.Application.UI.ViewModels
|
||||
IDesktopPlatformService.Instance.OpenFolder(app.InstalledDir);
|
||||
}
|
||||
|
||||
public void OpenAppStoreUrl(SteamApp app)
|
||||
public async void OpenAppStoreUrl(SteamApp app)
|
||||
{
|
||||
BrowserOpen(string.Format(SteamApiUrls.STEAMSTORE_APP_URL, app.AppId));
|
||||
await Browser2.OpenAsync(string.Format(SteamApiUrls.STEAMSTORE_APP_URL, app.AppId));
|
||||
}
|
||||
|
||||
public void OpenSteamDBUrl(SteamApp app)
|
||||
public async void OpenSteamDBUrl(SteamApp app)
|
||||
{
|
||||
BrowserOpen(string.Format(SteamApiUrls.STEAMDBINFO_APP_URL, app.AppId));
|
||||
await Browser2.OpenAsync(string.Format(SteamApiUrls.STEAMDBINFO_APP_URL, app.AppId));
|
||||
}
|
||||
|
||||
public void OpenSteamCardUrl(SteamApp app)
|
||||
public async void OpenSteamCardUrl(SteamApp app)
|
||||
{
|
||||
BrowserOpen(string.Format(SteamApiUrls.STEAMCARDEXCHANGE_APP_URL, app.AppId));
|
||||
await Browser2.OpenAsync(string.Format(SteamApiUrls.STEAMCARDEXCHANGE_APP_URL, app.AppId));
|
||||
}
|
||||
|
||||
public void AddAFKAppList(SteamApp app)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace System.Application.UI.ViewModels
|
||||
IconKey = nameof(LocalAuthPageViewModel);
|
||||
#endif
|
||||
|
||||
OpenBrowserCommand = ReactiveCommand.Create<string>(Services.CloudService.Constants.BrowserOpen);
|
||||
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(Browser2.OpenAsync);
|
||||
AddAuthCommand = ReactiveCommand.Create(AddAuthMenu_Click);
|
||||
RefreshAuthCommand = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -198,9 +198,9 @@ namespace System.Application.UI.ViewModels
|
||||
|
||||
}
|
||||
|
||||
public void OpenHomeScriptItemButton(ScriptDTO script)
|
||||
public async void OpenHomeScriptItemButton(ScriptDTO script)
|
||||
{
|
||||
Services.CloudService.Constants.BrowserOpen(script.SourceLink);
|
||||
await Browser2.OpenAsync(script.SourceLink);
|
||||
}
|
||||
|
||||
public async void RefreshScriptItemButton(ScriptDTO script)
|
||||
|
||||
@@ -220,9 +220,9 @@ namespace System.Application.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenUserProfileUrl(SteamUser user)
|
||||
public async void OpenUserProfileUrl(SteamUser user)
|
||||
{
|
||||
BrowserOpen(user.ProfileUrl);
|
||||
await Browser2.OpenAsync(user.ProfileUrl);
|
||||
}
|
||||
|
||||
public void LoginNewSteamAccount()
|
||||
|
||||
+5
-5
@@ -80,7 +80,7 @@ namespace System.Application.UI.ViewModels
|
||||
}
|
||||
|
||||
public ICommand ManualLogin { get; }
|
||||
|
||||
|
||||
private string? _CurrentSelectChannel;
|
||||
public string? CurrentSelectChannel
|
||||
{
|
||||
@@ -221,7 +221,7 @@ namespace System.Application.UI.ViewModels
|
||||
public const string Agreement = "Agreement";
|
||||
public const string Privacy = "Privacy";
|
||||
|
||||
void OpenHyperlink_(string parameter)
|
||||
async void OpenHyperlink_(string parameter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(parameter)) return;
|
||||
switch (parameter)
|
||||
@@ -234,18 +234,18 @@ namespace System.Application.UI.ViewModels
|
||||
break;
|
||||
}
|
||||
#if __MOBILE__
|
||||
BrowserOpen(parameter);
|
||||
await Browser2.OpenAsync(parameter);
|
||||
#else
|
||||
if (AppHelper.IsSystemWebViewAvailable)
|
||||
{
|
||||
IShowWindowService.Instance.Show(CustomWindow.WebView3, new WebView3WindowViewModel
|
||||
await IShowWindowService.Instance.Show(CustomWindow.WebView3, new WebView3WindowViewModel
|
||||
{
|
||||
Url = parameter,
|
||||
}, resizeMode: ResizeModeCompat.NoResize);
|
||||
}
|
||||
else
|
||||
{
|
||||
BrowserOpen(parameter);
|
||||
await Browser2.OpenAsync(parameter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+67
-67
@@ -11,79 +11,79 @@ using System.Reactive.Linq;
|
||||
using System.Linq;
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class ScriptStoreWindowViewModel : WindowViewModel
|
||||
{
|
||||
public ScriptStoreWindowViewModel() : base()
|
||||
public class ScriptStoreWindowViewModel : WindowViewModel
|
||||
{
|
||||
public ScriptStoreWindowViewModel() : base()
|
||||
{
|
||||
Title = ThisAssembly.AssemblyTrademark + " | " + AppResources.ScriptStore;
|
||||
_ScriptsSourceList = new SourceList<ScriptDTO>();
|
||||
Title = ThisAssembly.AssemblyTrademark + " | " + AppResources.ScriptStore;
|
||||
_ScriptsSourceList = new SourceList<ScriptDTO>();
|
||||
|
||||
_ScriptsSourceList
|
||||
.Connect()
|
||||
//.Filter(scriptFilter)
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Sort(SortExpressionComparer<ScriptDTO>.Ascending(x => x.Order).ThenBy(x => x.Name))
|
||||
.Bind(out _Scripts)
|
||||
.Subscribe(_ => this.RaisePropertyChanged(nameof(IsScriptsEmpty)));
|
||||
_ScriptsSourceList
|
||||
.Connect()
|
||||
//.Filter(scriptFilter)
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Sort(SortExpressionComparer<ScriptDTO>.Ascending(x => x.Order).ThenBy(x => x.Name))
|
||||
.Bind(out _Scripts)
|
||||
.Subscribe(_ => this.RaisePropertyChanged(nameof(IsScriptsEmpty)));
|
||||
|
||||
this.WhenAnyValue(x => x.SearchText)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
//x
|
||||
InitializeScriptList();
|
||||
});
|
||||
}
|
||||
this.WhenAnyValue(x => x.SearchText)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
//x
|
||||
InitializeScriptList();
|
||||
});
|
||||
}
|
||||
|
||||
private readonly ReadOnlyObservableCollection<ScriptDTO> _Scripts;
|
||||
public ReadOnlyObservableCollection<ScriptDTO> Scripts => _Scripts;
|
||||
private readonly ReadOnlyObservableCollection<ScriptDTO> _Scripts;
|
||||
public ReadOnlyObservableCollection<ScriptDTO> Scripts => _Scripts;
|
||||
|
||||
private readonly SourceList<ScriptDTO> _ScriptsSourceList;
|
||||
private readonly SourceList<ScriptDTO> _ScriptsSourceList;
|
||||
|
||||
public bool IsScriptsEmpty => !Scripts.Any_Nullable();
|
||||
public bool IsScriptsEmpty => !Scripts.Any_Nullable();
|
||||
|
||||
private string? _SearchText;
|
||||
public string? SearchText
|
||||
{
|
||||
get => _SearchText;
|
||||
set => this.RaiseAndSetIfChanged(ref _SearchText, value);
|
||||
}
|
||||
public void RefreshScriptButton()
|
||||
{
|
||||
InitializeScriptList();
|
||||
}
|
||||
public void DownloadScriptItemButton(ScriptDTO model)
|
||||
{
|
||||
ProxyService.Current.DownloadScript(model);
|
||||
}
|
||||
public void OpenHomeScriptItemButton(ScriptDTO script)
|
||||
{
|
||||
Services.CloudService.Constants.BrowserOpen(script.SourceLink);
|
||||
}
|
||||
private string? _SearchText;
|
||||
public string? SearchText
|
||||
{
|
||||
get => _SearchText;
|
||||
set => this.RaiseAndSetIfChanged(ref _SearchText, value);
|
||||
}
|
||||
public void RefreshScriptButton()
|
||||
{
|
||||
InitializeScriptList();
|
||||
}
|
||||
public void DownloadScriptItemButton(ScriptDTO model)
|
||||
{
|
||||
ProxyService.Current.DownloadScript(model);
|
||||
}
|
||||
public async void OpenHomeScriptItemButton(ScriptDTO script)
|
||||
{
|
||||
await Browser2.OpenAsync(script.SourceLink);
|
||||
}
|
||||
|
||||
private async void InitializeScriptList()
|
||||
{
|
||||
var client = ICloudServiceClient.Instance.Script;
|
||||
var response = await client.ScriptTable(name: SearchText,pageSize:100,errormsg:AppResources.ScriptShop_GetTableError);
|
||||
if (!response.IsSuccess || response.Content == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
response.Content.DataSource.ForEach(item =>
|
||||
{
|
||||
var old = ProxyService.Current.ProxyScripts.Items.FirstOrDefault(x => x.Id == item.Id);
|
||||
if (old != null)
|
||||
{
|
||||
item.IsExist = true;
|
||||
if (old.Version != item.Version)
|
||||
{
|
||||
item.IsUpdate = true;
|
||||
item.NewVersion = item.Version;
|
||||
item.Version = old.Version;
|
||||
}
|
||||
}
|
||||
});
|
||||
_ScriptsSourceList.Clear();
|
||||
_ScriptsSourceList.AddRange(response.Content.DataSource);
|
||||
}
|
||||
}
|
||||
private async void InitializeScriptList()
|
||||
{
|
||||
var client = ICloudServiceClient.Instance.Script;
|
||||
var response = await client.ScriptTable(name: SearchText, pageSize: 100, errormsg: AppResources.ScriptShop_GetTableError);
|
||||
if (!response.IsSuccess || response.Content == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
response.Content.DataSource.ForEach(item =>
|
||||
{
|
||||
var old = ProxyService.Current.ProxyScripts.Items.FirstOrDefault(x => x.Id == item.Id);
|
||||
if (old != null)
|
||||
{
|
||||
item.IsExist = true;
|
||||
if (old.Version != item.Version)
|
||||
{
|
||||
item.IsUpdate = true;
|
||||
item.NewVersion = item.Version;
|
||||
item.Version = old.Version;
|
||||
}
|
||||
}
|
||||
});
|
||||
_ScriptsSourceList.Clear();
|
||||
_ScriptsSourceList.AddRange(response.Content.DataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -107,9 +107,9 @@ namespace System.Application.UI.ViewModels
|
||||
_AuthorizedSourceList.Refresh();
|
||||
}
|
||||
|
||||
public void OpenUserProfileUrl(AuthorizedDevice user)
|
||||
public async void OpenUserProfileUrl(AuthorizedDevice user)
|
||||
{
|
||||
BrowserOpen(user.ProfileUrl);
|
||||
await Browser2.OpenAsync(user.ProfileUrl);
|
||||
}
|
||||
|
||||
public void About_Click()
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace System.Application.UI.Activities
|
||||
}).AddTo(this);
|
||||
|
||||
var adapter = new SmallPreferenceButtonAdapter<PreferenceButtonViewModel, PreferenceButton>(ViewModel!.PreferenceButtons);
|
||||
adapter.ItemClick += (_, e) =>
|
||||
adapter.ItemClick += async (_, e) =>
|
||||
{
|
||||
switch (e.Current.Id)
|
||||
{
|
||||
@@ -77,13 +77,13 @@ namespace System.Application.UI.Activities
|
||||
//ViewModel!.CheckUpdateCommand.Invoke();
|
||||
break;
|
||||
case PreferenceButton.更新日志:
|
||||
BrowserOpen(string.Format(
|
||||
await Browser2.OpenAsync(string.Format(
|
||||
UrlConstants.OfficialWebsite_Box_Changelog_,
|
||||
MainApplication.GetTheme(),
|
||||
R.Language));
|
||||
break;
|
||||
case PreferenceButton.常见问题疑难解答:
|
||||
BrowserOpen(string.Format(
|
||||
await Browser2.OpenAsync(string.Format(
|
||||
UrlConstants.OfficialWebsite_Box_Faq_,
|
||||
MainApplication.GetTheme(),
|
||||
R.Language));
|
||||
@@ -96,7 +96,7 @@ namespace System.Application.UI.Activities
|
||||
});
|
||||
break;
|
||||
case PreferenceButton.源码仓库:
|
||||
ComboBoxHelper.Dialog(this, SourceRepositories, x => BrowserOpen(x switch
|
||||
ComboBoxHelper.Dialog(this, SourceRepositories, async x => await Browser2.OpenAsync(x switch
|
||||
{
|
||||
GitHub => UrlConstants.GitHub_Repository,
|
||||
Gitee => UrlConstants.Gitee_Repository,
|
||||
@@ -104,13 +104,13 @@ namespace System.Application.UI.Activities
|
||||
}));
|
||||
break;
|
||||
case PreferenceButton.产品官网:
|
||||
BrowserOpen(UrlConstants.OfficialWebsite);
|
||||
await Browser2.OpenAsync(UrlConstants.OfficialWebsite);
|
||||
break;
|
||||
case PreferenceButton.联系我们:
|
||||
BrowserOpen(UrlConstants.OfficialWebsite_Contact);
|
||||
await Browser2.OpenAsync(UrlConstants.OfficialWebsite_Contact);
|
||||
break;
|
||||
case PreferenceButton.Bug反馈:
|
||||
ComboBoxHelper.Dialog(this, SourceRepositories, x => BrowserOpen(x switch
|
||||
ComboBoxHelper.Dialog(this, SourceRepositories, async x => await Browser2.OpenAsync(x switch
|
||||
{
|
||||
GitHub => UrlConstants.GitHub_Issues,
|
||||
Gitee => UrlConstants.Gitee_Issues,
|
||||
@@ -438,23 +438,23 @@ namespace System.Application.UI.Activities
|
||||
StringBuilder str = new(Developers_0);
|
||||
length = str.Length;
|
||||
str.Append(At_Rmbadmin);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.GitHub_User_Rmbadmin);
|
||||
await Browser2.OpenAsync(UrlConstants.GitHub_User_Rmbadmin);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
str.Append(Separator);
|
||||
length = str.Length;
|
||||
str.Append(At_AigioL);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.GitHub_User_AigioL);
|
||||
await Browser2.OpenAsync(UrlConstants.GitHub_User_AigioL);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
str.Append(Separator);
|
||||
length = str.Length;
|
||||
str.Append(At_Mossimos);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.GitHub_User_Mossimos);
|
||||
await Browser2.OpenAsync(UrlConstants.GitHub_User_Mossimos);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
return str;
|
||||
});
|
||||
@@ -465,9 +465,9 @@ namespace System.Application.UI.Activities
|
||||
StringBuilder str = new(BusinessCooperationContact_0);
|
||||
length = str.Length;
|
||||
str.Append(At_Cliencer);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.BILI_User_Cliencer);
|
||||
await Browser2.OpenAsync(UrlConstants.BILI_User_Cliencer);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
return str;
|
||||
});
|
||||
@@ -478,16 +478,16 @@ namespace System.Application.UI.Activities
|
||||
StringBuilder str = new();
|
||||
length = str.Length;
|
||||
str.Append(AppResources.User_Agreement);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.OfficialWebsite_Box_Agreement);
|
||||
await Browser2.OpenAsync(UrlConstants.OfficialWebsite_Box_Agreement);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
str.Append(Separator2);
|
||||
length = str.Length;
|
||||
str.Append(AppResources.User_Privacy);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.OfficialWebsite_Box_Privacy);
|
||||
await Browser2.OpenAsync(UrlConstants.OfficialWebsite_Box_Privacy);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
return str;
|
||||
});
|
||||
@@ -498,9 +498,9 @@ namespace System.Application.UI.Activities
|
||||
StringBuilder str = new(OpenSourceLicensed_0);
|
||||
length = str.Length;
|
||||
str.Append(OpenSourceLicensed_1);
|
||||
list.Add((new HyperlinkClickableSpan(_ =>
|
||||
list.Add((new HyperlinkClickableSpan(async _ =>
|
||||
{
|
||||
BrowserOpen(UrlConstants.License_GPLv3);
|
||||
await Browser2.OpenAsync(UrlConstants.License_GPLv3);
|
||||
}), length, str.Length, SpanTypes.ExclusiveExclusive));
|
||||
return str;
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
using static System.Application.Browser2;
|
||||
using static System.Application.Services.IAppUpdateService;
|
||||
using CC = System.Common.Constants;
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace System.Application.Services.Implementation
|
||||
}
|
||||
if (item.Redirect)
|
||||
{
|
||||
if (CloudService.Constants.IsHttpUrl(item.ForwardDomainName))
|
||||
if (Browser2.IsHttpUrl(item.ForwardDomainName))
|
||||
{
|
||||
e.Redirect(e.HttpClient.Request.RequestUri.AbsoluteUri.Replace(e.HttpClient.Request.RequestUri.Scheme + "://" + e.HttpClient.Request.RequestUri.Host, item.ForwardDomainName));
|
||||
return;
|
||||
@@ -400,7 +400,7 @@ namespace System.Application.Services.Implementation
|
||||
if (OperatingSystem2.IsLinux)
|
||||
{
|
||||
IPlatformService.Instance.AdminShell($"sudo cp -f \"{filePath}\" \"{Path.Combine(IOPath.AppDataDirectory, $@"{CertificateName}.Certificate.pem")}\"", false);
|
||||
CloudService.Constants.BrowserOpen("https://www.steampp.net/liunxSetupCer");
|
||||
Browser2.Open("https://www.steampp.net/liunxSetupCer");
|
||||
return true;
|
||||
}
|
||||
return IsCertificateInstalled(proxyServer.CertificateManager.RootCertificate);
|
||||
|
||||
@@ -12,7 +12,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using static System.Application.ForwardHelper;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
using static System.Application.Services.IHttpService;
|
||||
|
||||
namespace System.Application.Services.Implementation
|
||||
@@ -54,7 +53,7 @@ namespace System.Application.Services.Implementation
|
||||
request = requestFactory();
|
||||
requestUri ??= request.RequestUri.ToString();
|
||||
|
||||
if (!isCheckHttpUrl && !IsHttpUrl(requestUri)) return default;
|
||||
if (!isCheckHttpUrl && !Browser2.IsHttpUrl(requestUri)) return default;
|
||||
|
||||
if (enableForward && IsAllowUrl(requestUri))
|
||||
{
|
||||
@@ -178,7 +177,7 @@ namespace System.Application.Services.Implementation
|
||||
CancellationToken cancellationToken,
|
||||
string? cookie = null) where T : notnull
|
||||
{
|
||||
if (!IsHttpUrl(requestUri)) return Task.FromResult(default(T?));
|
||||
if (!Browser2.IsHttpUrl(requestUri)) return Task.FromResult(default(T?));
|
||||
return SendAsync<T>(isCheckHttpUrl: true, requestUri, () =>
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
|
||||
@@ -347,7 +346,7 @@ namespace System.Application.Services.Implementation
|
||||
|
||||
public async Task<string?> GetImageLocalFilePathAsync(string requestUri, string channelType, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!IsHttpUrl(requestUri)) return null;
|
||||
if (!Browser2.IsHttpUrl(requestUri)) return null;
|
||||
|
||||
if (get_image_pipeline.ContainsKey(channelType))
|
||||
{
|
||||
@@ -377,7 +376,7 @@ namespace System.Application.Services.Implementation
|
||||
|
||||
public async Task<Stream?> GetImageStreamAsync(string requestUri, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!IsHttpUrl(requestUri)) return null;
|
||||
if (!Browser2.IsHttpUrl(requestUri)) return null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Application.Properties;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace System.Application.Services.CloudService
|
||||
{
|
||||
@@ -38,10 +35,6 @@ namespace System.Application.Services.CloudService
|
||||
/// </summary>
|
||||
public const double SMSIntervalActually = 79.5;
|
||||
|
||||
public const string Prefix_HTTPS = "https://";
|
||||
|
||||
public const string Prefix_HTTP = "http://";
|
||||
|
||||
public static string IsNotOfficialChannelPackageWarning => SR.IsNotOfficialChannelPackageWarning;
|
||||
|
||||
/// <summary>
|
||||
@@ -67,49 +60,5 @@ namespace System.Application.Services.CloudService
|
||||
}
|
||||
return cacheValuesArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否为 Http Url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="httpsOnly">是否仅Https</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsHttpUrl(string? url, bool httpsOnly = false) => url != null &&
|
||||
(url.StartsWith(Prefix_HTTPS, StringComparison.OrdinalIgnoreCase) ||
|
||||
(!httpsOnly && url.StartsWith(Prefix_HTTP, StringComparison.OrdinalIgnoreCase)));
|
||||
|
||||
/// <summary>
|
||||
/// 兼容 Linux/Mac/.NetCore/Android/iOS 的打开链接方法
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public static async void BrowserOpen(string? url)
|
||||
{
|
||||
//if (IsHttpUrl(url))
|
||||
//{
|
||||
if (DeviceInfo.Platform == DevicePlatform.Unknown)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = url,
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
catch (Win32Exception e)
|
||||
{
|
||||
#if MVVM_VM
|
||||
// [Win32Exception: 找不到应用程序] 39次报告
|
||||
// 疑似缺失没有默认浏览器设置会导致此异常,可能与杀毒软件有关
|
||||
Toast.Show(e.GetAllMessage());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await Browser.OpenAsync(url);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -20,7 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Application.Services.CloudService.Clients.Abstractions;
|
||||
using System.Linq;
|
||||
using CSConst = System.Application.Services.CloudService.Constants;
|
||||
using static System.Application.Browser2;
|
||||
using System.Properties;
|
||||
using System.IO;
|
||||
using static System.Application.AppClientAttribute;
|
||||
@@ -416,7 +416,7 @@ namespace System.Application
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var url = CSConst.Prefix_HTTPS + "localhost:5001";
|
||||
// var url = Prefix_HTTPS + "localhost:5001";
|
||||
// var request = WebRequest.CreateHttp(url);
|
||||
// request.Timeout = 1888;
|
||||
// request.GetResponse();
|
||||
@@ -431,8 +431,8 @@ namespace System.Application
|
||||
//#endif
|
||||
var value =
|
||||
(_ThisAssembly.Debuggable || !s.GetIsOfficialChannelPackage()) ?
|
||||
CSConst.Prefix_HTTPS + "pan.mossimo.net:8862" :
|
||||
CSConst.Prefix_HTTPS + "api.steampp.net";
|
||||
Prefix_HTTPS + "pan.mossimo.net:8862" :
|
||||
Prefix_HTTPS + "api.steampp.net";
|
||||
s.ApiBaseUrl = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user