mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 11:39:56 +08:00
fix Res Link
This commit is contained in:
@@ -240,14 +240,14 @@ namespace System
|
||||
/// <summary>
|
||||
/// 判断路径是否为[文件夹(Dir)]
|
||||
/// </summary>
|
||||
/// <param name="IOPath"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsDirectory(string IOPath)
|
||||
public static bool IsDirectory(string path)
|
||||
{
|
||||
#if NET35
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
var attr = File.GetAttributes(IOPath);
|
||||
var attr = File.GetAttributes(path);
|
||||
return attr.HasFlag(FileAttributes.Directory);
|
||||
#endif
|
||||
}
|
||||
@@ -257,21 +257,21 @@ namespace System
|
||||
/// <para>如果传入的参数为[文件(File)]路径,则返回当前所在[文件夹(Dir)]路径</para>
|
||||
/// <para>如果传入的参数为[文件夹(Dir)]路径,则直接返回参数</para>
|
||||
/// </summary>
|
||||
/// <param name="IOPath"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDirectoryPath(string IOPath)
|
||||
public static string GetDirectoryPath(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsDirectory(IOPath))
|
||||
if (!IsDirectory(path))
|
||||
{
|
||||
return Path.GetDirectoryName(IOPath) ?? string.Empty;
|
||||
return Path.GetDirectoryName(path) ?? string.Empty;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return IOPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
static FileStream OpenReadCore(string filePath) => new(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace System.Properties
|
||||
case Platform.Linux:
|
||||
return Version + alpha;
|
||||
case Platform.Android:
|
||||
return Version + beta;
|
||||
return Version + alpha;
|
||||
case Platform.Apple:
|
||||
switch (DI.DeviceIdiom)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Startup2.cs" />
|
||||
<Compile Include="..\Startup2.HandleGlobalException.cs" />
|
||||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
using NLog;
|
||||
using ReactiveUI;
|
||||
using System.Application.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using AvaloniaApplication = Avalonia.Application;
|
||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||
|
||||
namespace System.Application.UI
|
||||
{
|
||||
static partial class Program
|
||||
{
|
||||
static Logger? logger;
|
||||
static readonly HashSet<Exception> exceptions = new();
|
||||
static readonly object lock_global_ex_log = new();
|
||||
|
||||
@@ -27,7 +21,6 @@ namespace System.Application.UI
|
||||
#if MAC
|
||||
AppDelegateHelper.Init(args);
|
||||
FileSystemDesktopMac.InitFileSystem();
|
||||
//FileSystemDesktop.InitFileSystem();
|
||||
#else
|
||||
FileSystemDesktop.InitFileSystem();
|
||||
#endif
|
||||
@@ -48,19 +41,7 @@ namespace System.Application.UI
|
||||
void InitCefNetApp() => CefNetApp.Init(AppHelper.LogDirPath, args);
|
||||
void InitAvaloniaApp() => BuildAvaloniaAppAndStartWithClassicDesktopLifetime(args);
|
||||
void InitStartup(DILevel level) => Startup.Init(level);
|
||||
logger = LogManager.GetCurrentClassLogger();
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
|
||||
{
|
||||
if (e.ExceptionObject is Exception ex)
|
||||
{
|
||||
HandleGlobalException(ex, nameof(AppDomain.UnhandledException), e.IsTerminating);
|
||||
}
|
||||
};
|
||||
RxApp.DefaultExceptionHandler = Observer.Create<Exception>(ex =>
|
||||
{
|
||||
// https://github.com/AvaloniaUI/Avalonia/issues/5290#issuecomment-760751036
|
||||
HandleGlobalException(ex, nameof(RxApp.DefaultExceptionHandler));
|
||||
});
|
||||
Startup.InitGlobalExceptionHandler();
|
||||
try
|
||||
{
|
||||
string[] args_clt;
|
||||
@@ -77,7 +58,7 @@ namespace System.Application.UI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleGlobalException(ex, nameof(Main));
|
||||
Startup.GlobalExceptionHandler(ex, nameof(Main));
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
@@ -87,85 +68,12 @@ namespace System.Application.UI
|
||||
LogManager.Shutdown();
|
||||
ArchiSteamFarm.LogManager.Shutdown();
|
||||
}
|
||||
|
||||
static void HandleGlobalException(Exception ex, string name, bool? isTerminating = null)
|
||||
{
|
||||
lock (lock_global_ex_log)
|
||||
{
|
||||
if (exceptions.Contains(ex)) return;
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
|
||||
AppHelper.TrySetLoggerMinLevel(LogLevel.Trace);
|
||||
// NLog: catch any exception and log it.
|
||||
logger?.Error(ex, "Stopped program because of exception, name: {1}, isTerminating: {0}", isTerminating, name);
|
||||
|
||||
try
|
||||
{
|
||||
DI.Get<IHttpProxyService>().StopProxy();
|
||||
ProxyService.OnExitRestoreHosts();
|
||||
}
|
||||
catch (Exception ex_restore_hosts)
|
||||
{
|
||||
logger?.Error(ex_restore_hosts, "(App)Close exception when OnExitRestoreHosts");
|
||||
}
|
||||
|
||||
var callTryShutdown = true;
|
||||
try
|
||||
{
|
||||
callTryShutdown = !App.Shutdown();
|
||||
}
|
||||
catch (Exception ex_shutdown)
|
||||
{
|
||||
logger?.Error(ex_shutdown,
|
||||
"(App)Close exception when exception occurs");
|
||||
}
|
||||
|
||||
if (callTryShutdown)
|
||||
{
|
||||
try
|
||||
{
|
||||
AppHelper.TryShutdown();
|
||||
}
|
||||
catch (Exception ex_shutdown_app_helper)
|
||||
{
|
||||
logger?.Error(ex_shutdown_app_helper,
|
||||
"(AppHelper)Close exception when exception occurs");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (AvaloniaApplication.Current is App app)
|
||||
{
|
||||
app.compositeDisposable.Dispose();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
//MessageBoxCompat.Show(ex.ToString(), "Steam++ Run Error" + ThisAssembly.Version, MessageBoxButtonCompat.OK, MessageBoxImageCompat.Warning);
|
||||
#endif
|
||||
|
||||
#if DEBUG && WINDOWS
|
||||
if (ex.InnerException is BadImageFormatException)
|
||||
{
|
||||
typeof(Program).Assembly.ManifestModule.GetPEKind(out var peKind, out var _);
|
||||
if (!peKind.HasFlag(Reflection.PortableExecutableKinds.Required32Bit))
|
||||
{
|
||||
logger?.Error("Some references need to work on X86 platforms.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否最小化启动
|
||||
/// </summary>
|
||||
public static bool IsMinimize { get; /*private*/ set; }
|
||||
public static bool IsMinimize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前是否是命令行工具进程
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Startup2.cs" />
|
||||
<Compile Include="..\Startup2.HandleGlobalException.cs" />
|
||||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
@@ -144,22 +145,19 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<!--AppSettings namespacePrefix = "System.Application.UI.Resources."-->
|
||||
<ItemGroup Condition="Exists('$(MSBuildProjectDirectory)\..\..\aes-key.pfx')">
|
||||
<EmbeddedResource Include="..\..\aes-key.pfx" Link="Resources\3A613E8D" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-debug.pfx" Link="Resources\0093BF84" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-debug.pfx" Link="Resources\6D72ED26" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-release.pfx" Link="Resources\F1D827AB" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-release.pfx" Link="Resources\E88CA4F9" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -74,10 +74,10 @@
|
||||
<ProjectReference Include="..\ST.Client.Desktop\ST.Client.Desktop.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--VisualStudioAppCenterSDK namespacePrefix = "System.Application.Resources."-->
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-mac-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-mac-debug.pfx" Link="Resources\547E2811" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-mac-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-mac-release.pfx" Link="Resources\93850BFE" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -45,10 +45,10 @@
|
||||
<ProjectReference Include="..\ST.Client.Desktop\ST.Client.Desktop.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--VisualStudioAppCenterSDK namespacePrefix = "System.Application.Resources."-->
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-debug.pfx" Link="Resources\7EE83DD3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-release.pfx" Link="Resources\0794704F" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace System.Application
|
||||
{
|
||||
var assembly = typeof(VisualStudioAppCenterSDK).Assembly;
|
||||
const string namespacePrefix = "System.Application.Resources.";
|
||||
Stream? func(string x) => assembly.GetManifestResourceStream(x);
|
||||
Stream? func(string x) => assembly!.GetManifestResourceStream(x);
|
||||
var r = GetResValue(func,
|
||||
#if XAMARIN_MAC || MONO_MAC || MAC
|
||||
"appcenter-secret-mac",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Startup2.cs" />
|
||||
<Compile Include="..\Startup2.HandleGlobalException.cs" />
|
||||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
@@ -166,34 +167,30 @@
|
||||
<ProjectReference Include="..\ST.Client.Mobile\ST.Client.Mobile.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--VisualStudioAppCenterSDK namespacePrefix = "System.Application.Resources."-->
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-android-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-android-debug.pfx" Link="UI\Resources\D0702261" />
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-android-debug.pfx" Link="Resources\D0702261" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\appcenter-secret-android-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-android-release.pfx" LinkBase="UI\Resources\5C6F1F18" />
|
||||
<EmbeddedResource Include="..\..\appcenter-secret-android-release.pfx" LinkBase="Resources\5C6F1F18" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--AppSettings namespacePrefix = "System.Application.UI.Resources."-->
|
||||
<ItemGroup Condition="Exists('$(MSBuildProjectDirectory)\..\..\aes-key.pfx')">
|
||||
<EmbeddedResource Include="..\..\aes-key.pfx" Link="UI\Resources\3A613E8D" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-debug.pfx" Link="UI\Resources\0093BF84" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-debug.pfx" Link="UI\Resources\6D72ED26" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-release.pfx" Link="UI\Resources\F1D827AB" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-release.pfx" Link="UI\Resources\E88CA4F9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="Exists('$(MSBuildProjectDistringsrectory)\..\..\masl-client-id.pfx')">
|
||||
<EmbeddedResource Include="..\..\masl-client-id.pfx" Link="UI\Resources\A608D029" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace System.Application.UI
|
||||
|
||||
AppHelper.InitLogDir();
|
||||
|
||||
Startup.InitGlobalExceptionHandler();
|
||||
|
||||
VisualStudioAppCenterSDK.Init();
|
||||
|
||||
XEFileProvider.TemporaryLocation = FileProviderLocation.Internal;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
using NLog;
|
||||
using ReactiveUI;
|
||||
using System.Application.Services;
|
||||
using System.Application.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive;
|
||||
#if !__MOBILE__
|
||||
using AvaloniaApplication = Avalonia.Application;
|
||||
#endif
|
||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||
|
||||
namespace System.Application
|
||||
{
|
||||
partial class Startup
|
||||
{
|
||||
static readonly Lazy<Logger> _logger = new(LogManager.GetCurrentClassLogger);
|
||||
static Logger? Logger => _logger.Value;
|
||||
static readonly HashSet<Exception> exceptions = new();
|
||||
static readonly object lock_global_ex_log = new();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化全局异常处理
|
||||
/// </summary>
|
||||
public static void InitGlobalExceptionHandler()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
|
||||
{
|
||||
if (e.ExceptionObject is Exception ex)
|
||||
{
|
||||
GlobalExceptionHandler(ex, nameof(AppDomain.UnhandledException), e.IsTerminating);
|
||||
}
|
||||
};
|
||||
RxApp.DefaultExceptionHandler = Observer.Create<Exception>(ex =>
|
||||
{
|
||||
// https://github.com/AvaloniaUI/Avalonia/issues/5290#issuecomment-760751036
|
||||
GlobalExceptionHandler(ex, nameof(RxApp.DefaultExceptionHandler));
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全局异常处理
|
||||
/// </summary>
|
||||
/// <param name="ex"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="isTerminating"></param>
|
||||
public static void GlobalExceptionHandler(Exception ex, string name, bool? isTerminating = null)
|
||||
{
|
||||
lock (lock_global_ex_log)
|
||||
{
|
||||
if (exceptions.Contains(ex)) return;
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
|
||||
AppHelper.TrySetLoggerMinLevel(LogLevel.Trace);
|
||||
// NLog: catch any exception and log it.
|
||||
Logger?.Error(ex, "Stopped program because of exception, name: {1}, isTerminating: {0}", isTerminating, name);
|
||||
|
||||
#if !__MOBILE__
|
||||
try
|
||||
{
|
||||
DI.Get<IHttpProxyService>().StopProxy();
|
||||
ProxyService.OnExitRestoreHosts();
|
||||
}
|
||||
catch (Exception ex_restore_hosts)
|
||||
{
|
||||
Logger?.Error(ex_restore_hosts, "(App)Close exception when OnExitRestoreHosts");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__MOBILE__
|
||||
var callTryShutdown = true;
|
||||
try
|
||||
{
|
||||
callTryShutdown = !App.Shutdown();
|
||||
}
|
||||
catch (Exception ex_shutdown)
|
||||
{
|
||||
Logger?.Error(ex_shutdown,
|
||||
"(App)Close exception when exception occurs");
|
||||
}
|
||||
|
||||
if (callTryShutdown)
|
||||
{
|
||||
try
|
||||
{
|
||||
AppHelper.TryShutdown();
|
||||
}
|
||||
catch (Exception ex_shutdown_app_helper)
|
||||
{
|
||||
Logger?.Error(ex_shutdown_app_helper,
|
||||
"(AppHelper)Close exception when exception occurs");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (AvaloniaApplication.Current is App app)
|
||||
{
|
||||
app.compositeDisposable.Dispose();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -43,7 +43,7 @@ using _ThisAssembly = System.Properties.ThisAssembly;
|
||||
|
||||
namespace System.Application
|
||||
{
|
||||
static class Startup
|
||||
static partial class Startup
|
||||
{
|
||||
static bool isInitialized;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user