Skip to content

Commit

Permalink
fix macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Mar 1, 2021
1 parent e081b13 commit da4bc1a
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ English | [简体中文](./README.md)

## ⛔ Unsupported Operating System
- Windows 8
- [Due to Microsoft's official support for the product has ended](https://docs.microsoft.com/lifecycle/products/windows-8), so this program cannot run on this operating system, [It is recommended to upgrade to Windows 8.1](https://support.microsoft.com/windows/update-to-windows-8-1-from-windows-8-17fc54a7-a465-6b5a-c1a0-34140afd0669) or Windows 10
- [Due to Microsoft's official support for the product has ended](https://docs.microsoft.com/lifecycle/products/windows-8), so this program cannot run on this operating system, [It is recommended to upgrade to Windows 8.1](https://support.microsoft.com/windows/update-to-windows-8-1-from-windows-8-17fc54a7-a465-6b5a-c1a0-34140afd0669)
- Windows Server 2012 / 2008 R2 SP1
- Only version 1.X is available, and version 2.X is not supported. It is recommended to upgrade to **Windows Server 2012 R2** or higher
- Windows Server / Linux version without desktop GUI
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
## ✨ 功能
1. 反代 Steam 的社区网页使其能正常访问
- 功能类似羽翼城大佬的 [steamcommunity_302](https://www.dogfight360.com/blog/686/)
- 使用 [Titanium-Web-Proxy](https://github.com/justcoding121/Titanium-Web-Proxy) 开源项目进行本地反代,使国内用户可以正常访问steam社区页
- 使用 [Titanium-Web-Proxy](https://github.com/justcoding121/Titanium-Web-Proxy) 开源项目进行本地反代,使国内用户可以正常访问 Steam 社区页
- 相比 **302工具** 具有更快的启动速度,以及支持简单的脚本注入(还顺便支持了Pixiv、Discord、Twitch等网站的反代支持)
2. 快速切换当前设备已记住登陆的 Steam 账号
- 该功能是读取 Steam 路径下存储的本地用户登录记录直接展示操作,可以多账号切换无需重新输入密码和令牌
Expand Down Expand Up @@ -61,7 +61,7 @@

## ⛔ 不受支持的操作系统
- Windows 8
- [由于微软官方对该产品的支持已结束](https://docs.microsoft.com/zh-cn/lifecycle/products/windows-8),故本程序无法在此操作系统上运行,[建议升级到 Windows 8.1](https://support.microsoft.com/zh-cn/windows/%E4%BB%8E-windows-8-%E6%9B%B4%E6%96%B0%E5%88%B0-windows-8-1-17fc54a7-a465-6b5a-c1a0-34140afd0669) 或 Windows 10
- [由于微软官方对该产品的支持已结束](https://docs.microsoft.com/zh-cn/lifecycle/products/windows-8),故本程序无法在此操作系统上运行,[建议升级到 Windows 8.1](https://support.microsoft.com/zh-cn/windows/%E4%BB%8E-windows-8-%E6%9B%B4%E6%96%B0%E5%88%B0-windows-8-1-17fc54a7-a465-6b5a-c1a0-34140afd0669)
- Windows Server 2012 / 2008 R2 SP1
- 仅可使用 1.X 版本,2.X 开始不受支持,建议升级到 **Windows Server 2012 R2** 或更高版本
- 无桌面 GUI 的 Windows Server / Linux 版本
Expand Down
29 changes: 18 additions & 11 deletions System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:System.Application.UI"
x:Class="System.Application.UI.App">
<Application.DataTemplates>
<ui:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme Mode="Light" />
<StyleInclude Source="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Styles.xaml" />
<StyleInclude Source="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Controls/SideBar.xaml" />
<Style Selector="Window">
<Setter Property="Icon" Value="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Assets/Icon.ico"/>
</Style>
</Application.Styles>
<Application.DataTemplates>
<ui:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme Mode="Light" />
<StyleInclude Source="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Styles.xaml" />
<StyleInclude Source="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Controls/SideBar.xaml" />
<!--<StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml"/>-->
<Style Selector="Window">
<Setter Property="Icon" Value="avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Assets/Icon.ico"/>
</Style>
</Application.Styles>
<!-- (NativeMenu.Menu) https://github.com/AvaloniaUI/Avalonia/issues/3541 -->
<!--<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About My App" Command="{Binding AboutCommand}" />
</NativeMenu>
</NativeMenu.Menu>-->
</Application>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#if WINDOWS
using System.Windows.Shell;
using WpfApplication = System.Windows.Application;
#elif MAC
using MonoMac.AppKit;
#endif

namespace System.Application.UI
Expand All @@ -41,6 +39,9 @@ public partial class App : AvaloniaApplication, IDisposableHolder
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);

Name = ThisAssembly.AssemblyTrademark;

MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
Expand All @@ -64,10 +65,7 @@ public override void OnFrameworkInitializationCompleted()
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
#if MAC
NSApplication.Init();
var appDelegate = DI.Get<AppDelegate>();
//AvaloniaLocator.CurrentMutable.Bind<AppDelegate>().ToConstant(appDelegate);
NSApplication.SharedApplication.Delegate = appDelegate;
AppDelegate.Init();
#endif

#region NotifyIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
using Avalonia.ReactiveUI;
using NLog;
using System.IO;
using System.Properties;
using System.Reflection;
using System.Threading.Tasks;

[assembly: AssemblyTitle(ThisAssembly.AssemblyTrademark + " v" + ThisAssembly.Version)]
namespace System.Application.UI
{
static class Program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>

<!--<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AllowedReferenceRelatedFileExtensions>
--><!-- Prevent default XML and PDB files copied to output in RELEASE.
Only *.allowedextension files will be included, which doesn't exist in my case.
--><!--
.allowedextension
</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>-->

<PropertyGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
<TargetFramework>net5.0-windows</TargetFramework>
</PropertyGroup>
Expand Down Expand Up @@ -43,6 +52,18 @@
<ProjectReference Include="..\System.Application.SteamTools.Client.Desktop.Linux\System.Application.SteamTools.Client.Desktop.Linux.csproj"/>
</ItemGroup>

<!--<ItemGroup Condition=" '$(OS)' == 'Windows_NT' And $(RuntimeIdentifier.Contains(`osx`)) And $(DefineConstants.Contains(`PUBLISH`)) ">
<Reference Include="Xamarin.Mac">
<HintPath>$(MSBuildExtensionsPath)\..\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.Mac\v2.0\Xamarin.Mac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' And (($(RuntimeIdentifier.Contains(`osx`)) And $(DefineConstants.Contains(`PUBLISH`))) Or !$(DefineConstants.Contains(`PUBLISH`))) ">
--><!--<Reference Include="Xamarin.Mac">
<HintPath>$(MSBuildExtensionsPath)/???/Xamarin.Mac.dll</HintPath>
</Reference>--><!--
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="MessageBox.Avalonia" Version="1.0.5">
<Aliases>MessageBox_Avalonia</Aliases>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using System.Application.UI.ViewModels;
using System.ComponentModel;
using Avalonia.Platform;
using System.ComponentModel;

namespace System.Application.UI.Views
{
Expand All @@ -25,10 +23,10 @@ public MainWindow(IWindowImpl impl) : base(impl)
#endif
}

protected override void OnClosing(CancelEventArgs e)
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
Hide();
base.OnClosed(e);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
using MonoMac.AppKit;
#if MONO_MAC
using MonoMac.AppKit;
using MonoMac.Foundation;
using Selector = MonoMac.ObjCRuntime.Selector;
#elif XAMARIN_MAC
using AppKit;
using Foundation;
using Selector = ObjCRuntime.Selector;
#endif

namespace System.Application.UI
{
Expand All @@ -8,23 +15,31 @@ namespace System.Application.UI
/// Int it's infinite wisdom and unlike Linux and or Windows Mac does not pass in the URL from a sqrl:// invokation
/// directly as a startup app paramter, instead it uses a System Event to do this which has to be registered
/// and listed to.
/// This requires us to use MonoMac to make it work with .net core
/// This requires us to use Xamarin.Mac to make it work with .net standard
/// </summary>
[Register("AppDelegate")]
public sealed class AppDelegate : NSApplicationDelegate
{
public AppDelegate()
{
Init();
// Registers an event for handling URL Invokation
NSAppleEventManager.SharedAppleEventManager.SetEventHandler(this,
new Selector("handleGetURLEvent:withReplyEvent:"),
AEEventClass.Internet,
AEEventID.GetUrl);
}

/// <summary>
/// Registers an event for handling URL Invokation
/// </summary>
void Init()
static bool isInitialized;

public static void Init()
{
//Register this Apple Delegate globablly with Avalonia for Later Use
NSAppleEventManager.SharedAppleEventManager.SetEventHandler(this, new MonoMac.ObjCRuntime.Selector("handleGetURLEvent:withReplyEvent:"), AEEventClass.Internet, AEEventID.GetUrl);
if (!isInitialized)
{
isInitialized = true;
NSApplication.Init();
var appDelegate = DI.Get<AppDelegate>();
NSApplication.SharedApplication.Delegate = appDelegate;
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using MonoMac.AppKit;
#if MONO_MAC
using MonoMac.AppKit;
#elif XAMARIN_MAC
using AppKit;
#endif
using System.Diagnostics.CodeAnalysis;

namespace System.Application.UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>System</RootNamespace>
<DefineConstants>MONO_MAC;$(DefineConstants)</DefineConstants>
<!--<DefineConstants>XAMARIN_MAC;$(DefineConstants)</DefineConstants>-->
</PropertyGroup>

<!--<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AllowedReferenceRelatedFileExtensions>
--><!-- Prevent default XML and PDB files copied to output in RELEASE.
Only *.allowedextension files will be included, which doesn't exist in my case.
--><!--
.allowedextension
</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>-->

<ItemGroup>
<Compile Include="..\System.Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
Expand All @@ -15,6 +26,18 @@
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" />
</ItemGroup>

<!--<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
<Reference Include="Xamarin.Mac">
<HintPath>$(MSBuildExtensionsPath)\..\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.Mac\v2.0\Xamarin.Mac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' ">
--><!--<Reference Include="Xamarin.Mac">
<HintPath>$(MSBuildExtensionsPath)/???/Xamarin.Mac.dll</HintPath>
</Reference>--><!--
</ItemGroup>-->

<ItemGroup>
<ProjectReference Include="..\System.Application.SteamTools.Client.Desktop\System.Application.SteamTools.Client.Desktop.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public string IconPath
{
try
{
if (string.IsNullOrWhiteSpace(value))
{
_icon = null;
_iconPath = string.Empty;
return;
}

// Check if path is a file system or resource path
if (value.StartsWith("resm:") || value.StartsWith("avares://"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public OperationResultBase(OperationResultType resultType, string message)
/// <param name="resultType">操作结果类型</param>
/// <param name="message">返回消息</param>
/// <param name="appendData">返回数据</param>
public OperationResultBase(OperationResultType resultType, string message, T appendData)
public OperationResultBase(OperationResultType resultType, string message, T? appendData)
: this(resultType, message)
{
AppendData = appendData;
Expand All @@ -66,7 +66,7 @@ public OperationResultBase(OperationResultType resultType, string message, strin
/// <param name="message">返回消息</param>
/// <param name="logMessage">日志记录消息</param>
/// <param name="appendData">返回数据</param>
public OperationResultBase(OperationResultType resultType, string message, string logMessage, T appendData)
public OperationResultBase(OperationResultType resultType, string message, string logMessage, T? appendData)
: this(resultType, message, logMessage)
{
AppendData = appendData;
Expand Down Expand Up @@ -168,6 +168,8 @@ public OperationResult(OperationResultType resultType, string message, string lo
}

[NotNull, DisallowNull] // C# 8 not null
#pragma warning disable CS8765 // 参数类型的为 Null 性与重写成员不匹配(可能是由于为 Null 性特性)。
public sealed override T? AppendData { get; set; } = new T();
#pragma warning restore CS8765 // 参数类型的为 Null 性与重写成员不匹配(可能是由于为 Null 性特性)。
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.Application.UI.Views
/// </summary>
public partial class Form1 : Form
{
readonly string app_path = @"\System.Application.SteamTools.Client.Desktop.Avalonia.App\bin\Release\Publish\win-x64";
readonly string app_path = @"\System.Application.SteamTools.Client.Desktop.Avalonia.App\bin\Release\Publish\win-x86";

static string GetPath(string path)
{
Expand Down
Loading

0 comments on commit da4bc1a

Please sign in to comment.