Browse Source

fix qrcode display error

liuyuqi-dellpc 5 years ago
parent
commit
c3defdf3b6
2 changed files with 5 additions and 3 deletions
  1. 1 0
      .gitignore
  2. 4 3
      qr/qr.go

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 qr-filetransfer
 qrcp
 dist
+/.idea

+ 4 - 3
qr/qr.go

@@ -1,16 +1,17 @@
 package qr
 
 import (
-	"fmt"
+	"os/exec"
 
 	"github.com/skip2/go-qrcode"
 )
 
 // RenderString as a QR code
 func RenderString(s string) {
-	q, err := qrcode.New(s, qrcode.Medium)
+	err := qrcode.WriteFile(s, qrcode.Medium, 200, "tmp.png")
 	if err != nil {
 		panic(err)
 	}
-	fmt.Println(q.ToSmallString(false))
+	cmd:=exec.Command("rundll32.exe", "url.dll,FileProtocolHandler", "tmp.png")
+	cmd.Start()
 }