mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 23:19:53 +08:00
Misc
This commit is contained in:
@@ -11,9 +11,6 @@
|
||||
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
|
||||
<DefineConstants>APP_HOST;$(DefineConstants)</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net3')) OR $(TargetFramework.StartsWith('net4')) OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
|
||||
<ApplicationIcon>..\..\res\icons\app\v2\Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -28,6 +25,10 @@
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith('net3')) OR !$(TargetFramework.StartsWith('net4'))">
|
||||
<None Remove="App.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\AssemblyInfo.Constants.cs">
|
||||
<LinkBase>Properties</LinkBase>
|
||||
|
||||
@@ -12,8 +12,9 @@ static partial class Program
|
||||
{
|
||||
public const string dotnet_version_major = "7";
|
||||
public const string dotnet_version_minor = "0";
|
||||
public const string dotnet_version_build = "3";
|
||||
public const string dotnet_version_build = "4";
|
||||
public const string dotnet_version = $"{dotnet_version_major}.{dotnet_version_minor}.{dotnet_version_build}";
|
||||
|
||||
const string dotnet_runtime = "Microsoft.NETCore.App";
|
||||
const string aspnetcore_runtime = "Microsoft.AspNetCore.App";
|
||||
|
||||
@@ -21,6 +22,33 @@ static partial class Program
|
||||
const string dotnet_type = "BD.WTTS.Program, Steam++";
|
||||
const string dotnet_type_method = "CustomEntryPoint";
|
||||
|
||||
/// <summary>
|
||||
/// 是否依赖 AspNetCore
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
static bool RequireAspNetCore(string baseDirectory)
|
||||
{
|
||||
foreach (var moduleName in new[] {
|
||||
// 依赖 AspNetCore 的模块名
|
||||
"Accelerator",
|
||||
"ArchiSteamFarm",
|
||||
})
|
||||
{
|
||||
var module_path =
|
||||
#if NET35
|
||||
PathCombine
|
||||
#else
|
||||
Path.Combine
|
||||
#endif
|
||||
(baseDirectory, "modules", moduleName);
|
||||
if (Directory.Exists(module_path) && !PathIsDirectoryEmpty(module_path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[LibraryImport("shlwapi.dll", EntryPoint = "PathIsDirectoryEmptyW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
@@ -91,7 +119,9 @@ static partial class Program
|
||||
{
|
||||
Architecture.X86 => "x86",
|
||||
Architecture.X64 => "x64",
|
||||
Architecture.Arm => "Arm32",
|
||||
Architecture.Arm64 => "Arm64",
|
||||
Architecture.Armv6 => "Armv6",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(architecture), architecture, null),
|
||||
};
|
||||
|
||||
@@ -136,7 +166,8 @@ static partial class Program
|
||||
[STAThread]
|
||||
static int Main()
|
||||
{
|
||||
// TODO 合并32位与64位本机库?检查进程是否是x64,加载不同的运行库与程序集
|
||||
// TODO 合并 32 位与 64 位本机库?检查进程是否是 x64,加载不同的运行库与程序集
|
||||
// 允许在 64 位系统上使用 32 位运行
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Environment.Version: {Environment.Version}");
|
||||
@@ -150,6 +181,7 @@ static partial class Program
|
||||
#else
|
||||
AppDomain.CurrentDomain.BaseDirectory;
|
||||
#endif
|
||||
var requireAspNetCore = RequireAspNetCore(baseDirectory);
|
||||
string hostfxr_path, dotnet_runtime_path, aspnetcore_runtime_path, config_path, dotnetlib_path;
|
||||
|
||||
// STEP 0: Search HostFxr
|
||||
@@ -166,9 +198,17 @@ static partial class Program
|
||||
{
|
||||
// 此应用程序必须安装 {0} 才能运行,你想现在就下载并安装运行时吗?
|
||||
var archStr = ToString(GetProcessArchitecture());
|
||||
var _AspNetCoreRuntime = string.Format(AspNetCoreRuntimeFormat1, archStr);
|
||||
var _NetRuntime = string.Format(NetRuntimeFormat1, archStr);
|
||||
var _Runtime = $"{_AspNetCoreRuntime} {And} {_NetRuntime}";
|
||||
string _Runtime;
|
||||
if (requireAspNetCore)
|
||||
{
|
||||
var _AspNetCoreRuntime = string.Format(AspNetCoreRuntimeFormat1, archStr);
|
||||
_Runtime = $"{_AspNetCoreRuntime} {And} {_NetRuntime}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_Runtime = _NetRuntime;
|
||||
}
|
||||
var text = string.Format(FrameworkMissingFailureFormat1, _Runtime);
|
||||
var result = ShowErrMessageBox(text, WPFMessageBoxButton.YesNo);
|
||||
if (result == WPFMessageBoxResult.Yes)
|
||||
@@ -187,30 +227,56 @@ static partial class Program
|
||||
{
|
||||
if (Directory.Exists(dotnet_root) && !PathIsDirectoryEmpty(dotnet_root))
|
||||
{
|
||||
var dir_hostfxr_path =
|
||||
#if NET35
|
||||
PathCombine
|
||||
#else
|
||||
Path.Combine
|
||||
#endif
|
||||
(dotnet_root, "host", "fxr");
|
||||
string usable_dotnet_version = dotnet_version;
|
||||
var dotnet_version_max = Directory.GetDirectories(dir_hostfxr_path, $"{dotnet_version_major}.*").Select(x =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Version(Path.GetFileName(x));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(x => x != null).Max();
|
||||
if (dotnet_version_max != null)
|
||||
{
|
||||
usable_dotnet_version = dotnet_version_max.ToString();
|
||||
}
|
||||
|
||||
hostfxr_path =
|
||||
#if NET35
|
||||
PathCombine
|
||||
#else
|
||||
Path.Combine
|
||||
#endif
|
||||
(dotnet_root, "host", "fxr", dotnet_version, "hostfxr.dll");
|
||||
(dir_hostfxr_path, usable_dotnet_version, "hostfxr.dll");
|
||||
|
||||
dotnet_runtime_path =
|
||||
#if NET35
|
||||
PathCombine
|
||||
#else
|
||||
Path.Combine
|
||||
#endif
|
||||
(dotnet_root, "shared", dotnet_runtime, dotnet_version);
|
||||
aspnetcore_runtime_path =
|
||||
(dotnet_root, "shared", dotnet_runtime, usable_dotnet_version);
|
||||
|
||||
aspnetcore_runtime_path = requireAspNetCore ?
|
||||
#if NET35
|
||||
PathCombine
|
||||
#else
|
||||
Path.Combine
|
||||
#endif
|
||||
(dotnet_root, "shared", aspnetcore_runtime, dotnet_version);
|
||||
(dotnet_root, "shared", aspnetcore_runtime, usable_dotnet_version) : null!;
|
||||
if (File.Exists(hostfxr_path) &&
|
||||
Directory.Exists(dotnet_runtime_path) && !PathIsDirectoryEmpty(dotnet_runtime_path) &&
|
||||
Directory.Exists(aspnetcore_runtime_path) && !PathIsDirectoryEmpty(aspnetcore_runtime_path))
|
||||
(!requireAspNetCore || (Directory.Exists(aspnetcore_runtime_path) && !PathIsDirectoryEmpty(aspnetcore_runtime_path))))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -465,7 +531,13 @@ static partial class Program
|
||||
{
|
||||
X86 = 0,
|
||||
X64 = 1,
|
||||
Arm = 2,
|
||||
Arm64 = 3,
|
||||
//Wasm = 4,
|
||||
//S390x = 5,
|
||||
//LoongArch64 = 6, // SkiaSharp incompatibility.
|
||||
Armv6 = 7,
|
||||
//Ppc64le = 8,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>bin\Release\Publish\linux-x64</PublishDir>
|
||||
<PublishDir>bin\Release\Publish\linux-x64\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
@@ -18,14 +18,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
|
||||
<DebugType>none</DebugType>
|
||||
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
<!-- Only some may work - From the experimental AOT version -->
|
||||
<!-- 本机 AOT 当前不支持跨操作系统编译,需要在 Linux 上发布此 -->
|
||||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
|
||||
<IlcTrimMetadata>true</IlcTrimMetadata>
|
||||
<IlcInvariantGlobalization>true</IlcInvariantGlobalization>
|
||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishDir>bin\Release\Publish\win-any\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net3.5</TargetFramework>
|
||||
<TargetFramework>net35</TargetFramework>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
|
||||
@@ -18,14 +18,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
|
||||
<DebugType>none</DebugType>
|
||||
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
<!-- Only some may work - From the experimental AOT version -->
|
||||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
|
||||
<IlcTrimMetadata>true</IlcTrimMetadata>
|
||||
<IlcInvariantGlobalization>true</IlcInvariantGlobalization>
|
||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -64,6 +64,8 @@ static partial class Program
|
||||
{
|
||||
if (Environment.UserInteractive)
|
||||
{
|
||||
// 在 Win 11 上 MessageBox 与 net35 WPF 上的样式不一致,net35 中的 Title 缺少一些 Padding
|
||||
// 发布此 win-any 与 win-x64 可比较区别
|
||||
return WPFMessageBox.Show(error, AppResources.Error, button, WPFMessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
@@ -72,13 +74,17 @@ static partial class Program
|
||||
|
||||
}
|
||||
|
||||
Console.WriteLine("---------------------------");
|
||||
Console.WriteLine(AppResources.Error);
|
||||
Console.WriteLine("---------------------------");
|
||||
Console.WriteLine(error);
|
||||
Console.WriteLine("---------------------------");
|
||||
switch (button)
|
||||
{
|
||||
case WPFMessageBoxButton.OKCancel:
|
||||
{
|
||||
Console.WriteLine("OK/Cancel");
|
||||
Console.WriteLine("---------------------------");
|
||||
var line = Console.ReadLine();
|
||||
if (string.Equals(line, nameof(WPFMessageBoxResult.OK)) || string.Equals(line, nameof(WPFMessageBoxResult.Yes)) || string.Equals(line, "o") || string.Equals(line, "y"))
|
||||
return WPFMessageBoxResult.OK;
|
||||
@@ -89,6 +95,7 @@ static partial class Program
|
||||
case WPFMessageBoxButton.YesNoCancel:
|
||||
{
|
||||
Console.WriteLine("Yes/No/Cancel");
|
||||
Console.WriteLine("---------------------------");
|
||||
var line = Console.ReadLine();
|
||||
if (string.Equals(line, nameof(WPFMessageBoxResult.OK)) || string.Equals(line, nameof(WPFMessageBoxResult.Yes)) || string.Equals(line, "o") || string.Equals(line, "y"))
|
||||
return WPFMessageBoxResult.Yes;
|
||||
@@ -101,6 +108,7 @@ static partial class Program
|
||||
case WPFMessageBoxButton.YesNo:
|
||||
{
|
||||
Console.WriteLine("Yes/No");
|
||||
Console.WriteLine("---------------------------");
|
||||
var line = Console.ReadLine();
|
||||
if (string.Equals(line, nameof(WPFMessageBoxResult.OK)) || string.Equals(line, nameof(WPFMessageBoxResult.Yes)) || string.Equals(line, "o") || string.Equals(line, "y"))
|
||||
return WPFMessageBoxResult.Yes;
|
||||
|
||||
@@ -160,6 +160,7 @@ static partial class Program
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine($"CurrentUICulture: {CultureInfo.CurrentUICulture}");
|
||||
Console.WriteLine($"RID: {GlobalDllImportResolver.RID}");
|
||||
Console.WriteLine($"DefaultFontFamilyName: {SkiaSharp.SKTypeface.Default.FamilyName}");
|
||||
Console.WriteLine($"DefaultFontFamilyName2: {IPlatformService.Instance.GetDefaultFontFamily()}");
|
||||
|
||||
@@ -15,5 +15,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<UseAppHost>false</UseAppHost>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -15,5 +15,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<UseAppHost>false</UseAppHost>
|
||||
<PublishDocumentationFile>false</PublishDocumentationFile>
|
||||
<PublishDocumentationFiles>false</PublishDocumentationFiles>
|
||||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -50,7 +50,7 @@ public static partial class CompositeDisposableExtensions
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await DisposeAsyncCore().ConfigureAwait(false);
|
||||
await DisposeAsyncCoreAsync().ConfigureAwait(false);
|
||||
|
||||
Dispose(disposing: false);
|
||||
GC.SuppressFinalize(this);
|
||||
@@ -67,7 +67,7 @@ public static partial class CompositeDisposableExtensions
|
||||
}
|
||||
}
|
||||
|
||||
async ValueTask DisposeAsyncCore()
|
||||
async ValueTask DisposeAsyncCoreAsync()
|
||||
{
|
||||
if (_asyncDisposableResource is not null)
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ public static partial class GlobalDllImportResolver
|
||||
Architecture.X64 => "linux-x64", // 大多数桌面发行版,如 CentOS、Debian、Fedora、Ubuntu 及派生版本
|
||||
Architecture.Arm64 => "linux-arm64", // 在 64 位 ARM 上运行的 Linux 发行版本,如 Raspberry Pi Model 3 及更高版本上的 Ubuntu 服务器 64 位
|
||||
Architecture.Arm => "linux-arm", // 在 ARM 上运行的 Linux 发行版本,如 Raspberry Pi Model 2 及更高版本上的 Raspbian
|
||||
Architecture.Armv6 => "linux-armv6",
|
||||
_ => throw new PlatformNotSupportedException(),
|
||||
};
|
||||
#else
|
||||
|
||||
@@ -33,7 +33,7 @@ public static class SendSmsUIHelper
|
||||
var isStartSendSmsTimer = validator.Validate(request_);
|
||||
if (isStartSendSmsTimer) i.StartSendSmsTimer();
|
||||
|
||||
await i.SendSms(request_, isStartSendSmsTimer);
|
||||
await i.SendSmsAsync(request_, isStartSendSmsTimer);
|
||||
}
|
||||
|
||||
static async void StartSendSmsTimer(this IViewModel i)
|
||||
@@ -85,7 +85,7 @@ public static class SendSmsUIHelper
|
||||
while (b);
|
||||
}
|
||||
|
||||
static async ValueTask<IApiRsp> SendSms(this IViewModel i, SendSmsRequest request, bool isStartSendSmsTimer)
|
||||
static async ValueTask<IApiRsp> SendSmsAsync(this IViewModel i, SendSmsRequest request, bool isStartSendSmsTimer)
|
||||
{
|
||||
i.TbSmsCodeFocus?.Invoke();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public static class ThirdPartyLoginHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
await OnMessage(modelvm.Value, null);
|
||||
await OnMessageAsync(modelvm.Value, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public static class ThirdPartyLoginHelper
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="socket"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task OnMessage(string msg, IWebSocketConnection? socket = null)
|
||||
public static async Task OnMessageAsync(string msg, IWebSocketConnection? socket = null)
|
||||
{
|
||||
if (tempAes == null) return;
|
||||
var byteArray = msg.Base64UrlDecodeToByteArray();
|
||||
@@ -177,7 +177,7 @@ public static class ThirdPartyLoginHelper
|
||||
|
||||
ws.Start(socket =>
|
||||
{
|
||||
socket.OnMessage = async message => await OnMessage(message, socket);
|
||||
socket.OnMessage = async message => await OnMessageAsync(message, socket);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -74,13 +74,13 @@ public interface ICertificateManager
|
||||
/// <summary>
|
||||
/// 由平台实现的信任根证书引导,有 Root 权限将尝试执行信任,否则则 UI 引导,跳转网页或弹窗
|
||||
/// </summary>
|
||||
ValueTask PlatformTrustRootCertificateGuide();
|
||||
ValueTask PlatformTrustRootCertificateGuideAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 安装根证书,如果没有证书将生成一个新的
|
||||
/// </summary>
|
||||
/// <returns>返回根证书是否受信任</returns>
|
||||
ValueTask<bool> SetupRootCertificate();
|
||||
ValueTask<bool> SetupRootCertificateAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 删除根证书,如果没有证书将返回 <see langword="true"/>
|
||||
|
||||
@@ -74,13 +74,13 @@ public sealed class AdvertiseService : ReactiveObject
|
||||
{
|
||||
if (IsInitialized == false)
|
||||
{
|
||||
await RefrshAdvertise();
|
||||
await RefrshAdvertiseAsync();
|
||||
IsInitialized = true;
|
||||
CheckShow();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RefrshAdvertise()
|
||||
public async Task RefrshAdvertiseAsync()
|
||||
{
|
||||
var client = IMicroServiceClient.Instance.Advertisement;
|
||||
var result = await client.All();
|
||||
|
||||
@@ -41,7 +41,7 @@ public sealed class UserService : ReactiveObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
await windowManager.ShowDialog(windowName, isDialog: isDialog, resizeMode: default);
|
||||
await windowManager.ShowDialogAsync(windowName, isDialog: isDialog, resizeMode: default);
|
||||
}
|
||||
|
||||
public void NavigateUserCenterPage()
|
||||
@@ -85,7 +85,7 @@ public sealed class UserService : ReactiveObject
|
||||
|
||||
public DateTimeOffset? LastSignInTime { get; set; }
|
||||
|
||||
public async Task SignIn()
|
||||
public async Task SignInAsync()
|
||||
{
|
||||
if (User == null)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed class NotificationService : ReactiveObject
|
||||
NoticeTypes = new();
|
||||
}
|
||||
|
||||
public async Task GetNews()
|
||||
public async Task GetNewsAsync()
|
||||
{
|
||||
var data = await notificationRepo.GetAllAsync(w => w.ExpirationTime > DateTimeOffset.Now);
|
||||
UnreadNotificationsCount = data.Count(x => !x.HasRead);
|
||||
@@ -50,7 +50,7 @@ public sealed class NotificationService : ReactiveObject
|
||||
#pragma warning disable CS0618 // 类型或成员已过时
|
||||
Click = new NotificationBuilderClickAction(() =>
|
||||
{
|
||||
IWindowManager.Instance.Show(AppEndPoint.Notice);
|
||||
IWindowManager.Instance.ShowAsync(AppEndPoint.Notice);
|
||||
}),
|
||||
#pragma warning restore CS0618 // 类型或成员已过时
|
||||
});
|
||||
@@ -61,14 +61,14 @@ public sealed class NotificationService : ReactiveObject
|
||||
INotificationService.Instance.Notify(notice);
|
||||
}
|
||||
|
||||
await InsertNotificationRecord(noticeList);
|
||||
await InsertNotificationRecordAsync(noticeList);
|
||||
}
|
||||
|
||||
DeleteExpiredRecordAsync();
|
||||
DeleteExpiredRecord();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task LoadNoticeTypes()
|
||||
public async Task LoadNoticeTypesAsync()
|
||||
{
|
||||
var client = IMicroServiceClient.Instance.Notice;
|
||||
var result = await client.Types();
|
||||
@@ -81,7 +81,7 @@ public sealed class NotificationService : ReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
public async Task LoadNotification(NoticeGroupDTO? selectGroup)
|
||||
public async Task LoadNotificationAsync(NoticeGroupDTO? selectGroup)
|
||||
{
|
||||
var client = IMicroServiceClient.Instance.Notice;
|
||||
var typeid = selectGroup == DefaultType ? null : selectGroup?.Id;
|
||||
@@ -94,12 +94,12 @@ public sealed class NotificationService : ReactiveObject
|
||||
// item.PictureStream = httpService.GetImageAsync(item.Picture, ImageChannelType.NoticePicture);
|
||||
//}
|
||||
NoticesSource.Clear();
|
||||
var data = await LoadHasReadRecord(result.Content.DataSource);
|
||||
var data = await LoadHasReadRecordAsync(result.Content.DataSource);
|
||||
NoticesSource.AddOrUpdate(data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<NoticeDTO>> LoadHasReadRecord(IEnumerable<NoticeDTO> notices)
|
||||
public async Task<IEnumerable<NoticeDTO>> LoadHasReadRecordAsync(IEnumerable<NoticeDTO> notices)
|
||||
{
|
||||
var data = await notificationRepo.GetAllAsync(w => w.ExpirationTime > DateTimeOffset.Now);
|
||||
if (data.Any_Nullable())
|
||||
@@ -118,7 +118,7 @@ public sealed class NotificationService : ReactiveObject
|
||||
return notices;
|
||||
}
|
||||
|
||||
public async Task InsertNotificationRecord(IEnumerable<NoticeDTO> notices)
|
||||
public async Task InsertNotificationRecordAsync(IEnumerable<NoticeDTO> notices)
|
||||
{
|
||||
var data = await notificationRepo.GetAllAsync(w => w.ExpirationTime > DateTimeOffset.Now);
|
||||
var newData = notices
|
||||
@@ -136,14 +136,14 @@ public sealed class NotificationService : ReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
public async Task MarkNotificationHasRead(params Notification[] notice)
|
||||
public async Task MarkNotificationHasReadAsync(params Notification[] notice)
|
||||
{
|
||||
await notificationRepo.UpdateRangeAsync(notice);
|
||||
UnreadNotificationsCount -= notice.Length;
|
||||
UnreadNotificationsCount = UnreadNotificationsCount < 0 ? 0 : UnreadNotificationsCount;
|
||||
}
|
||||
|
||||
public async void DeleteExpiredRecordAsync()
|
||||
public async void DeleteExpiredRecord()
|
||||
{
|
||||
var data = await notificationRepo.GetAllAsync(w => w.ExpirationTime < DateTimeOffset.Now);
|
||||
await notificationRepo.DeleteRangeAsync(data);
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface IWindowManager
|
||||
/// <param name="isDialog"></param>
|
||||
/// <param name="isParent"></param>
|
||||
/// <returns></returns>
|
||||
Task Show<TWindowViewModel>(
|
||||
Task ShowAsync<TWindowViewModel>(
|
||||
AppEndPoint appEndPoint,
|
||||
TWindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
@@ -39,7 +39,7 @@ public interface IWindowManager
|
||||
/// <param name="isDialog"></param>
|
||||
/// <param name="isParent"></param>
|
||||
/// <returns></returns>
|
||||
Task Show(Type typeWindowViewModel,
|
||||
Task ShowAsync(Type typeWindowViewModel,
|
||||
AppEndPoint appEndPoint,
|
||||
WindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
@@ -57,7 +57,7 @@ public interface IWindowManager
|
||||
/// <param name="isDialog"></param>
|
||||
/// <param name="isParent"></param>
|
||||
/// <returns></returns>
|
||||
Task Show(AppEndPoint appEndPoint,
|
||||
Task ShowAsync(AppEndPoint appEndPoint,
|
||||
WindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
ResizeMode resizeMode = ResizeMode.NoResize,
|
||||
@@ -75,7 +75,7 @@ public interface IWindowManager
|
||||
/// <param name="isDialog"></param>
|
||||
/// <param name="isParent"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ShowDialog<TWindowViewModel>(
|
||||
Task<bool> ShowDialogAsync<TWindowViewModel>(
|
||||
AppEndPoint appEndPoint,
|
||||
TWindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
@@ -94,7 +94,7 @@ public interface IWindowManager
|
||||
/// <param name="resizeMode"></param>
|
||||
/// <param name="isDialog"></param>
|
||||
/// <returns></returns>
|
||||
Task ShowDialog(Type typeWindowViewModel,
|
||||
Task ShowDialogAsync(Type typeWindowViewModel,
|
||||
AppEndPoint appEndPoint,
|
||||
WindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
@@ -110,7 +110,7 @@ public interface IWindowManager
|
||||
/// <param name="resizeMode"></param>
|
||||
/// <param name="isDialog"></param>
|
||||
/// <returns></returns>
|
||||
Task ShowDialog(AppEndPoint appEndPoint,
|
||||
Task ShowDialogAsync(AppEndPoint appEndPoint,
|
||||
WindowViewModel? viewModel = null,
|
||||
string title = "",
|
||||
ResizeMode resizeMode = ResizeMode.NoResize,
|
||||
@@ -144,7 +144,7 @@ public interface IWindowManager
|
||||
var windowName = vm.GetType().Name.TrimEnd(nameof(WindowViewModel));
|
||||
if (Enum.TryParse<AppEndPoint>(windowName, out var appEndPoint))
|
||||
{
|
||||
await Show(appEndPoint, vm);
|
||||
await ShowAsync(appEndPoint, vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public sealed partial class MainWindowViewModel : WindowViewModel
|
||||
{
|
||||
foreach (var plugin in StartupOptions.Value.Plugins!)
|
||||
{
|
||||
await plugin.OnInitialize();
|
||||
await plugin.OnInitializeAsync();
|
||||
}
|
||||
}
|
||||
//if (ASFSettings.AutoRunArchiSteamFarm.Value)
|
||||
|
||||
@@ -89,7 +89,7 @@ public class TextBoxWindowViewModel : DialogWindowViewModel, ITextBoxWindowViewM
|
||||
public static async Task<string?> ShowDialogAsync(TextBoxWindowViewModel? vm = null)
|
||||
{
|
||||
vm ??= new TextBoxWindowViewModel();
|
||||
var r = await IWindowManager.Instance.ShowDialog(
|
||||
var r = await IWindowManager.Instance.ShowDialogAsync(
|
||||
AppEndPoint.TextBox,
|
||||
vm, string.Empty, ResizeMode.NoResize);
|
||||
if (r)
|
||||
|
||||
@@ -134,7 +134,7 @@ public static partial class MessageBox
|
||||
IsShowRememberChoose = isDoNotShow,
|
||||
};
|
||||
|
||||
var r = await IWindowManager.Instance.ShowDialog(
|
||||
var r = await IWindowManager.Instance.ShowDialogAsync(
|
||||
AppEndPoint.MessageBox, viewModel, caption, ResizeMode.NoResize);
|
||||
|
||||
if (r && viewModel.RememberChoose && isDoNotShow)
|
||||
|
||||
Reference in New Issue
Block a user