Skip to content

Commit

Permalink
✨ 设置 macOS 菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
Mossimos committed Nov 29, 2024
1 parent cc8dbeb commit 002e550
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/BD.WTTS.Client.Avalonia.App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<dict>
<key>CFBundleName</key>
<string>Watt Toolkit</string>
<key>CFBundleDisplayName</key>
<string>Watt Toolkit</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<key>CFBundleVersion</key>
<string>3.0.0.0</string>
<string>3.0.1219.0</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
4 changes: 4 additions & 0 deletions src/BD.WTTS.Client.Avalonia.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ IEnumerable<X11RenderingMode> GetRenderingMode()
{
RenderingMode = GetRenderingMode().ToArray(),
});
builder.With(new MacOSPlatformOptions
{
DisableDefaultApplicationMenuItems = true,
});
#elif LINUX
builder.With(new X11PlatformOptions
{
Expand Down
8 changes: 8 additions & 0 deletions src/BD.WTTS.Client.Avalonia/UI/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ public sealed partial class App : Application

public App()
{
Name = AssemblyInfo.Trademark;
OpenBrowserCommand = ReactiveCommand.Create<object?>(OpenBrowserCommandCore);
CopyToClipboardCommand = ReactiveCommand.Create<object?>(CopyToClipboardCommandCore);
#if MACOS
var menus = new NativeMenu();
menus.Add(new NativeMenuItem { Header = Strings.Settings, Command = ReactiveCommand.Create(() => { INavigationService.Instance.Navigate(typeof(SettingsPage)); }) });
menus.Add(new NativeMenuItemSeparator());
menus.Add(new NativeMenuItem { Header = Strings.Exit, Command = ReactiveCommand.Create(() => { Shutdown(); }) });
NativeMenu.SetMenu(this, menus);
#endif
}

/// <summary>
Expand Down

0 comments on commit 002e550

Please sign in to comment.