fix: 登录二维码按页面图片方式获取

This commit is contained in:
Nixevol
2026-10-16 17:08:39 +08:00
parent 889383569f
commit 26ab215890
3 changed files with 36 additions and 13 deletions
+5 -2
View File
@@ -195,12 +195,15 @@ func (a *App) login(w http.ResponseWriter, r *http.Request) {
func (a *App) qrCode(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 40*time.Second)
defer cancel()
img, err := a.client.QRCode(ctx)
img, ctype, err := a.client.QRCode(ctx)
if err != nil {
writeErr(w, err.Error())
return
}
w.Header().Set("Content-Type", "image/jpeg")
if ctype == "" {
ctype = "image/png"
}
w.Header().Set("Content-Type", ctype)
w.Header().Set("Cache-Control", "no-store")
_, _ = w.Write(img)
}