(ctx: SystemCommandContext)
| 698 | } |
| 699 | |
| 700 | function handleColorPicker(ctx: SystemCommandContext): Promise<any> { |
| 701 | console.log('[SystemCmd] 执行屏幕取色') |
| 702 | ctx.mainWindow?.hide() |
| 703 | |
| 704 | return new Promise((resolve) => { |
| 705 | try { |
| 706 | ColorPicker.start((result) => { |
| 707 | if (result.success && result.hex) { |
| 708 | clipboard.writeText(result.hex) |
| 709 | console.log('[SystemCmd] 已复制颜色值:', result.hex) |
| 710 | if (Notification.isSupported()) { |
| 711 | new Notification({ title: 'ZTools', body: `已复制颜色值: ${result.hex}` }).show() |
| 712 | } |
| 713 | resolve({ success: true, hex: result.hex }) |
| 714 | } else { |
| 715 | console.log('[SystemCmd] 取色已取消') |
| 716 | resolve({ success: false, error: '取色已取消' }) |
| 717 | } |
| 718 | }) |
| 719 | } catch (error) { |
| 720 | console.error('[SystemCmd] 取色失败:', error) |
| 721 | resolve({ success: false, error: String(error) }) |
| 722 | } |
| 723 | }) |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * 添加到唤醒黑名单:将唤醒前活动窗口的应用加入黑名单 |
no test coverage detected