🎨 Optimize code
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||
)
|
||||
|
||||
// HotkeyService 全局热键服务
|
||||
// HotkeyService 存根热键服务
|
||||
type HotkeyService struct {
|
||||
logger *log.LoggerService
|
||||
configService *ConfigService
|
||||
@@ -24,7 +24,7 @@ type HotkeyError struct {
|
||||
|
||||
// Error 实现error接口
|
||||
func (e *HotkeyError) Error() string {
|
||||
return fmt.Sprintf("hotkey error during %s: %v", e.Operation, e.Err)
|
||||
return fmt.Sprintf("hotkey %s: %v", e.Operation, e.Err)
|
||||
}
|
||||
|
||||
// Unwrap 获取原始错误
|
||||
@@ -32,7 +32,7 @@ func (e *HotkeyError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
// NewHotkeyService 创建新的热键服务实例
|
||||
// NewHotkeyService 创建热键服务实例
|
||||
func NewHotkeyService(configService *ConfigService, logger *log.LoggerService) *HotkeyService {
|
||||
if logger == nil {
|
||||
logger = log.New()
|
||||
@@ -46,40 +46,39 @@ func NewHotkeyService(configService *ConfigService, logger *log.LoggerService) *
|
||||
|
||||
// Initialize 初始化热键服务
|
||||
func (hs *HotkeyService) Initialize(app *application.App) error {
|
||||
hs.logger.Warning("Hotkey: Global hotkey is not supported on this platform")
|
||||
hs.logger.Warning("Global hotkey is not supported on this platform")
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterHotkey 注册全局热键
|
||||
func (hs *HotkeyService) RegisterHotkey(hotkey *models.HotkeyCombo) error {
|
||||
return &HotkeyError{Operation: "register", Err: fmt.Errorf("not supported on this platform")}
|
||||
return &HotkeyError{"register", fmt.Errorf("not supported on this platform")}
|
||||
}
|
||||
|
||||
// UnregisterHotkey 取消注册全局热键
|
||||
func (hs *HotkeyService) UnregisterHotkey() error {
|
||||
return &HotkeyError{Operation: "unregister", Err: fmt.Errorf("not supported on this platform")}
|
||||
return &HotkeyError{"unregister", fmt.Errorf("not supported on this platform")}
|
||||
}
|
||||
|
||||
// UpdateHotkey 更新热键配置
|
||||
func (hs *HotkeyService) UpdateHotkey(enable bool, hotkey *models.HotkeyCombo) error {
|
||||
if enable {
|
||||
return hs.RegisterHotkey(hotkey)
|
||||
} else {
|
||||
return hs.UnregisterHotkey()
|
||||
}
|
||||
return hs.UnregisterHotkey()
|
||||
}
|
||||
|
||||
// GetCurrentHotkey 获取当前注册的热键
|
||||
// GetCurrentHotkey 获取当前热键
|
||||
func (hs *HotkeyService) GetCurrentHotkey() *models.HotkeyCombo {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsRegistered 检查是否已注册热键
|
||||
// IsRegistered 检查是否已注册
|
||||
func (hs *HotkeyService) IsRegistered() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ServiceShutdown 关闭热键服务
|
||||
// ServiceShutdown 关闭服务
|
||||
func (hs *HotkeyService) ServiceShutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user