From 5cc18a4e6b0aed3753b88791f457f4cc97282e95 Mon Sep 17 00:00:00 2001 From: pppscn <35696959@qq.com> Date: Thu, 7 Jan 2021 23:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E5=90=8E=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=85=B3=E9=97=AD=E7=85=A7=E7=89=87=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/lib.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/lib.go b/common/lib.go index ddbcfe0..f7d9541 100644 --- a/common/lib.go +++ b/common/lib.go @@ -102,8 +102,18 @@ func Exists(path string) bool { func OpenImage(qrPath string) { if runtime.GOOS == "windows" {//windows - cmd := exec.Command("cmd", "/k", "start", qrPath) + cmd := exec.Command("cmd", "/c", "rundll32.exe", "C:\\Windows\\System32\\shimgvw.dll,ImageView_FullscreenA", qrPath) _ = cmd.Start() + //扫码后二维码自动删除,自动关闭照片查看器 + go func() { + for { + time.Sleep(time.Duration(1) * time.Second) + if !Exists(qrPath) { + _ = exec.Command("taskkill", "/F", "/T", "/PID", fmt.Sprint(cmd.Process.Pid)).Run() + break + } + } + }() }else if runtime.GOOS == "darwin" {//Macos cmd := exec.Command("open", qrPath) _ = cmd.Start()