From 5798da1edc3b184a8128220308aaa443e4643555 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Sun, 15 Dec 2024 21:07:40 +0800 Subject: [PATCH] refactor: move appInfo to EasydictMainMenu --- Easydict/App/EasydictApp.swift | 10 +--------- .../Swift/View/MenuView/MainMenuCommand.swift | 20 ++++++++++++++----- .../MenuView/MainMenuShortcutCommand.swift | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Easydict/App/EasydictApp.swift b/Easydict/App/EasydictApp.swift index d1b33a5a6..140f6f003 100644 --- a/Easydict/App/EasydictApp.swift +++ b/Easydict/App/EasydictApp.swift @@ -67,15 +67,7 @@ struct EasydictApp: App { } .menuBarExtraStyle(.menu) .commands { - EasyDictMainMenu() // main menu - // Override About button - CommandGroup(replacing: .appInfo) { - Button { - openWindow(id: .aboutWindowId) - } label: { - Text("menubar.about") - } - } + EasydictMainMenu() // main menu } Settings { diff --git a/Easydict/Swift/View/MenuView/MainMenuCommand.swift b/Easydict/Swift/View/MenuView/MainMenuCommand.swift index 1330cf5b0..54a58b58b 100644 --- a/Easydict/Swift/View/MenuView/MainMenuCommand.swift +++ b/Easydict/Swift/View/MenuView/MainMenuCommand.swift @@ -8,22 +8,32 @@ import SwiftUI -struct EasyDictMainMenu: Commands { +struct EasydictMainMenu: Commands { // MARK: Internal var body: some Commands { - // shortcut + // Shortcuts MainMenuShortcutCommand() - // Help - CommandGroup(replacing: CommandGroupPlacement.help, addition: { + // Override Help + CommandGroup(replacing: .help) { Button("menu_feedback") { openURL(URL(string: "\(EZGithubRepoEasydictURL)/issues")!) } - }) + } + + // Override About + CommandGroup(replacing: .appInfo) { + Button { + openWindow(id: .aboutWindowId) + } label: { + Text("menubar.about") + } + } } // MARK: Private @Environment(\.openURL) private var openURL + @Environment(\.openWindow) private var openWindow } diff --git a/Easydict/Swift/View/MenuView/MainMenuShortcutCommand.swift b/Easydict/Swift/View/MenuView/MainMenuShortcutCommand.swift index e562eda82..280a49f6c 100644 --- a/Easydict/Swift/View/MenuView/MainMenuShortcutCommand.swift +++ b/Easydict/Swift/View/MenuView/MainMenuShortcutCommand.swift @@ -8,7 +8,7 @@ import SwiftUI -extension EasyDictMainMenu { +extension EasydictMainMenu { struct MainMenuShortcutCommand: Commands { // MARK: Internal