fix #28 添加配置项qr_code可推送二维码

fix 修复了edge_path无效的问题
This commit is contained in:
johlanse 2022-04-11 11:19:26 +08:00
parent 95b16a35ae
commit 17881510a4
2 changed files with 25 additions and 11 deletions

View File

@ -31,13 +31,14 @@ type Config struct {
Proxy string `json:"proxy" yaml:"proxy"` Proxy string `json:"proxy" yaml:"proxy"`
} `json:"tg" yaml:"tg"` } `json:"tg" yaml:"tg"`
Web struct { Web struct {
Account string `json:"account"` Account string `json:"account" yaml:"account"`
Password string `json:"password"` Password string `json:"password" yaml:"password"`
Host string `json:"host"` Host string `json:"host" yaml:"host"`
Port int `json:"port"` Port int `json:"port" yaml:"port"`
} `json:"web"` } `json:"web"`
Cron string `json:"cron"` Cron string `json:"cron" yaml:"cron"`
EdgePath string `json:"edge_path"` EdgePath string `json:"edge_path" yaml:"edge_path"`
QrCOde bool `json:"qr_code" yaml:"qr_code"`
} }
var ( var (

View File

@ -1,6 +1,7 @@
package lib package lib
import ( import (
"encoding/base64"
"errors" "errors"
"fmt" "fmt"
"image" "image"
@ -89,6 +90,13 @@ func (c *Core) Init() {
} }
} }
// L
/**
* @Description:
* @receiver c
* @return *model.User
* @return error
*/
func (c *Core) L() (*model.User, error) { func (c *Core) L() (*model.User, error) {
client := req.C() client := req.C()
client.OnAfterResponse(func(client *req.Client, response *req.Response) error { client.OnAfterResponse(func(client *req.Client, response *req.Response) error {
@ -119,6 +127,10 @@ func (c *Core) L() (*model.User, error) {
} else { } else {
log.Infoln("二维码已生成到目录下的qrcode.png") log.Infoln("二维码已生成到目录下的qrcode.png")
} }
if GetConfig().QrCOde {
data, _ := os.ReadFile("qrcode.png")
c.Push("markdown", fmt.Sprintf("![](%v)", "data:image/png;base64,"+base64.StdEncoding.EncodeToString(data)))
}
qrCodeString := qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.QRCodeRecoveryLevels.Low).Get(codeURL) qrCodeString := qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.QRCodeRecoveryLevels.Low).Get(codeURL)
qrCodeString.Print() qrCodeString.Print()
@ -208,13 +220,13 @@ func (c *Core) initWondows() {
"--start-maximized", "--start-maximized",
"--no-sandbox", "--no-sandbox",
"--window-size=500,450", "--window-size=500,450",
// "--mute-audio", "--mute-audio",
"--window-position=0,0", "--window-position=0,0",
"--ignore-certificate-errors", "--ignore-certificate-errors",
// "--ignore-ssl-errors", "--ignore-ssl-errors",
// "--disable-features=RendererCodeIntegrity", "--disable-features=RendererCodeIntegrity",
// "--disable-blink-features", "--disable-blink-features",
// "--disable-blink-features=AutomationControlled", "--disable-blink-features=AutomationControlled",
}, },
Channel: nil, Channel: nil,
ChromiumSandbox: nil, ChromiumSandbox: nil,
@ -234,6 +246,7 @@ func (c *Core) initWondows() {
log.Errorln("[core] ", err.Error()) log.Errorln("[core] ", err.Error())
return return
} }
c.browser = browser c.browser = browser
context, err := c.browser.NewContext() context, err := c.browser.NewContext()