From 778055cd1d95c019b5b81e3040baac6a3d033d18 Mon Sep 17 00:00:00 2001 From: mamamiyear Date: Tue, 7 Jul 2026 14:03:02 +0800 Subject: [PATCH] feat: unify status feedback for copy, save and cancel actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Route the copy-to-clipboard and save-to-disk pipelines through emitOperationStatus so they show the same running/success/error stages as the upload, save-remote and summary flows, and surface a short "已取消" status when a capture is cancelled. This gives every capture action a consistent HUD experience. --- app.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app.go b/app.go index 3fac457..b3607f4 100644 --- a/app.go +++ b/app.go @@ -320,17 +320,32 @@ func (a *App) runUploadPipeline(provider domain.OSSProvider, pngBytes []byte) er func (a *App) runCopyImagePipeline(pngBytes []byte) error { svc := &application.CaptureActionsService{ Clipboard: a.clip, - Notifier: &runtimeNotifier{ctx: a.ctx}, } - return svc.CopyImage(a.ctx, pngBytes) + a.emitOperationStatus("copy", "复制中", "正在把截图复制到剪贴板", "running") + if err := svc.CopyImage(a.ctx, pngBytes); err != nil { + a.emitOperationStatus("copy", "复制失败", err.Error(), "error") + wruntime.EventsEmit(a.ctx, "upload:failure", err.Error()) + return err + } + a.emitOperationStatus("copy", "复制完成", "截图已复制到剪贴板", "success") + wruntime.EventsEmit(a.ctx, "upload:success", "image copied to clipboard") + return nil } func (a *App) runSaveImagePipeline(pngBytes []byte, dir string) (string, error) { svc := &application.CaptureActionsService{ Clipboard: a.clip, - Notifier: &runtimeNotifier{ctx: a.ctx}, } - return svc.SaveImage(a.ctx, pngBytes, dir) + a.emitOperationStatus("save", "保存中", "正在保存截图到本地", "running") + path, err := svc.SaveImage(a.ctx, pngBytes, dir) + if err != nil { + a.emitOperationStatus("save", "保存失败", err.Error(), "error") + wruntime.EventsEmit(a.ctx, "upload:failure", err.Error()) + return "", err + } + a.emitOperationStatus("save", "保存完成", path, "success") + wruntime.EventsEmit(a.ctx, "upload:success", path) + return path, nil } // runSaveRemotePipeline uploads the captured PNG to the configured SSH host @@ -939,6 +954,7 @@ func (a *App) CancelRegion() { a.pendingMu.Unlock() a.capturing.Store(false) a.dismissOverlay() + a.emitOperationStatus("capture", "已取消", "本次截图已取消", "success") } // CancelNativeRegion releases native-overlay state without touching the @@ -949,6 +965,7 @@ func (a *App) CancelNativeRegion() { a.pendingMu.Unlock() a.capturing.Store(false) hideDockIcon() + a.emitOperationStatus("capture", "已取消", "本次截图已取消", "success") } // ShowWindow brings the main window back to the foreground in its normal