From a5842be993c469972e7b1746b534dec4c5418f77 Mon Sep 17 00:00:00 2001 From: e1732a364fed <75717694+e1732a364fed@users.noreply.github.com> Date: Sat, 1 Jan 2000 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=AE=A2gui=E4=BB=A3=E7=A0=81,?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=9F=E6=88=90=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=80=89=E9=A1=B9;=E6=9B=B4=E6=96=B0gomobile?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/verysimple/gui.go | 13 --------- cmd/verysimple/gui_menu.go | 59 ++++++++++++++++++++++++++++++++++++++ machine/genaar.sh | 2 +- 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/cmd/verysimple/gui.go b/cmd/verysimple/gui.go index c4ab3a6..d2da74e 100644 --- a/cmd/verysimple/gui.go +++ b/cmd/verysimple/gui.go @@ -17,7 +17,6 @@ import ( "github.com/e1732a364fed/v2ray_simple/netLayer" "github.com/e1732a364fed/v2ray_simple/utils" "go.uber.org/zap" - "rsc.io/qr" ) var ( @@ -54,18 +53,6 @@ func init() { multilineEntry.SetText(strings.Join(strs, "\n")) } - const qrname = "vs_qrcode.png" - - c, err := qr.Encode("https://example.org", qr.L) - if err != nil { - log.Fatal(err) - } - pngdat := c.PNG() - if true { - os.WriteFile(qrname, pngdat, 0666) - } - utils.OpenFile(qrname) - } defer func() { diff --git a/cmd/verysimple/gui_menu.go b/cmd/verysimple/gui_menu.go index c9b886a..ca34731 100644 --- a/cmd/verysimple/gui_menu.go +++ b/cmd/verysimple/gui_menu.go @@ -12,6 +12,7 @@ import ( "github.com/e1732a364fed/v2ray_simple/netLayer" "github.com/e1732a364fed/v2ray_simple/utils" "go.uber.org/zap" + "rsc.io/qr" ) func setMenu() { @@ -56,6 +57,64 @@ func setMenu() { tryDownloadGeositeSource() }) + filesM.AppendSeparator() + + filesM.AppendItem("从当前配置生成标准toml配置文件的QRCode").OnClicked(func(mi *ui.MenuItem, w *ui.Window) { + + vc := mainM.DumpVSConf() + + bs, e := utils.GetPurgedTomlBytes(vc) + if e != nil { + if ce := utils.CanLogErr("转换格式错误"); ce != nil { + ce.Write(zap.Error(e)) + } + + return + } + str := string(bs) + + const qrname = "vs_qrcode.png" + + c, err := qr.Encode(str, qr.L) + if err != nil { + log.Fatal(err) + } + pngdat := c.PNG() + if true { + os.WriteFile(qrname, pngdat, 0666) + } + utils.OpenFile(qrname) + }) + + filesM.AppendItem("从当前配置到第一个dial生成对应toml的QRCode").OnClicked(func(mi *ui.MenuItem, w *ui.Window) { + + vc := mainM.DumpStandardConf() + if len(vc.Dial) == 0 { + return + } + + bs, e := utils.GetPurgedTomlBytes(vc.Dial[0]) + if e != nil { + if ce := utils.CanLogErr("转换格式错误"); ce != nil { + ce.Write(zap.Error(e)) + } + + return + } + str := string(bs) + + const qrname = "vs_qrcode.png" + + c, err := qr.Encode(str, qr.L) + if err != nil { + log.Fatal(err) + } + pngdat := c.PNG() + if true { + os.WriteFile(qrname, pngdat, 0666) + } + utils.OpenFile(qrname) + }) } var viewM = ui.NewMenu("View") diff --git a/machine/genaar.sh b/machine/genaar.sh index ae4aa2e..8fd5d95 100755 --- a/machine/genaar.sh +++ b/machine/genaar.sh @@ -1,3 +1,3 @@ go get golang.org/x/mobile/bind -gomobile bind -v -o xx.aar -target=android . +gomobile bind -v -o xx.aar -target=android -ldflags "-s -w -buildid=" -trimpath . go mod tidy \ No newline at end of file