Skip to content

Commit

Permalink
refactor: move appInfo to EasydictMainMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Dec 15, 2024
1 parent 89b7ecc commit 5798da1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 1 addition & 9 deletions Easydict/App/EasydictApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 15 additions & 5 deletions Easydict/Swift/View/MenuView/MainMenuCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion Easydict/Swift/View/MenuView/MainMenuShortcutCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

extension EasyDictMainMenu {
extension EasydictMainMenu {
struct MainMenuShortcutCommand: Commands {
// MARK: Internal

Expand Down

0 comments on commit 5798da1

Please sign in to comment.