mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 23:19:53 +08:00
add macOS igonre, fix macOS notifyIcon
This commit is contained in:
@@ -12,9 +12,9 @@ namespace System.Application
|
||||
{
|
||||
public static bool IsMainThread => Instance.PlatformIsMainThread;
|
||||
|
||||
public static void BeginInvokeOnMainThread(Action action, DispatcherPriority? priority = null)
|
||||
public static void BeginInvokeOnMainThread(Action action, DispatcherPriority? priority = null, bool isForce = false)
|
||||
{
|
||||
if (IsMainThread)
|
||||
if (!isForce && IsMainThread)
|
||||
{
|
||||
action();
|
||||
}
|
||||
@@ -24,9 +24,9 @@ namespace System.Application
|
||||
}
|
||||
}
|
||||
|
||||
public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriority? priority = null)
|
||||
public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriority? priority = null, bool isForce = false)
|
||||
{
|
||||
if (IsMainThread)
|
||||
if (!isForce && IsMainThread)
|
||||
{
|
||||
action();
|
||||
#if NETSTANDARD1_0
|
||||
@@ -49,14 +49,14 @@ namespace System.Application
|
||||
{
|
||||
tcs.TrySetException(ex);
|
||||
}
|
||||
}, priority);
|
||||
}, priority, isForce);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func, DispatcherPriority? priority = null)
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func, DispatcherPriority? priority = null, bool isForce = false)
|
||||
{
|
||||
if (IsMainThread)
|
||||
if (!isForce && IsMainThread)
|
||||
{
|
||||
return Task.FromResult(func());
|
||||
}
|
||||
@@ -74,14 +74,14 @@ namespace System.Application
|
||||
{
|
||||
tcs.TrySetException(ex);
|
||||
}
|
||||
}, priority);
|
||||
}, priority, isForce);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static Task InvokeOnMainThreadAsync(Func<Task> funcTask, DispatcherPriority? priority = null)
|
||||
public static Task InvokeOnMainThreadAsync(Func<Task> funcTask, DispatcherPriority? priority = null, bool isForce = false)
|
||||
{
|
||||
if (IsMainThread)
|
||||
if (!isForce && IsMainThread)
|
||||
{
|
||||
return funcTask();
|
||||
}
|
||||
@@ -100,14 +100,14 @@ namespace System.Application
|
||||
{
|
||||
tcs.SetException(e);
|
||||
}
|
||||
}, priority);
|
||||
}, priority, isForce);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask, DispatcherPriority? priority = null)
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask, DispatcherPriority? priority = null, bool isForce = false)
|
||||
{
|
||||
if (IsMainThread)
|
||||
if (!isForce && IsMainThread)
|
||||
{
|
||||
return funcTask();
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace System.Application
|
||||
{
|
||||
tcs.SetException(e);
|
||||
}
|
||||
}, priority);
|
||||
}, priority, isForce);
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace System.Application.Services
|
||||
/// </summary>
|
||||
string HostsFilePath => "/etc/hosts";
|
||||
|
||||
void StartProcess(string name, string filePath) => Process.Start(name, filePath);
|
||||
|
||||
/// <summary>
|
||||
/// 使用文本阅读器打开文件
|
||||
/// </summary>
|
||||
@@ -50,7 +52,7 @@ namespace System.Application.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(value, filePath);
|
||||
StartProcess(value, filePath);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -79,7 +81,7 @@ namespace System.Application.Services
|
||||
{
|
||||
var fileName = GetFileName(item);
|
||||
if (fileName == null) continue;
|
||||
Process.Start(fileName, filePath);
|
||||
StartProcess(fileName, filePath);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
+3
-3
@@ -38,11 +38,11 @@ namespace System.Application.Services.Implementation
|
||||
var rspContentClrType = typeof(T);
|
||||
if (rspContentClrType == typeof(string))
|
||||
{
|
||||
return (T)(object)await response.Content.ReadAsStringAsync(cancellationToken);
|
||||
return (T)(object)await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else if (rspContentClrType == typeof(byte[]))
|
||||
{
|
||||
return (T)(object)await response.Content.ReadAsByteArrayAsync(cancellationToken);
|
||||
return (T)(object)await response.Content.ReadAsByteArrayAsync();
|
||||
}
|
||||
else if (rspContentClrType == typeof(Stream))
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace System.Application.Services.Implementation
|
||||
case MediaTypeNames.XML_APP:
|
||||
{
|
||||
using var stream = await response.Content
|
||||
.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
.ReadAsStreamAsync().ConfigureAwait(false);
|
||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||
switch (mime)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<RootNamespace>System.Application</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user