From a496ff518a824ac60d4323a08c591ea0ff105967 Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Thu, 1 Feb 2024 15:58:04 +0800 Subject: [PATCH] fix: review problem --- .../NewApp/Feature/Shortcut/Shortcut.swift | 27 ++++++++----------- .../Shortcut/GeneralKeyHolderWrapper.swift | 4 +-- .../Shortcut/GeneralShortcutSetting.swift | 1 - 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index 2234d52fc..f4eaf72ec 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -57,27 +57,22 @@ class Shortcut: NSObject { // restore shortcut extension Shortcut { func restoreShortcut() { - if let inputTranslateKeyCombo = Defaults[.inputShortcut] { - bindingShortCut(keyCombo: inputTranslateKeyCombo, type: .inputTranslate) - } - if let snipShortcutKeyKeyCombo = Defaults[.snipShortcut] { - bindingShortCut(keyCombo: snipShortcutKeyKeyCombo, type: .snipTranslate) - } - if let selectionShortcutKeyCombo = Defaults[.selectionShortcut] { - bindingShortCut(keyCombo: selectionShortcutKeyCombo, type: .selectTranslate) - } - if let screenshotOCRShortcutKeyCombo = Defaults[.screenshotOCRShortcut] { - bindingShortCut(keyCombo: screenshotOCRShortcutKeyCombo, type: .silentScreenshotOcr) - } - if let showMiniWindowShortcutKeyCombo = Defaults[.showMiniWindowShortcut] { - bindingShortCut(keyCombo: showMiniWindowShortcutKeyCombo, type: .showMiniWindow) - } + // inputTranslate + bindingShortcut(keyCombo: Defaults[.inputShortcut], type: .inputTranslate) + // snipTranslate + bindingShortcut(keyCombo: Defaults[.snipShortcut], type: .snipTranslate) + // selectTranslate + bindingShortcut(keyCombo: Defaults[.selectionShortcut], type: .selectTranslate) + // silentScreenshotOcr + bindingShortcut(keyCombo: Defaults[.screenshotOCRShortcut], type: .silentScreenshotOcr) + // showMiniWindow + bindingShortcut(keyCombo: Defaults[.showMiniWindowShortcut], type: .showMiniWindow) } } // binding shortcut extension Shortcut { - func bindingShortCut(keyCombo: KeyCombo?, type: ShortcutType) { + func bindingShortcut(keyCombo: KeyCombo?, type: ShortcutType) { guard let keyCombo else { HotKeyCenter.shared.unregisterHotKey(with: type.rawValue) return diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift index a40007270..7c8b50c5f 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift @@ -74,7 +74,7 @@ extension GeneralKeyHolderWrapper { } } storeKeyCombo(with: keyCombo) - Shortcut.shared.bindingShortCut(keyCombo: keyCombo, type: type) + Shortcut.shared.bindingShortcut(keyCombo: keyCombo, type: type) } func restoreKeyCombo(_ recordView: RecordView) { @@ -92,7 +92,7 @@ extension GeneralKeyHolderWrapper { keyCombo = Defaults[.showMiniWindowShortcut] } recordView.keyCombo = keyCombo - Shortcut.shared.bindingShortCut(keyCombo: keyCombo, type: type) + Shortcut.shared.bindingShortcut(keyCombo: keyCombo, type: type) } // shortcut diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift index 2d2770101..c18ef3c88 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift @@ -12,7 +12,6 @@ import SwiftUI extension ShortcutTab { struct GeneralShortcutSettingView: View { @State var confictAlterMessage: ShortcutConfictAlertMessage = .init(message: "") -// @State var showAlter: Bool = false var body: some View { let showAlter = Binding(