feat: unify status feedback for copy, save and cancel actions
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.
This commit is contained in:
@@ -320,17 +320,32 @@ func (a *App) runUploadPipeline(provider domain.OSSProvider, pngBytes []byte) er
|
|||||||
func (a *App) runCopyImagePipeline(pngBytes []byte) error {
|
func (a *App) runCopyImagePipeline(pngBytes []byte) error {
|
||||||
svc := &application.CaptureActionsService{
|
svc := &application.CaptureActionsService{
|
||||||
Clipboard: a.clip,
|
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) {
|
func (a *App) runSaveImagePipeline(pngBytes []byte, dir string) (string, error) {
|
||||||
svc := &application.CaptureActionsService{
|
svc := &application.CaptureActionsService{
|
||||||
Clipboard: a.clip,
|
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
|
// runSaveRemotePipeline uploads the captured PNG to the configured SSH host
|
||||||
@@ -939,6 +954,7 @@ func (a *App) CancelRegion() {
|
|||||||
a.pendingMu.Unlock()
|
a.pendingMu.Unlock()
|
||||||
a.capturing.Store(false)
|
a.capturing.Store(false)
|
||||||
a.dismissOverlay()
|
a.dismissOverlay()
|
||||||
|
a.emitOperationStatus("capture", "已取消", "本次截图已取消", "success")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CancelNativeRegion releases native-overlay state without touching the
|
// CancelNativeRegion releases native-overlay state without touching the
|
||||||
@@ -949,6 +965,7 @@ func (a *App) CancelNativeRegion() {
|
|||||||
a.pendingMu.Unlock()
|
a.pendingMu.Unlock()
|
||||||
a.capturing.Store(false)
|
a.capturing.Store(false)
|
||||||
hideDockIcon()
|
hideDockIcon()
|
||||||
|
a.emitOperationStatus("capture", "已取消", "本次截图已取消", "success")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShowWindow brings the main window back to the foreground in its normal
|
// ShowWindow brings the main window back to the foreground in its normal
|
||||||
|
|||||||
Reference in New Issue
Block a user