Merge branch 'develop' of https://github.com/SteamTools-Team/SteamTools into develop

This commit is contained in:
Mossimo
2021-08-13 16:54:45 +08:00
30 changed files with 165 additions and 168 deletions
+1 -5
View File
@@ -139,7 +139,7 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston
* [Polly](https://github.com/App-vNext/Polly)
* [TaskScheduler](https://github.com/dahall/taskscheduler)
* [SharpZipLib](https://github.com/icsharpcode/SharpZipLib)
* [LibVLCSharp](https://github.com/videolan/libvlcsharp)
* [SevenZipSharp](https://github.com/squid-box/SevenZipSharp)
* [Depressurizer](https://github.com/Depressurizer/Depressurizer)
* [NLog](https://github.com/nlog/NLog)
* [NUnit](https://github.com/nunit/nunit)
@@ -149,18 +149,14 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston
* [AvaloniaGif](https://github.com/jmacato/AvaloniaGif)
* [Avalonia XAML Behaviors](https://github.com/wieslawsoltes/AvaloniaBehaviors)
* [APNG.NET](https://github.com/jz5/APNG.NET)
* [Chromium Embedded Framework (CEF)](https://github.com/chromiumembedded/cef)
* [Moq](https://github.com/moq/moq4)
* [NPOI](https://github.com/nissl-lab/npoi)
* [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
* [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers)
* [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers)
* [CefNet](https://github.com/CefNet/CefNet)
* [CefSharp](https://github.com/cefsharp/CefSharp)
* [ZXing.Net](https://github.com/micjahn/ZXing.Net)
* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile)
* [QRCoder](https://github.com/codebude/QRCoder)
* [SharpCompress](https://github.com/adamhathcock/sharpcompress)
* [React](https://github.com/facebook/react)
* [Ant Design](https://github.com/ant-design/ant-design)
* [Ant Design Blazor](https://github.com/ant-design-blazor/ant-design-blazor)
+7 -5
View File
@@ -120,6 +120,12 @@
## 🏗️ [项目结构](./src/README.md)
<!--
* [LibVLCSharp](https://github.com/videolan/libvlcsharp)
* [Chromium Embedded Framework (CEF)](https://github.com/chromiumembedded/cef)
* [CefNet](https://github.com/CefNet/CefNet)
* [CefSharp](https://github.com/cefsharp/CefSharp)
-->
<!--👇图标如果发生更改,还需更改 Tools.OpenSourceLibraryList(Program.OpenSourceLibraryListEmoji) -->
## 📄 感谢以下开源项目
* [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)
@@ -151,7 +157,7 @@
* [Polly](https://github.com/App-vNext/Polly)
* [TaskScheduler](https://github.com/dahall/taskscheduler)
* [SharpZipLib](https://github.com/icsharpcode/SharpZipLib)
* [LibVLCSharp](https://github.com/videolan/libvlcsharp)
* [SevenZipSharp](https://github.com/squid-box/SevenZipSharp)
* [Depressurizer](https://github.com/Depressurizer/Depressurizer)
* [NLog](https://github.com/nlog/NLog)
* [NUnit](https://github.com/nunit/nunit)
@@ -161,18 +167,14 @@
* [AvaloniaGif](https://github.com/jmacato/AvaloniaGif)
* [Avalonia XAML Behaviors](https://github.com/wieslawsoltes/AvaloniaBehaviors)
* [APNG.NET](https://github.com/jz5/APNG.NET)
* [Chromium Embedded Framework (CEF)](https://github.com/chromiumembedded/cef)
* [Moq](https://github.com/moq/moq4)
* [NPOI](https://github.com/nissl-lab/npoi)
* [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
* [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers)
* [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers)
* [CefNet](https://github.com/CefNet/CefNet)
* [CefSharp](https://github.com/cefsharp/CefSharp)
* [ZXing.Net](https://github.com/micjahn/ZXing.Net)
* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile)
* [QRCoder](https://github.com/codebude/QRCoder)
* [SharpCompress](https://github.com/adamhathcock/sharpcompress)
* [React](https://github.com/facebook/react)
* [Ant Design](https://github.com/ant-design/ant-design)
* [Ant Design Blazor](https://github.com/ant-design-blazor/ant-design-blazor)
-31
View File
@@ -99,8 +99,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ST.Tools.Packager.Installer
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ST.Tools.Translate", "src\ST.Tools.Translate\ST.Tools.Translate.csproj", "{7A27EDB5-2E6A-4E01-AA55-62C8B3117226}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ST.Tools.Win7Troubleshoot", "src\ST.Tools.Win7Troubleshoot\ST.Tools.Win7Troubleshoot.csproj", "{1A07EEE0-3533-4FD1-8D08-F89129820B1A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ST.Client.Desktop.Avalonia.App", "src\ST.Client.Desktop.Avalonia.App\ST.Client.Desktop.Avalonia.App.csproj", "{1CB40DC8-8FBC-4278-A19A-D872CFA353C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ST.Client.Desktop.Avalonia.Demo.App", "src\ST.Client.Desktop.Avalonia.Demo.App\ST.Client.Desktop.Avalonia.Demo.App.csproj", "{7EC4BAB6-B7C0-4E87-9FB6-091ABFF10D88}"
@@ -1163,34 +1161,6 @@ Global
{7A27EDB5-2E6A-4E01-AA55-62C8B3117226}.Release|x64.Build.0 = Release|Any CPU
{7A27EDB5-2E6A-4E01-AA55-62C8B3117226}.Release|x86.ActiveCfg = Release|Any CPU
{7A27EDB5-2E6A-4E01-AA55-62C8B3117226}.Release|x86.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|ARM.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|ARM64.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|iPhone.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|x64.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|x64.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|x86.ActiveCfg = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Debug|x86.Build.0 = Debug|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|Any CPU.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|ARM.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|ARM.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|ARM64.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|ARM64.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|iPhone.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|iPhone.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|x64.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|x64.Build.0 = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|x86.ActiveCfg = Release|Any CPU
{1A07EEE0-3533-4FD1-8D08-F89129820B1A}.Release|x86.Build.0 = Release|Any CPU
{1CB40DC8-8FBC-4278-A19A-D872CFA353C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CB40DC8-8FBC-4278-A19A-D872CFA353C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CB40DC8-8FBC-4278-A19A-D872CFA353C0}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -1558,7 +1528,6 @@ Global
{2BF2DA87-7F0E-4384-AF80-275D495A1972} = {E448F863-4C9D-47A4-BC4A-4A1381B54DA4}
{A4E53C27-0195-47D3-9DC7-192061402BB8} = {E448F863-4C9D-47A4-BC4A-4A1381B54DA4}
{7A27EDB5-2E6A-4E01-AA55-62C8B3117226} = {E448F863-4C9D-47A4-BC4A-4A1381B54DA4}
{1A07EEE0-3533-4FD1-8D08-F89129820B1A} = {E448F863-4C9D-47A4-BC4A-4A1381B54DA4}
{9A8D2254-9B2B-4B92-8498-43A73BB9A410} = {E448F863-4C9D-47A4-BC4A-4A1381B54DA4}
{F4D8CD7B-6DF4-445C-AFA9-44466A552922} = {673FF8CD-9E85-4FA1-ABFC-D1149675E138}
{1F659618-71E2-4AAF-9D86-62700FD4CF02} = {1B889C56-157A-4493-85F2-76366282B002}
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -9,9 +9,8 @@
7. 新增 意大利语支持
8. 新增 西班牙语支持
9. 新增 通用设置内可支持访问程序的 AppData、Cache、Logs 文件夹和查看缓存及日志占用空间大小情况
10. 新增 hosts 文件编码设置项,可在 Windows 上使用系统的活动代码页(ANSICodePage),例如 GB2312/936
11. Android/macOS/Linux 版现已开启 Beta/Alpha 测试,可从 GitHub/Gitee 上下载
12. 现已通过 Desktop Bridge 转制为 UWP 上架 Microsoft Store
10. Android/macOS/Linux 版现已开启 Beta/Alpha 测试,可从 GitHub/Gitee 上下载
11. 现已通过 Desktop Bridge 转制为 UWP 上架 Microsoft Store
### 修复问题
1. 修复 开机自启动在 2.4.x 中不生效
@@ -38,6 +37,7 @@
22. 改进 移除了CEF模块,缩减程序体积和运行时内存占用
23. 改进 库存游戏支持显示已安装游戏占用空间大小
24. 改进 库存游戏封面大小调节可支持滚动调节
25. 改进 hosts 文件编码在 Windows 上使用系统的活动代码页(ANSICodePage),例如 GB2312/936,其他操作系统则使用 UTF-8,还原 V1 版本行为
***
<!-- 1. 新增 ASF Plus 本地挂卡
+3 -1
View File
@@ -1,4 +1,4 @@
namespace System.Common
namespace System.Common
{
public static class Constants
{
@@ -53,5 +53,7 @@
public const long TimestampMillisecondsMaxValue = 253402300799999;
public const string N = "N";
public const float MaxProgress = 100f;
}
}
+4 -4
View File
@@ -32,11 +32,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
<!--<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.2" />-->
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
</ItemGroup>
@@ -1,8 +1,10 @@
using System.Runtime.Versioning;
using Windows.Storage;
// ReSharper disable once CheckNamespace
namespace System.Application
{
[SupportedOSPlatform("Windows10.0.10240.0")]
static class FileSystemDesktopBridge
{
internal static void InitFileSystem()
@@ -91,6 +91,9 @@
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<ProjectReference Include="..\ST.Client.Desktop.Windows\ST.Client.Desktop.Windows.csproj" />
<None Include="..\..\references\7z.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!--<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) And $(DefineConstants.Contains(`PUBLISH`)) ">
@@ -13,34 +13,6 @@ namespace System.Application.Converters
{
(var length, string unit) = IOPath.GetSize(b);
return $"{length:###,###.##} {unit}";
//if (b > 0)
//{
// if (b > SizeUnit)
// {
// var kb = b / SizeUnit;
// if (kb > SizeUnit)
// {
// var mb = kb / SizeUnit;
// if (mb > SizeUnit)
// {
// var gb = mb / SizeUnit;
// if (gb > SizeUnit)
// {
// var tb = gb / SizeUnit;
// return tb.ToString("###,###.##") + " TB";
// }
// return gb.ToString("###,###.##") + " GB";
// }
// return mb.ToString("###,###.##") + " MB";
// }
// return kb.ToString("###,###.##") + " KB";
// }
// return b.ToString("###,###.##") + " B";
//}
//else
//{
// return "0 B";
//}
}
return value;
}
@@ -359,19 +359,27 @@
Foreground="#FFFFFFFF"
IsVisible="{Binding LibraryLogoStream^,Converter={StaticResource IsNullConverter}}"/>
<Border IsVisible="{Binding IsInstalled}"
Margin="20 0 20 -5"
Margin="20 0 20 -3"
CornerRadius="3"
Classes="paper"
Background="#3D4450"
HorizontalAlignment="Center"
VerticalAlignment="Bottom">
<TextBlock Text="{Binding SizeOnDisk,Converter={StaticResource SizeConverter}}"
Foreground="#FFFFFFFF"
TextWrapping="Wrap"
Margin="10 3"
HorizontalAlignment="Center"
TextAlignment="Center"
FontSize="12"/>
<StackPanel Margin="15 3"
Orientation="Horizontal"
Spacing="3"
HorizontalAlignment="Center">
<TextBlock Text="{Binding InstalledDrive}"
IsVisible="{Binding InstalledDrive,Converter={StaticResource IsNullConverter},ConverterParameter=invert}"
VerticalAlignment="Center"
FontSize="12"/>
<TextBlock Text="{Binding SizeOnDisk,Converter={StaticResource SizeConverter}}"
Foreground="#FFFFFFFF"
TextWrapping="Wrap"
VerticalAlignment="Center"
TextAlignment="Center"
FontSize="12"/>
</StackPanel>
</Border>
</Panel>
</Border>
@@ -27,7 +27,7 @@
<StackPanel Grid.Row="2" x:Name="content">
<ScrollViewer MaxHeight="400" Padding="12 10 12 0">
<StackPanel Spacing="8">
<TextBlock Text="{ReflectionBinding Path=Res.UpdateContent,Mode=OneWay,Source={x:Static resx:R.Current}}"
<TextBlock Text="{ReflectionBinding Path=Res.UpdateContent,Mode=OneWay,Source={x:Static resx:R.Current}}"
FontSize="19"/>
<TextBlock Text="{ReflectionBinding Path=NewVersionInfoDesc,Mode=OneWay,Source={x:Static ccl_services:IAppUpdateService.Instance}}"
MaxWidth="596"
@@ -66,6 +66,7 @@
Padding="30,6"
Margin="10,0,0,10"
IsDefault="True"
IsEnabled="{ReflectionBinding Path=IsNotStartUpdateing,Mode=OneWay,Source={x:Static ccl_services:IAppUpdateService.Instance}}"
Content="{ReflectionBinding Path=Res.StartUpdate,Mode=OneWay,Source={x:Static resx:R.Current}}"
Command="{ReflectionBinding Path=StartUpdateCommand,Mode=OneWay,Source={x:Static ccl_services:IAppUpdateService.Instance}}"/>
<Button
@@ -74,6 +75,7 @@
Padding="30,6"
Margin="10,0,0,10"
IsCancel="True"
IsEnabled="{ReflectionBinding Path=IsNotStartUpdateing,Mode=OneWay,Source={x:Static ccl_services:IAppUpdateService.Instance}}"
Content="{ReflectionBinding Path=Res.DoNotUpdate,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
</WrapPanel>
</Grid>
@@ -78,5 +78,4 @@
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
@@ -85,8 +85,8 @@ namespace System.Application.Services.Implementation
//InstalledDir = GetAppInstallDir(s.AppId),
//IsInstalled = IsAppInstalled(s.AppId)
//s.IsInstalled = IsAppInstalled(s.AppId);
//s.InstalledDir = GetAppInstallDir(s.AppId);
s.Type = Enum.TryParse<SteamAppType>(GetAppData(s.AppId, "type"), true, out var result) ? result : SteamAppType.Unknown;
s.InstalledDir = GetAppInstallDir(s.AppId);
return s;
}).ToList();
}
+2
View File
@@ -53,6 +53,8 @@ namespace System.Application.Models
//public bool IsInstalled { get; set; }
public bool IsInstalled => IsBitSet(State, 2);
public string? InstalledDrive => !string.IsNullOrEmpty(InstalledDir) ? Path.GetPathRoot(InstalledDir)?.ToUpper()?.Replace(Path.DirectorySeparatorChar.ToString(), "") : null;
public string? InstalledDir { get; set; }
public string? Name { get; set; }
@@ -42,8 +42,8 @@
<PackageReference Include="Gameloop.Vdf" Version="0.6.1" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.3" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="SharpZipLib" Version="1.3.2" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.4.0.345" />
<PackageReference Include="StatefulModel.Standard" Version="0.1.0" />
<!--<PackageReference Include="Titanium.Web.Proxy" Version="3.1.1344" />-->
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
@@ -7,7 +7,7 @@ namespace System.Application.Services
/// </summary>
public interface IHostsFileService
{
const string TAG = "HostsFileS";
protected const string TAG = "HostsFileS";
public static IHostsFileService Instance => DI.Get<IHostsFileService>();
@@ -58,8 +58,8 @@ namespace System.Application.Services
/// <returns></returns>
OperationResult RemoveHostsByTag();
static bool mOnExitRestoreHosts;
static readonly object mOnExitRestoreHostsLock = new();
private static bool mOnExitRestoreHosts;
private static readonly object mOnExitRestoreHostsLock = new();
/// <summary>
/// 当程序退出时还原 hosts 文件
@@ -76,17 +76,17 @@ namespace System.Application.Services
bool ContainsHostsByTag();
public enum EncodingType : byte
enum EncodingType : byte
{
UTF8,
UTF8WithBOM,
/// <summary>
/// 系统的活动代码页并创建 Encoding 与其对应的对象。
/// 活动代码页可能是 ANSI 代码页,其中包括 ASCII 字符集以及不同于代码页的其他字符。
/// </summary>
ANSICodePage,
UTF8,
UTF8WithBOM,
}
}
}
@@ -6,7 +6,8 @@ using System.Diagnostics;
using System.IO;
using System.Properties;
using System.Text;
using static System.Application.Services.IAppUpdateService;
using System.Threading.Tasks;
using CC = System.Common.Constants;
namespace System.Application.Services.Implementation
{
@@ -25,7 +26,7 @@ namespace System.Application.Services.Implementation
/// </summary>
protected abstract void OnExit();
protected override void OverwriteUpgrade(string value, bool isIncrement, AppDownloadType downloadType)
protected override async void OverwriteUpgrade(string value, bool isIncrement, AppDownloadType downloadType)
{
if (isIncrement) // 增量更新
{
@@ -40,28 +41,29 @@ namespace System.Application.Services.Implementation
Directory.Delete(dirPath, true);
}
var isOK = downloadType switch
var isOK = await Task.Run(() => downloadType switch
{
AppDownloadType.Compressed_GZip
=> TarGZipHelper.Unpack(value, dirPath,
progress: new Progress<float>(OnReportDecompressing),
maxProgress: MaxProgressValue),
maxProgress: CC.MaxProgress),
AppDownloadType.Compressed_7z
=> SevenZipHelper.Unpack(value, dirPath,
progress: new Progress<float>(OnReportDecompressing),
maxProgress: MaxProgressValue),
_ => throw new NotSupportedException(),
};
maxProgress: CC.MaxProgress),
_ => false,
});
if (isOK)
{
OnReport(MaxProgressValue);
OnReport(CC.MaxProgress);
IOPath.FileTryDelete(value);
OverwriteUpgradePrivate(dirPath);
}
else
{
toast.Show(SR.UpdateUnpackFail);
OnReport(MaxProgressValue);
OnReport(CC.MaxProgress);
IsNotStartUpdateing = true;
}
}
@@ -190,6 +190,7 @@ namespace System.Application.Services.Implementation
}
return users;
}
public bool UpdateAuthorizedDeviceList(IEnumerable<AuthorizedDevice> model)
{
var authorizeds = new List<AuthorizedDevice>();
@@ -236,6 +236,7 @@ namespace System.Application.Services
if (SteamApps.Items.Any())
{
LoadGames(ApiService.OwnsApps(await ISteamService.Instance.GetAppInfos()));
InitializeDownloadGameList();
}
//var mainViewModel = (IWindowService.Instance.MainWindow as WindowViewModel);
//await mainViewModel.SteamAppPage.Initialize();
+18 -44
View File
@@ -1,15 +1,21 @@
using SharpCompress.Archives;
using SharpCompress.Archives.SevenZip;
using SharpCompress.Common;
using SevenZip;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CC = System.Common.Constants;
namespace System.Application
{
public static class SevenZipHelper
{
static SevenZipHelper()
{
if (DI.Platform == Platform.Windows)
{
// ✅ AppContext.BaseDirectory
var sevenZipLibraryPath = Path.Combine(AppContext.BaseDirectory, "7z.dll");
SevenZipBase.SetLibraryPath(sevenZipLibraryPath);
}
}
/// <summary>
/// 解压压缩包文件
/// </summary>
@@ -20,58 +26,26 @@ namespace System.Application
/// <returns></returns>
public static bool Unpack(string filePath, string dirPath,
IProgress<float>? progress = null,
float maxProgress = 100f)
float maxProgress = CC.MaxProgress)
{
if (!File.Exists(filePath)) return false;
if (Directory.Exists(dirPath)) return false;
using var fs = File.OpenRead(filePath);
float length = fs.Length;
var isFinish = false;
CancellationTokenSource? cts = null;
async void ProgressMonitor()
{
try
{
while (!isFinish)
{
var value = fs.Position / length * maxProgress;
progress!.Report(value);
await Task.Delay(200, cts.Token);
}
}
catch (OperationCanceledException)
{
}
}
Directory.CreateDirectory(dirPath);
using var archive = SevenZipArchive.Open(fs);
using var archive = new SevenZipExtractor(fs);
var hasProgress = progress != null;
if (hasProgress)
{
cts = new();
try
archive.Extracting += (_, e) =>
{
Task.Factory.StartNew(ProgressMonitor, cts.Token);
}
catch (OperationCanceledException)
{
}
progress!.Report(e.PercentDone);
};
}
var files = archive.Entries.Where(entry => !entry.IsDirectory).ToArray();
for (int i = 0; i < files.Length; i++)
{
var file = files[i];
file.WriteToDirectory(dirPath, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
isFinish = true;
archive.ExtractArchive(dirPath);
if (hasProgress)
{
cts!.Cancel();
progress!.Report(maxProgress);
}
return true;
+3 -2
View File
@@ -5,6 +5,7 @@ using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CC = System.Common.Constants;
namespace System.Application
{
@@ -16,7 +17,7 @@ namespace System.Application
/// <param name="filePath">要创建的文件路径</param>
/// <param name="dirPath">要打包的目录</param>
/// <param name="level">压缩等级,取值范围在 <see cref="Deflater.NO_COMPRESSION"/> ~ <see cref="Deflater.BEST_COMPRESSION"/></param>
/// <param name="progressMessage">进度消息监听</param>
/// <param name="progress">进度值监听</param>
/// <returns></returns>
public static bool Create(string filePath, string dirPath, int level = Deflater.BEST_COMPRESSION, ProgressMessageHandler? progress = null)
{
@@ -66,7 +67,7 @@ namespace System.Application
public static bool Unpack(string filePath, string dirPath,
ProgressMessageHandler? progressMessage = null,
IProgress<float>? progress = null,
float maxProgress = 100f)
float maxProgress = CC.MaxProgress)
{
if (!File.Exists(filePath)) return false;
if (Directory.Exists(dirPath)) return false;
@@ -103,7 +103,7 @@ namespace System.Application.UI.ViewModels
.Filter(typeFilter)
.Filter(installFilter)
.ObserveOn(RxApp.MainThreadScheduler)
.Sort(SortExpressionComparer<SteamApp>.Ascending(x => x.DisplayName))
.Sort(SortExpressionComparer<SteamApp>.Ascending(x => x.DisplayName).ThenByDescending(s => s.SizeOnDisk))
.Bind(out _SteamApps)
.Subscribe(_ =>
{
@@ -6,7 +6,7 @@ using System.Application.Models;
using System.Windows;
using XEPlatform = Xamarin.Essentials.Platform;
using static System.Application.UI.Resx.AppResources;
using static System.Application.Services.IAppUpdateService;
using CC = System.Common.Constants;
namespace System.Application.Services.Implementation
{
@@ -56,13 +56,13 @@ namespace System.Application.Services.Implementation
base.OnReport(value, str);
if (value == 0)
{
progress?.Report(MaxProgressValue);
progress?.Report(CC.MaxProgress);
progress = notification.NotifyDownload(() => ProgressString,
NotificationType.NewVersionDownloadProgress);
}
else if (value == MaxProgressValue)
else if (value == CC.MaxProgress)
{
progress?.Report(MaxProgressValue);
progress?.Report(CC.MaxProgress);
progress = null;
}
else
Binary file not shown.
+2 -2
View File
@@ -13,13 +13,13 @@ namespace System.Application.Services
{
static IAppUpdateService Instance => DI.Get<IAppUpdateService>();
const float MaxProgressValue = 100f;
/// <summary>
/// 升级包存放文件夹名称
/// </summary>
const string PackDirName = "UpgradePackages";
bool IsNotStartUpdateing { get; }
/// <summary>
/// 进度值
/// </summary>
@@ -11,6 +11,7 @@ using System.Threading.Tasks;
using System.Windows.Input;
using static System.Application.Services.CloudService.Constants;
using static System.Application.Services.IAppUpdateService;
using CC = System.Common.Constants;
namespace System.Application.Services.Implementation
{
@@ -155,6 +156,13 @@ namespace System.Application.Services.Implementation
/// </summary>
const bool isSupportedResume = false;
bool _IsNotStartUpdateing = true;
public bool IsNotStartUpdateing
{
get => _IsNotStartUpdateing;
protected set => this.RaiseAndSetIfChanged(ref _IsNotStartUpdateing, value);
}
float _ProgressValue;
public float ProgressValue
{
@@ -190,7 +198,7 @@ namespace System.Application.Services.Implementation
onReportCalcHashing(0);
var sha256_ = Hashs.String.SHA256(File.OpenRead(filePath)); // 改为带进度的哈希计算
var value = string.Equals(sha256_, sha256, StringComparison.OrdinalIgnoreCase);
onReportCalcHashing(MaxProgressValue);
onReportCalcHashing(CC.MaxProgress);
return value;
}
@@ -203,6 +211,8 @@ namespace System.Application.Services.Implementation
/// </summary>
protected async void DownloadUpdate()
{
var isCallOverwriteUpgrade = false;
if (isDownloading) return;
if (!IsSupportedServerDistribution) throw new PlatformNotSupportedException();
@@ -354,10 +364,10 @@ namespace System.Application.Services.Implementation
#endregion
for_end: i++;
OnReportDownloading3_(i / (float)allFiles.Count * MaxProgressValue);
OnReportDownloading3_(i / (float)allFiles.Count * CC.MaxProgress);
}
OnReport(MaxProgressValue);
OnReport(CC.MaxProgress);
OverwriteUpgrade(packDirPath, isIncrement: true);
}
else // 全量更新
@@ -390,7 +400,8 @@ namespace System.Application.Services.Implementation
{
if (UpdatePackVerification(packFilePath, download!.SHA256!)) // (已有文件)哈希验证成功,进行覆盖安装
{
OverwriteUpgrade(packFilePath, isIncrement: false);
isCallOverwriteUpgrade = true;
OverwriteUpgrade(packFilePath, isIncrement: false, downloadType: download.DownloadType);
goto end;
}
else // 验证文件失败,删除源文件,将会重新下载
@@ -476,6 +487,7 @@ namespace System.Application.Services.Implementation
requestUri: requestUri,
cacheFilePath,
new Progress<float>(OnReportDownloading));
OnReportDownloading(CC.MaxProgress);
if (rsp.IsSuccess)
{
@@ -483,8 +495,8 @@ namespace System.Application.Services.Implementation
if (UpdatePackVerification(packFilePath, download!.SHA256!)) // (下载文件)哈希验证成功,进行覆盖安装
{
OverwriteUpgrade(packFileName, isIncrement: false, downloadType: download.DownloadType);
OnReportDownloading(MaxProgressValue);
isCallOverwriteUpgrade = true;
OverwriteUpgrade(packFilePath, isIncrement: false, downloadType: download.DownloadType);
}
else
{
@@ -504,10 +516,14 @@ namespace System.Application.Services.Implementation
}
end: isDownloading = false;
if (!isCallOverwriteUpgrade)
{
IsNotStartUpdateing = true;
}
void Fail(string error)
{
toast.Show(error);
OnReport(MaxProgressValue);
OnReport(CC.MaxProgress);
}
}
@@ -533,6 +549,7 @@ namespace System.Application.Services.Implementation
NewVersionInfo.HasValue() &&
!NewVersionInfo!.DisableAutomateUpdate)
{
IsNotStartUpdateing = false;
DownloadUpdate();
}
else
@@ -17,6 +17,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Application.Services.CloudService.Constants.Headers.Request;
using CC = System.Common.Constants;
using JsonSerializer = Newtonsoft.Json.JsonSerializer;
namespace System.Application.Services.CloudService
@@ -846,7 +847,7 @@ namespace System.Application.Services.CloudService
totalRead += read;
if (canReportProgress)
{
var progressValue = MathF.Round((float)totalRead / total, 2, MidpointRounding.AwayFromZero);
var progressValue = MathF.Round((float)totalRead / total * CC.MaxProgress, 2, MidpointRounding.AwayFromZero);
if (progressValue != lastProgressValue)
{
progress?.Report(progressValue);
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
@@ -16,6 +16,9 @@
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.Version.cs">
<Link>Properties\AssemblyInfo.Version.cs</Link>
</Compile>
<Compile Include="..\Common.CoreLib\Common\Constants.cs">
<Link>Common\Constants.cs</Link>
</Compile>
<Compile Include="..\Common.CoreLib\Properties\ThisAssembly.cs">
<Link>Properties\ThisAssembly.cs</Link>
</Compile>
+40
View File
@@ -5,6 +5,9 @@ using System.Application.Services.Implementation;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using R = System.Application.Properties.Resources;
namespace System.Application
@@ -33,6 +36,7 @@ namespace System.Application
File.WriteAllLines(tempFileName, hosts);
var mock_dps = new Mock<IDesktopPlatformService>();
mock_dps.Setup(x => x.HostsFilePath).Returns(tempFileName);
mock_dps.Setup(x => x.Default).Returns(DefaultEncoding);
IDesktopPlatformService dps = mock_dps.Object;
IHostsFileService s = new HostsFileServiceImpl(dps);
action(hosts, s, dps);
@@ -40,6 +44,42 @@ namespace System.Application
tempFileNames.Remove(tempFileName);
}
#region DefaultEncoding
static volatile Encoding? defaultEncoding;
static Encoding DefaultEncoding
{
get
{
if (DI.IsWindowsOrUWP)
{
if (defaultEncoding == null)
{
defaultEncoding = CreateDefaultEncoding();
}
return defaultEncoding;
}
else
{
return Encoding.Default;
}
}
}
static Encoding CreateDefaultEncoding()
{
int codePage = GetACP();
var encoding = CodePagesEncodingProvider.Instance.GetEncoding(codePage);
return encoding ?? Encoding.Default;
}
[DllImport("kernel32.dll")]
[ResourceExposure(ResourceScope.None)]
static extern int GetACP();
#endregion
static bool TestEquals(IEnumerable<(string ip, string domain)> left, IEnumerable<(string ip, string domain)> right)
{
if (left.Count() != right.Count()) return false;