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"`
} `json:"tg" yaml:"tg"`
Web struct {
Account string `json:"account"`
Password string `json:"password"`
Host string `json:"host"`
Port int `json:"port"`
Account string `json:"account" yaml:"account"`
Password string `json:"password" yaml:"password"`
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
} `json:"web"`
Cron string `json:"cron"`
EdgePath string `json:"edge_path"`
Cron string `json:"cron" yaml:"cron"`
EdgePath string `json:"edge_path" yaml:"edge_path"`
QrCOde bool `json:"qr_code" yaml:"qr_code"`
}
var (

View File

@ -1,6 +1,7 @@
package lib
import (
"encoding/base64"
"errors"
"fmt"
"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) {
client := req.C()
client.OnAfterResponse(func(client *req.Client, response *req.Response) error {
@ -119,6 +127,10 @@ func (c *Core) L() (*model.User, error) {
} else {
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.Print()
@ -208,13 +220,13 @@ func (c *Core) initWondows() {
"--start-maximized",
"--no-sandbox",
"--window-size=500,450",
// "--mute-audio",
"--mute-audio",
"--window-position=0,0",
"--ignore-certificate-errors",
// "--ignore-ssl-errors",
// "--disable-features=RendererCodeIntegrity",
// "--disable-blink-features",
// "--disable-blink-features=AutomationControlled",
"--ignore-ssl-errors",
"--disable-features=RendererCodeIntegrity",
"--disable-blink-features",
"--disable-blink-features=AutomationControlled",
},
Channel: nil,
ChromiumSandbox: nil,
@ -234,6 +246,7 @@ func (c *Core) initWondows() {
log.Errorln("[core] ", err.Error())
return
}
c.browser = browser
context, err := c.browser.NewContext()