From 17881510a405762405fc87ae1e5592b4463a900f Mon Sep 17 00:00:00 2001 From: johlanse Date: Mon, 11 Apr 2022 11:19:26 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#28=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9qr=5Fcode=E5=8F=AF=E6=8E=A8=E9=80=81=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=20fix=20=E4=BF=AE=E5=A4=8D=E4=BA=86edge=5Fpa?= =?UTF-8?q?th=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config.go | 13 +++++++------ lib/core.go | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/config.go b/lib/config.go index cf59478..2080515 100644 --- a/lib/config.go +++ b/lib/config.go @@ -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 ( diff --git a/lib/core.go b/lib/core.go index 38eda52..1526c9e 100644 --- a/lib/core.go +++ b/lib/core.go @@ -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()