feat 初始化
This commit is contained in:
19
utils/qr.go
Normal file
19
utils/qr.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
func GetQRCodeIO(content string, size ...int) string {
|
||||
s := 260 // 写死尺寸 260*260
|
||||
if len(size) > 0 {
|
||||
s = size[0]
|
||||
}
|
||||
png, err := qrcode.Encode(content, qrcode.High, s)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return "data:image/png;base64," + base64.StdEncoding.EncodeToString(png)
|
||||
}
|
||||
Reference in New Issue
Block a user